aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/output/video/resolution.lux
blob: 1cfcd0ae80eb1e3851d62ae831b5b65e1463ebe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]
     [\\spec
      ["$." equivalence]
      ["$." hash]]]
    [data
     ["." maybe]
     [collection
      ["." list]
      ["." set (#+ Set)]]]
    [math
     ["." random (#+ Random)]
     [number
      ["n" nat]]]]]
  [\\library
   ["." /]])

(with_expansions [<resolutions> (as_is /.svga
                                       /.wsvga
                                       /.xga
                                       /.xga+
                                       /.wxga/16:9
                                       /.wxga/5:3
                                       /.wxga/16:10
                                       /.sxga
                                       /.wxga+
                                       /.hd+
                                       /.wsxga+
                                       /.fhd
                                       /.wuxga
                                       /.wqhd
                                       /.uhd-4k)]
  (def: listing
    (List /.Resolution)
    (list <resolutions>))

  (def: catalogue
    (Set /.Resolution)
    (set.from_list /.hash ..listing))

  (def: #export random
    (Random /.Resolution)
    (let [count (list.size ..listing)]
      (do {! random.monad}
        [choice (\ ! map (n.% count) random.nat)]
        (wrap (maybe.assume (list.nth choice ..listing))))))

  (def: #export test
    Test
    (<| (_.covering /._)
        (_.for [/.Resolution])
        ($_ _.and
            (_.for [/.equivalence]
                   ($equivalence.spec /.equivalence ..random))
            (_.for [/.hash]
                   ($hash.spec /.hash ..random))

            (_.cover [<resolutions>]
                     (n.= (list.size ..listing)
                          (set.size ..catalogue)))
            ))))