aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/time/solar.lux
blob: 5611d4d5d592e4f4a3f9b544337280915a72d3ca (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
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try]
    ["[0]" exception]
    ["[0]" io]]
   [data
    ["[0]" bit (.use "[1]#[0]" equivalence)]
    ["[0]" text (.use "[1]#[0]" equivalence)
     ["%" \\format (.only format)]]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]
     ["i" int]]]
   [meta
    [compiler
     ["@" target]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" / (.only)
   [//
    ["[0]" duration]
    ["[0]" instant]]]])

(def .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Instant])
      (do random.monad
        [_ (in [])])
      (all _.and
           (_.for [/.Zone]
                  (_.coverage [/.local_zone]
                    (io.run! (do io.monad
                               [zone /.local_zone]
                               (in (for @.lua
                                        ... Lua doesn't natively support getting the time-zone ID.
                                        (text.empty? zone)
                                        
                                        ... else
                                        (not (text.empty? zone))))))))
           (_.coverage [/.now /.zone]
             (io.run! (do io.monad
                        [zone /.local_zone
                         it /.now]
                        (in (text#= zone (/.zone it))))))
           (_.coverage [/.format /.universal /.offset]
             (io.run! (do io.monad
                        [zone /.local_zone
                         it /.now]
                        (in (text.starts_with? (instant.format (instant.after (/.offset it) (/.universal it)))
                                               (/.format it))))))
           )))