aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/output/video/resolution.lux
blob: 59a46f1034223aedb9f4c3068ef7631461fc600f (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
66
(.module:
  [library
   [lux "*"
    ["_" test {"+" [Test]}]
    [abstract
     [monad {"+" [do]}]
     [\\specification
      ["$." equivalence]
      ["$." hash]]]
    [control
     ["." maybe]]
    [data
     [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.of_list /.hash ..listing))

  (def: .public random
    (Random /.Resolution)
    (let [count (list.size ..listing)]
      (do [! random.monad]
        [choice (\ ! each (n.% count) random.nat)]
        (in (maybe.trusted (list.item choice ..listing))))))

  (def: .public 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)))
            ))))