aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2016-12-17 15:28:36 -0400
committerEduardo Julian2016-12-17 15:28:36 -0400
commita60af2d673ef6b3c7090e454a1edc59838f3540d (patch)
treeb30b2893426a606e93c7bca1ca5e91a3f2012c68 /stdlib/test
parente0c21be8ded9924bb0fde7ae5b7bd422d77a6b03 (diff)
- Added tests for lux/macro/poly/*
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/macro/poly/eq.lux66
-rw-r--r--stdlib/test/test/lux/macro/poly/functor.lux44
-rw-r--r--stdlib/test/test/lux/macro/poly/text-encoder.lux63
-rw-r--r--stdlib/test/tests.lux13
4 files changed, 178 insertions, 8 deletions
diff --git a/stdlib/test/test/lux/macro/poly/eq.lux b/stdlib/test/test/lux/macro/poly/eq.lux
new file mode 100644
index 000000000..983d2da69
--- /dev/null
+++ b/stdlib/test/test/lux/macro/poly/eq.lux
@@ -0,0 +1,66 @@
+## Copyright (c) Eduardo Julian. All rights reserved.
+## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+## If a copy of the MPL was not distributed with this file,
+## You can obtain one at http://mozilla.org/MPL/2.0/.
+
+(;module:
+ lux
+ (lux (codata [io])
+ (control monad
+ eq)
+ (data text/format
+ [bool]
+ [number "i/" Number<Int>]
+ [char]
+ [text])
+ (math ["R" random])
+ pipe
+ [macro]
+ (macro [poly #+ derived:]
+ ["&" poly/eq]))
+ lux/test)
+
+## [Utils]
+(type: Variant
+ (#Case0 Bool)
+ (#Case1 Int)
+ (#Case2 Real))
+
+(type: Record
+ {#unit Unit
+ #bool Bool
+ #int Int
+ #real Real
+ #char Char
+ #text Text
+ #maybe (Maybe Int)
+ #list (List Int)
+ #variant Variant
+ #tuple [Int Real Char]})
+
+(def: gen-record
+ (R;Random Record)
+ (do R;Monad<Random>
+ [size (:: @ map (n.% +2) R;nat)
+ #let [gen-int (|> R;int (:: @ map (|>. i/abs (i.% 1_000_000))))]]
+ ($_ R;seq
+ (:: @ wrap [])
+ R;bool
+ gen-int
+ R;real
+ R;char
+ (R;text size)
+ (R;maybe gen-int)
+ (R;list size gen-int)
+ ($_ R;alt R;bool gen-int R;real)
+ ($_ R;seq gen-int R;real R;char)
+ )))
+
+(derived: (&;Eq<?> Record))
+
+## [Tests]
+(test: "Eq polytypism"
+ [sample gen-record
+ #let [(^open "&/") Eq<Record>]]
+ (assert "Every instance equals itself."
+ (&/= sample sample)))
diff --git a/stdlib/test/test/lux/macro/poly/functor.lux b/stdlib/test/test/lux/macro/poly/functor.lux
new file mode 100644
index 000000000..c25f536e9
--- /dev/null
+++ b/stdlib/test/test/lux/macro/poly/functor.lux
@@ -0,0 +1,44 @@
+## Copyright (c) Eduardo Julian. All rights reserved.
+## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+## If a copy of the MPL was not distributed with this file,
+## You can obtain one at http://mozilla.org/MPL/2.0/.
+
+(;module:
+ lux
+ (lux (codata [io])
+ (control monad
+ [functor]
+ eq)
+ (data text/format
+ [bool]
+ [number "i/" Number<Int>]
+ [char]
+ [text])
+ (math ["R" random])
+ pipe
+ [macro]
+ (macro [poly #+ derived:]
+ ["&" poly/functor]))
+ lux/test)
+
+## [Utils]
+(type: (My-Maybe a)
+ #My-None
+ (#My-Some a))
+
+(type: (My-List a)
+ #My-Nil
+ (#My-Cons [a (My-List a)]))
+
+(type: (My-State s a)
+ (-> s [s a]))
+
+(derived: (&;Functor<?> My-Maybe))
+
+(derived: (&;Functor<?> My-List))
+
+(derived: (&;Functor<?> My-State))
+
+## [Tests]
+(test: "Functor polytypism"
+ (assert "" true))
diff --git a/stdlib/test/test/lux/macro/poly/text-encoder.lux b/stdlib/test/test/lux/macro/poly/text-encoder.lux
new file mode 100644
index 000000000..e106162a3
--- /dev/null
+++ b/stdlib/test/test/lux/macro/poly/text-encoder.lux
@@ -0,0 +1,63 @@
+## Copyright (c) Eduardo Julian. All rights reserved.
+## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+## If a copy of the MPL was not distributed with this file,
+## You can obtain one at http://mozilla.org/MPL/2.0/.
+
+(;module:
+ lux
+ (lux (codata [io])
+ (control monad
+ eq)
+ (data text/format
+ [bool]
+ [number "i/" Number<Int>]
+ [char]
+ [text])
+ (math ["R" random])
+ pipe
+ [macro]
+ (macro [poly #+ derived:]
+ ["&" poly/text-encoder]))
+ lux/test)
+
+## [Utils]
+(type: Variant
+ (#Case0 Bool)
+ (#Case1 Int)
+ (#Case2 Real))
+
+(type: Record
+ {#unit Unit
+ #bool Bool
+ #int Int
+ #real Real
+ #char Char
+ #text Text
+ #maybe (Maybe Int)
+ #list (List Int)
+ #variant Variant
+ #tuple [Int Real Char]})
+
+(def: gen-record
+ (R;Random Record)
+ (do R;Monad<Random>
+ [size (:: @ map (n.% +2) R;nat)
+ #let [gen-int (|> R;int (:: @ map (|>. i/abs (i.% 1_000_000))))]]
+ ($_ R;seq
+ (:: @ wrap [])
+ R;bool
+ gen-int
+ R;real
+ R;char
+ (R;text size)
+ (R;maybe gen-int)
+ (R;list size gen-int)
+ ($_ R;alt R;bool gen-int R;real)
+ ($_ R;seq gen-int R;real R;char)
+ )))
+
+(derived: (&;Codec<Text,?>::encode Record))
+
+## [Tests]
+(test: "Text-encoding polytypism"
+ (assert "" true))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index 85cce3d9f..ebb6c6999 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -26,7 +26,6 @@
[frp]
["_;" promise]
[stm])
-
(data [bit]
[bool]
[char]
@@ -60,18 +59,16 @@
## [macro]
(macro ["_;" ast]
["_;" syntax]
- ["_;" template])
+ ["_;" template]
+ (poly ["poly_;" eq]
+ ["poly_;" text-encoder]
+ ["poly_;" functor]))
["_;" type]
(type ["_;" check]
["_;" auto])
## (control [effect])
)
- )
- ## (lux (macro [poly]
- ## (poly ["poly_;" eq]
- ## ["poly_;" text-encoder]
- ## ["poly_;" functor])))
- )
+ ))
## [Program]
(program: args