aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/meta/macro.lux2
-rw-r--r--stdlib/source/test/lux/meta/macro/expansion.lux89
-rw-r--r--stdlib/source/test/lux/world/time.lux4
-rw-r--r--stdlib/source/test/lux/world/time/solar.lux61
4 files changed, 155 insertions, 1 deletions
diff --git a/stdlib/source/test/lux/meta/macro.lux b/stdlib/source/test/lux/meta/macro.lux
index 270040d6d..d3bc360d4 100644
--- a/stdlib/source/test/lux/meta/macro.lux
+++ b/stdlib/source/test/lux/meta/macro.lux
@@ -31,6 +31,7 @@
["[0]" expansion]]]
["[0]" /
["[1][0]" context]
+ ["[1][0]" expansion]
["[1][0]" local]
["[1][0]" syntax]
["[1][0]" template]
@@ -250,6 +251,7 @@
..test|expansion
/context.test
+ /expansion.test
/local.test
/syntax.test
/template.test
diff --git a/stdlib/source/test/lux/meta/macro/expansion.lux b/stdlib/source/test/lux/meta/macro/expansion.lux
new file mode 100644
index 000000000..fb552a8fe
--- /dev/null
+++ b/stdlib/source/test/lux/meta/macro/expansion.lux
@@ -0,0 +1,89 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]]
+ [control
+ ["[0]" try]
+ ["[0]" exception]]
+ [data
+ ["[0]" text (.only)
+ ["%" \\format]]
+ [collection
+ ["[0]" list]]]
+ [math
+ [number
+ ["n" nat]]]
+ ["[0]" meta (.only)
+ ["[0]" static]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]
+ [macro
+ [syntax (.only syntax)]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(use "code_list#[0]" (list.equivalence code.equivalence))
+
+(def dup
+ (syntax (_ [times <code>.nat
+ what <code>.any])
+ (when times
+ 0 (in (list what))
+ _ (let [it (` (..dup (, (code.nat (-- times))) (, what)))]
+ (in (list it it))))))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (`` (all _.and
+ (,, (with_template [<expansion> <inner> <0> <1>]
+ [(_.coverage [<expansion>]
+ (and (<| static.expansion
+ (do meta.monad
+ [it (<expansion> (` (..dup 0 <inner>)))]
+ (in (list (code.bit (code_list#= <0>
+ it))))))
+ (<| static.expansion
+ (do meta.monad
+ [it (<expansion> (` (..dup 1 <inner>)))]
+ (in (list (code.bit (code_list#= <1>
+ it))))))))]
+
+ [/.single [] (list (` [])) (list (` (..dup 0 [])) (` (..dup 0 [])))]
+ [/.complete [] (list (` [])) (list (` []) (` []))]
+ [/.total (..dup 0 []) (list (` [])) (list (` []) (` []))]
+ ))
+ (_.coverage [/.one]
+ (and (<| static.expansion
+ (do meta.monad
+ [it (/.one (` (..dup 0 [])))]
+ (in (list (code.bit (code#= (` [])
+ it))))))
+ (<| static.expansion
+ (do meta.monad
+ [it (meta.try (/.one (` (..dup 1 []))))]
+ (in (list (code.bit (when it
+ {try.#Failure _}
+ true
+
+ {try.#Success _}
+ false))))))))
+ (_.coverage [/.log_single!]
+ (exec
+ (,, (/.log_single! "omit" (..dup 0 [])))
+ (,, (/.log_single! (..dup 0 [])))
+ true))
+ (_.coverage [/.log_complete!]
+ (exec
+ (,, (/.log_complete! "omit" (..dup 1 [])))
+ (,, (/.log_complete! (..dup 1 [])))
+ true))
+ (_.coverage [/.log_total!]
+ (exec
+ (,, (/.log_total! "omit" (..dup 1 (..dup 0 []))))
+ (,, (/.log_total! (..dup 1 (..dup 0 []))))
+ true))
+ ))))
diff --git a/stdlib/source/test/lux/world/time.lux b/stdlib/source/test/lux/world/time.lux
index 4ca58afca..68e6e478c 100644
--- a/stdlib/source/test/lux/world/time.lux
+++ b/stdlib/source/test/lux/world/time.lux
@@ -28,7 +28,8 @@
["[1][0]" duration]
["[1][0]" instant]
["[1][0]" month]
- ["[1][0]" year]]
+ ["[1][0]" year]
+ ["[1][0]" solar]]
[\\library
["[0]" / (.only)
["[0]" duration]]])
@@ -155,4 +156,5 @@
/instant.test
/month.test
/year.test
+ /solar.test
)))))
diff --git a/stdlib/source/test/lux/world/time/solar.lux b/stdlib/source/test/lux/world/time/solar.lux
new file mode 100644
index 000000000..f1da38370
--- /dev/null
+++ b/stdlib/source/test/lux/world/time/solar.lux
@@ -0,0 +1,61 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" order]
+ ["$[0]" codec]]]
+ [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
+ ["@" 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))))))
+ )))