diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/data.lux | 6 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/number/i16.lux | 39 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/number/i32.lux | 39 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/number/i64.lux | 8 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/number/i8.lux | 39 |
5 files changed, 129 insertions, 2 deletions
diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index 4b0f02903..116a4c890 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -12,6 +12,9 @@ ["#." product] ["#." sum] [number + ["#." i8] + ["#." i16] + ["#." i32] ["#." i64] ["#." nat] ["#." int] @@ -29,6 +32,9 @@ (def: number Test ($_ _.and + /i8.test + /i16.test + /i32.test /i64.test /nat.test /int.test diff --git a/stdlib/source/test/lux/data/number/i16.lux b/stdlib/source/test/lux/data/number/i16.lux new file mode 100644 index 000000000..d44ce68f0 --- /dev/null +++ b/stdlib/source/test/lux/data/number/i16.lux @@ -0,0 +1,39 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [data + ["." name] + ["%" text/format (#+ format)]] + [abstract + [monad (#+ do)] + {[0 #test] + [/ + ["$." equivalence]]}] + [math + ["r" random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["#." i64 (#+ Mask)]]]}) + +(def: #export i16 + (Random /.I16) + (:: r.functor map /.i16 r.i64)) + +(def: mask + Mask + (//i64.or //i64.sign + (//i64.mask 15))) + +(def: #export test + Test + (<| (_.context (name.module (name-of /._))) + (do r.monad + [expected (:: @ map (|>> (//i64.and ..mask) (: I64)) r.i64)] + ($_ _.and + ($equivalence.spec /.equivalence ..i16) + + (_.test "Can convert between I64 and I16" + (let [actual (|> expected /.i16 /.i64)] + (:: //i64.equivalence = expected actual))) + )))) diff --git a/stdlib/source/test/lux/data/number/i32.lux b/stdlib/source/test/lux/data/number/i32.lux new file mode 100644 index 000000000..ae7e0ae41 --- /dev/null +++ b/stdlib/source/test/lux/data/number/i32.lux @@ -0,0 +1,39 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [data + ["." name] + ["%" text/format (#+ format)]] + [abstract + [monad (#+ do)] + {[0 #test] + [/ + ["$." equivalence]]}] + [math + ["r" random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["#." i64 (#+ Mask)]]]}) + +(def: #export i32 + (Random /.I32) + (:: r.functor map /.i32 r.i64)) + +(def: mask + Mask + (//i64.or //i64.sign + (//i64.mask 31))) + +(def: #export test + Test + (<| (_.context (name.module (name-of /._))) + (do r.monad + [expected (:: @ map (|>> (//i64.and ..mask) (: I64)) r.i64)] + ($_ _.and + ($equivalence.spec /.equivalence ..i32) + + (_.test "Can convert between I64 and I32" + (let [actual (|> expected /.i32 /.i64)] + (:: //i64.equivalence = expected actual))) + )))) diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux index c4124669b..fd4b3adeb 100644 --- a/stdlib/source/test/lux/data/number/i64.lux +++ b/stdlib/source/test/lux/data/number/i64.lux @@ -1,11 +1,14 @@ (.module: [lux #* - ["%" data/text/format (#+ format)] ["_" test (#+ Test)] + [data + ["." name] + ["%" text/format (#+ format)]] [abstract [monad (#+ do)] {[0 #test] [/ + ["$." equivalence] ["$." monoid]]}] [math ["r" random]]] @@ -16,11 +19,12 @@ (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (name.module (name-of /._))) (do r.monad [pattern r.nat idx (:: @ map (n/% /.width) r.nat)] ($_ _.and + ($equivalence.spec /.equivalence r.i64) ($monoid.spec //nat.equivalence /.disjunction r.nat) ($monoid.spec //nat.equivalence /.conjunction r.nat) diff --git a/stdlib/source/test/lux/data/number/i8.lux b/stdlib/source/test/lux/data/number/i8.lux new file mode 100644 index 000000000..dc4b799fe --- /dev/null +++ b/stdlib/source/test/lux/data/number/i8.lux @@ -0,0 +1,39 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [data + ["." name] + ["%" text/format (#+ format)]] + [abstract + [monad (#+ do)] + {[0 #test] + [/ + ["$." equivalence]]}] + [math + ["r" random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["#." i64 (#+ Mask)]]]}) + +(def: #export i8 + (Random /.I8) + (:: r.functor map /.i8 r.i64)) + +(def: mask + Mask + (//i64.or //i64.sign + (//i64.mask 7))) + +(def: #export test + Test + (<| (_.context (name.module (name-of /._))) + (do r.monad + [expected (:: @ map (|>> (//i64.and ..mask) (: I64)) r.i64)] + ($_ _.and + ($equivalence.spec /.equivalence ..i8) + + (_.test "Can convert between I64 and I8" + (let [actual (|> expected /.i8 /.i64)] + (:: //i64.equivalence = expected actual))) + )))) |