aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/output/video/resolution.lux
blob: 0dec2c08a0786dcef70216a87a6c0a54b9dad15f (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
67
68
69
70
71
72
73
74
75
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    ["[0]" hash
     ["[1]T" \\test]]
    ["[0]" equivalence
     ["[1]T" \\test]]]
   [control
    ["[0]" maybe]]
   [data
    [collection
     ["[0]" list]
     ["[0]" set (.only Set)]]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(with_expansions [<resolutions> (these /.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 (of ! each (n.% count) random.nat)]
        (in (maybe.trusted (list.item choice ..listing))))))

  (def .public test
    Test
    (<| (_.covering /._)
        (_.for [/.Resolution])
        (`` (all _.and
                 (_.for [/.equivalence]
                        (equivalenceT.spec /.equivalence ..random))
                 (_.for [/.hash]
                        (hashT.spec /.hash ..random))

                 (_.coverage [<resolutions>]
                   (n.= (list.size ..listing)
                        (set.size ..catalogue)))
                 (,, (with_template [<slot>]
                       [(_.coverage [<slot>]
                          (list.every? (|>> (the <slot>) (n.> 0)) ..listing))]

                       [/.#width]
                       [/.#height]
                       ))
                 )))))