aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorLuxLang2017-03-24 17:02:05 -0400
committerGitHub2017-03-24 17:02:05 -0400
commit67835905186803efa763b2c107ecadc835ebe0a6 (patch)
tree626b3240bf1c5131d630358efa57951f157daa2d /stdlib/test
parent7886f9da86c2b6d3da6ab801d07005d21686c275 (diff)
parent3ad92cceba0ebd2fa4b6ced5302d4a9290229e43 (diff)
Merge pull request #29 from LuxLang/js_port
Js port
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux.lux16
-rw-r--r--stdlib/test/test/lux/data/char.lux3
-rw-r--r--stdlib/test/test/lux/data/text.lux16
-rw-r--r--stdlib/test/test/lux/host.js.lux32
-rw-r--r--stdlib/test/test/lux/host.jvm.lux (renamed from stdlib/test/test/lux/host.lux)0
-rw-r--r--stdlib/test/test/lux/math.lux3
-rw-r--r--stdlib/test/test/lux/math/complex.lux16
7 files changed, 57 insertions, 29 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index 9516ae317..92ed5e2ca 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -115,10 +115,10 @@
(|> x' (/ y) (* y) (= x'))))
))]
- ["Nat" R;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id]
- ["Int" R;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id]
- ["Real" R;real r.= r.+ r.- r.* r./ r.% r.> 0.0 1.0 1000000.0 %r id math;floor]
- ["Deg" R;deg d.= d.+ d.- d.* d./ d.% d.> .0 (_lux_proc ["deg" "max-value"] []) (_lux_proc ["deg" "max-value"] []) %f id id]
+ ["Nat" R;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id]
+ ["Int" R;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id]
+ ["Real" R;real r.= r.+ r.- r.* r./ r.% r.> 0.0 1.0 1000000.0 %r id math;floor]
+ ["Deg" R;deg d.= d.+ d.- d.* d./ d.% d.> .0 (_lux_proc ["deg" "max-value"] []) (_lux_proc ["deg" "max-value"] []) %f id id]
)
(do-template [category rand-gen -> <- = <cap> %a %z]
@@ -128,10 +128,10 @@
(assert ""
(|> value -> <- (= value))))]
- ["Int->Nat" R;int int-to-nat nat-to-int i.= (i.% 1000000) %i %n]
- ["Nat->Int" R;nat nat-to-int int-to-nat n.= (n.% +1000000) %n %i]
- ["Int->Real" R;int int-to-real real-to-int i.= (i.% 1000000) %i %r]
- ["Real->Int" R;real real-to-int int-to-real r.= math;floor %r %i]
+ ["Int->Nat" R;int int-to-nat nat-to-int i.= (i.% 1000000) %i %n]
+ ["Nat->Int" R;nat nat-to-int int-to-nat n.= (n.% +1000000) %n %i]
+ ["Int->Real" R;int int-to-real real-to-int i.= (i.% 1000000) %i %r]
+ ["Real->Int" R;real real-to-int int-to-real r.= math;floor %r %i]
## [R;real real-to-deg deg-to-real r.= (r.% 1.0) %r %f]
)
diff --git a/stdlib/test/test/lux/data/char.lux b/stdlib/test/test/lux/data/char.lux
index 67332f282..88a5d86ae 100644
--- a/stdlib/test/test/lux/data/char.lux
+++ b/stdlib/test/test/lux/data/char.lux
@@ -6,8 +6,7 @@
[text]
text/format)
["R" random]
- pipe
- [host #- try])
+ pipe)
lux/test)
(test: "Char operations"
diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux
index fd847001e..883ff0b2b 100644
--- a/stdlib/test/test/lux/data/text.lux
+++ b/stdlib/test/test/lux/data/text.lux
@@ -32,10 +32,10 @@
(&;nth idx)
(case> (^=> (#;Some char)
[(char;as-text char) char']
- [[(&;index-of char' sample)
- (&;last-index-of char' sample)
- (&;index-of' char' idx sample)
- (&;last-index-of' char' idx sample)]
+ [[(&;index-of' char' sample)
+ (&;last-index-of' char' sample)
+ (&;index-of char' idx sample)
+ (&;last-index-of char' idx sample)]
[(#;Some io) (#;Some lio)
(#;Some io') (#;Some lio')]])
(and (n.<= idx io)
@@ -77,10 +77,10 @@
_
false))
- (|> [(&;sub +0 sizeL sample)
- (&;sub sizeL (&;size sample) sample)
- (&;sub' sizeL sample)
- (&;sub' +0 sample)]
+ (|> [(&;clip +0 sizeL sample)
+ (&;clip sizeL (&;size sample) sample)
+ (&;clip' sizeL sample)
+ (&;clip' +0 sample)]
(case> [(#;Right _l) (#;Right _r) (#;Right _r') (#;Right _f)]
(and (= sampleL _l)
(= sampleR _r)
diff --git a/stdlib/test/test/lux/host.js.lux b/stdlib/test/test/lux/host.js.lux
new file mode 100644
index 000000000..4c2b55485
--- /dev/null
+++ b/stdlib/test/test/lux/host.js.lux
@@ -0,0 +1,32 @@
+(;module:
+ lux
+ (lux [io]
+ (control monad)
+ (data text/format)
+ ["&" host]
+ ["R" random]
+ pipe)
+ lux/test)
+
+(test: "JavaScript operations"
+ ($_ seq
+ (assert "Null equals itself."
+ (is (&;null) (&;null)))
+
+ (assert "Undefined equals itself."
+ (is (&;undef) (&;undef)))
+
+ (assert "Can reference JavaScript objects."
+ (is (&;ref "Math") (&;ref "Math")))
+
+ (assert "Can create objects and access their fields."
+ (|> (&;object "foo" "BAR")
+ (&;get "foo" Text)
+ (is "BAR")))
+
+ (assert "Can call JavaScript functions"
+ (and (is 124.0
+ (&;call! (&;ref "Math.ceil" &;Function) [123.45] Real))
+ (is 124.0
+ (&;call! (&;ref "Math") "ceil" [123.45] Real))))
+ ))
diff --git a/stdlib/test/test/lux/host.lux b/stdlib/test/test/lux/host.jvm.lux
index 54e6cf4b9..54e6cf4b9 100644
--- a/stdlib/test/test/lux/host.lux
+++ b/stdlib/test/test/lux/host.jvm.lux
diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux
index 18cb1545c..769a6f889 100644
--- a/stdlib/test/test/lux/math.lux
+++ b/stdlib/test/test/lux/math.lux
@@ -35,9 +35,6 @@
## (assert "Tangent and arc-tangent are inverse functions."
## (|> angle &;tan &;atan (within? margin angle)))
-
-## (assert "Can freely go between degrees and radians."
-## (|> angle &;degrees &;radians (within? margin angle)))
## ))
(test: "Roots"
diff --git a/stdlib/test/test/lux/math/complex.lux b/stdlib/test/test/lux/math/complex.lux
index 04ebcb3c0..f965f9214 100644
--- a/stdlib/test/test/lux/math/complex.lux
+++ b/stdlib/test/test/lux/math/complex.lux
@@ -54,8 +54,8 @@
(r.= imaginary (get@ #&;imaginary r+i)))))
(assert "If either the real part or the imaginary part is NaN, the composite is NaN."
- (and (&;nan? (&;complex number;nan imaginary))
- (&;nan? (&;complex real number;nan))))
+ (and (&;not-a-number? (&;complex number;not-a-number imaginary))
+ (&;not-a-number? (&;complex real number;not-a-number))))
))
(test: "Absolute value"
@@ -69,14 +69,14 @@
(r.>= (r/abs imaginary) abs))))
(assert "The absolute value of a complex number involving a NaN on either dimension, results in a NaN value."
- (and (number;nan? (get@ #&;real (&;c.abs (&;complex number;nan imaginary))))
- (number;nan? (get@ #&;real (&;c.abs (&;complex real number;nan))))))
+ (and (number;not-a-number? (get@ #&;real (&;c.abs (&;complex number;not-a-number imaginary))))
+ (number;not-a-number? (get@ #&;real (&;c.abs (&;complex real number;not-a-number))))))
(assert "The absolute value of a complex number involving an infinity on either dimension, results in an infinite value."
- (and (r.= number;+inf (get@ #&;real (&;c.abs (&;complex number;+inf imaginary))))
- (r.= number;+inf (get@ #&;real (&;c.abs (&;complex real number;+inf))))
- (r.= number;+inf (get@ #&;real (&;c.abs (&;complex number;-inf imaginary))))
- (r.= number;+inf (get@ #&;real (&;c.abs (&;complex real number;-inf))))))
+ (and (r.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;positive-infinity imaginary))))
+ (r.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;positive-infinity))))
+ (r.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex number;negative-infinity imaginary))))
+ (r.= number;positive-infinity (get@ #&;real (&;c.abs (&;complex real number;negative-infinity))))))
))
(test: "Addidion, substraction, multiplication and division"