aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test/test/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2016-12-01 15:12:42 -0400
committerEduardo Julian2016-12-01 15:12:42 -0400
commita699799f30d438711ae80a0fa6388de6ada2432c (patch)
treef50f15db45c5926101460f7aee59d1e16d46fd6a /stdlib/test/test/lux.lux
parent7f66c54f4c9753b94dbf46ec50b8b16549daf324 (diff)
- Simplified the Test type.
- Added Test combinators. - Removed unnecessary testing macros (testing only needs assertions).
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux.lux77
1 files changed, 43 insertions, 34 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index 947ec5b6f..f507e1e9a 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -14,15 +14,18 @@
[compiler]
(macro ["s" syntax #+ syntax:])))
-(test: "Every value is identical to itself, and the 'id' function doesn't change values in any way."
- [value R;int]
- (assert "" (and (== value value)
- (== value (id value)))))
-
-(test: "Values created separately can't be identical."
- [x R;int
- y R;int]
- (match false (== x y)))
+(test: "Value identity."
+ [size (|> R;nat (:: @ map (|>. (%+ +100) (max+ +10))))
+ x (R;text size)
+ y (R;text size)]
+ ($_ seq
+ (assert "Every value is identical to itself, and the 'id' function doesn't change values in any way."
+ (and (== x x)
+ (== x (id x))))
+
+ (assert "Values created separately can't be identical."
+ (not (== x y)))
+ ))
(do-template [category rand-gen inc dec even? odd? = < >]
[(test: (format "[" category "] " "Moving up-down or down-up should result in same value.")
@@ -137,28 +140,34 @@
)
(test: "Simple macros and constructs"
- (all (match ["lux" "yolo"] (ident-for ;yolo))
- (match ["test/lux" "yolo"] (ident-for ;;yolo))
- (match ["" "yolo"] (ident-for yolo))
- (match ["lux/test" "yolo"] (ident-for lux/test;yolo))
- (match ["lux" "yolo"] (ident-for #;yolo))
- (match ["test/lux" "yolo"] (ident-for #;;yolo))
- (match ["" "yolo"] (ident-for #yolo))
- (match ["lux/test" "yolo"] (ident-for #lux/test;yolo))
-
- (match 1000 (loop [counter 0
- value 1]
- (if (< 3 counter)
- (recur (inc counter) (* 10 value))
- value)))
-
- (match (^ (list 1 2 3))
- (list 1 2 3))
- (match (^ (list 1 2 3 4 5 6))
- (list& 1 2 3 (list 4 5 6)))
-
- (match "yolo" (default "yolo"
- #;None))
- (match "lol" (default "yolo"
- (#;Some "lol")))
- ))
+ ($_ seq
+ (assert "Can write easy loops for iterative programming."
+ (= 1000
+ (loop [counter 0
+ value 1]
+ (if (< 3 counter)
+ (recur (inc counter) (* 10 value))
+ value))))
+
+ (assert "Can create lists easily through macros."
+ (and (case (list 1 2 3)
+ (#;Cons 1 (#;Cons 2 (#;Cons 3 #;Nil)))
+ true
+
+ _
+ false)
+
+ (case (list& 1 2 3 (list 4 5 6))
+ (#;Cons 1 (#;Cons 2 (#;Cons 3 (#;Cons 4 (#;Cons 5 (#;Cons 6 #;Nil))))))
+ true
+
+ _
+ false)))
+
+ (assert "Can have defaults for Maybe values."
+ (and (== "yolo" (default "yolo"
+ #;None))
+
+ (== "lol" (default "yolo"
+ (#;Some "lol")))))
+ ))