aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/data/sum.lux53
-rw-r--r--stdlib/source/test/lux/target/python.lux33
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux14
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux41
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux (renamed from stdlib/source/test/lux/tool/compiler/language/lux/synthesis/side.lux)4
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/cache/module.lux12
7 files changed, 119 insertions, 42 deletions
diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux
index 73ffe0e21..2aa3c5058 100644
--- a/stdlib/source/test/lux/data/sum.lux
+++ b/stdlib/source/test/lux/data/sum.lux
@@ -1,24 +1,25 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]
- [\\specification
- ["$[0]" equivalence]]]
- [control
- pipe]
- [data
- ["[0]" text]
- [collection
- ["[0]" list ("[1]#[0]" functor)]]]
- [math
- ["[0]" random]
- [number
- ["n" nat]
- ["i" int]]]]]
- [\\library
- ["[0]" /]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [control
+ pipe]
+ [data
+ ["[0]" text]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]
+ ["i" int]]]]]
+ [\\library
+ ["[0]" /]])
(def: .public test
Test
@@ -31,15 +32,9 @@
(_.for [/.equivalence]
($equivalence.spec (/.equivalence n.equivalence n.equivalence)
(random.or random.nat random.nat)))
- (do random.monad
- [left random.int
- right random.nat]
- (_.cover [/.hash]
- (let [hash (/.hash i.hash n.hash)]
- (and (n.= (# i.hash hash left)
- (# hash hash {.#Left left}))
- (n.= (# n.hash hash right)
- (# hash hash {.#Right right}))))))
+ (_.for [/.hash]
+ ($hash.spec (/.hash n.hash n.hash)
+ (random.or random.nat random.nat)))
(_.cover [/.left]
(|> (/.left expected)
diff --git a/stdlib/source/test/lux/target/python.lux b/stdlib/source/test/lux/target/python.lux
index b09be8b72..cb9a3551c 100644
--- a/stdlib/source/test/lux/target/python.lux
+++ b/stdlib/source/test/lux/target/python.lux
@@ -141,6 +141,13 @@
(/.repr/1 (/.float subject))))
))))
+(def: python_3?
+ (/.Expression Any)
+ (|> (/.__import__/1 (/.unicode "sys"))
+ (/.the "version_info")
+ (/.the "major")
+ (/.= (/.int +3))))
+
(def: int/16
(-> Int Int)
(i64.and (-- (i64.left_shifted 15 1))))
@@ -164,6 +171,16 @@
[/.bit_xor i64.xor]
[/.bit_and i64.and]
))
+ (~~ (template [</> <lux>]
+ [(_.cover [</>]
+ (let [left (.int shift)
+ right (i.* (.int shift) i16)
+ expected (<lux> left right)]
+ (expression (|>> (:as Int) (i.= expected))
+ (</> (/.int left) (/.int right)))))]
+
+ [/.// i./]
+ ))
(_.cover [/.opposite]
(expression (|>> (:as Int) (i.= (i.* -1 left)))
(/.opposite (/.int left))))
@@ -183,6 +200,11 @@
(_.cover [/.str/1]
(expression (|>> (:as Text) (text#= (text.replaced "+" "" (%.int left))))
(/.str/1 (/.int left))))
+ (_.cover [/.long]
+ (or (expression (|>> (:as Bit))
+ ..python_3?)
+ (expression (|>> (:as Int) (i.= left))
+ (/.long left))))
))))
(def: test|text
@@ -191,11 +213,16 @@
[expected_code (# ! each (n.% 128) random.nat)
.let [expected_char (text.of_char expected_code)]]
($_ _.and
- (_.cover [/.chr/1 /.ord/1]
+ (_.cover [/.chr/1 /.ord/1
+ /.unichr/1 /.unicode/1]
(and (expression (|>> (:as Int) .nat (n.= expected_code))
- (/.ord/1 (/.chr/1 (/.int (.int expected_code)))))
+ (/.? python_3?
+ (/.ord/1 (/.chr/1 (/.int (.int expected_code))))
+ (/.unicode/1 (/.unichr/1 (/.int (.int expected_code))))))
(expression (|>> (:as Text) (text#= expected_char))
- (/.chr/1 (/.ord/1 (/.string expected_char))))))
+ (/.? python_3?
+ (/.chr/1 (/.ord/1 (/.string expected_char)))
+ (/.unichr/1 (/.unicode/1 (/.string expected_char)))))))
)))
(def: test|array
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 1009e3239..d21012a13 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -14,7 +14,7 @@
["[1][0]" analysis]
["[1][0]" synthesis "_"
["[1]/[0]" simple]
- ["[1]/[0]" side]]
+ ["[1]/[0]" access]]
["[1][0]" phase "_"
["[1]/[0]" extension]
["[1]/[0]" analysis]
@@ -38,7 +38,7 @@
/phase.test
/analysis.test
/synthesis/simple.test
- /synthesis/side.test
+ /synthesis/access.test
/meta/archive.test
/meta/cli.test
/meta/export.test
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux
new file mode 100644
index 000000000..cb6859350
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux
@@ -0,0 +1,14 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]]]
+ ["[0]" / "_"
+ ["[1][0]" side]
+ ["[1][0]" member]])
+
+(def: .public test
+ Test
+ ($_ _.and
+ /side.test
+ /member.test
+ ))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux
new file mode 100644
index 000000000..db4f15bfa
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux
@@ -0,0 +1,41 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random {"+" Random}]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: .public random
+ (Random /.Member)
+ ($_ random.and
+ random.nat
+ random.bit
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Member])
+ (do [! random.monad]
+ [left ..random
+ right ..random]
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
+ (_.cover [/.format]
+ (bit#= (# /.equivalence = left right)
+ (text#= (/.format left) (/.format right))))
+ ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/side.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux
index 3dccec159..adc2b142d 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/side.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux
@@ -11,9 +11,7 @@
["[0]" bit ("[1]#[0]" equivalence)]
["[0]" text ("[1]#[0]" equivalence)]]
[math
- ["[0]" random {"+" Random}]
- [number
- ["n" nat]]]]]
+ ["[0]" random {"+" Random}]]]]
[\\library
["[0]" /]])
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
index b73f420aa..841167110 100644
--- a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
+++ b/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux
@@ -49,13 +49,13 @@
Test
(<| (_.covering /._)
(do [! random.monad]
- [.let [/ "/"
- fs (file.mock /)]
- context $///context.random
+ [context $///context.random
@module random.nat]
($_ _.and
(in (do [! async.monad]
- [pre/0 (# fs directory? (/.path fs context @module))
+ [.let [/ "/"
+ fs (file.mock /)]
+ pre/0 (# fs directory? (/.path fs context @module))
pre/1 (/.enabled? fs context @module)
outcome (/.enable! ! fs context @module)
post/0 (# fs directory? (/.path fs context @module))
@@ -71,7 +71,9 @@
post/0
post/1))))
(in (do [! async.monad]
- [pre/0 (# fs directory? (/.path fs context @module))
+ [.let [/ "/"
+ fs (file.mock /)]
+ pre/0 (# fs directory? (/.path fs context @module))
pre/1 (/.enabled? fs context @module)
outcome (/.enable! ! (..bad fs) context @module)
post/0 (# fs directory? (/.path fs context @module))