diff options
author | Eduardo Julian | 2017-10-04 22:02:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-04 22:02:41 -0400 |
commit | 29228f5c601d8d5d42aa5352566a609bf4259d11 (patch) | |
tree | 4bd9ee826f07c131e921eaf8e31d9efe309b9c6f /new-luxc/test/test/luxc/analyser | |
parent | 36b89b978e8bc6f084e67a11207488ea2fe25c72 (diff) |
- WIP: JVM host procedure analysis.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/test/test/luxc/analyser/procedure/common.lux | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/new-luxc/test/test/luxc/analyser/procedure/common.lux b/new-luxc/test/test/luxc/analyser/procedure/common.lux index 3947a738e..5e834746a 100644 --- a/new-luxc/test/test/luxc/analyser/procedure/common.lux +++ b/new-luxc/test/test/luxc/analyser/procedure/common.lux @@ -60,19 +60,19 @@ paramC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can count the number of 1 bits in a bit pattern." - (check-success+ "bit count" (list subjectC) Nat)) + (check-success+ "lux bit count" (list subjectC) Nat)) (test "Can perform bit 'and'." - (check-success+ "bit and" (list subjectC paramC) Nat)) + (check-success+ "lux bit and" (list subjectC paramC) Nat)) (test "Can perform bit 'or'." - (check-success+ "bit or" (list subjectC paramC) Nat)) + (check-success+ "lux bit or" (list subjectC paramC) Nat)) (test "Can perform bit 'xor'." - (check-success+ "bit xor" (list subjectC paramC) Nat)) + (check-success+ "lux bit xor" (list subjectC paramC) Nat)) (test "Can shift bit pattern to the left." - (check-success+ "bit shift-left" (list subjectC paramC) Nat)) + (check-success+ "lux bit shift-left" (list subjectC paramC) Nat)) (test "Can shift bit pattern to the right." - (check-success+ "bit unsigned-shift-right" (list subjectC paramC) Nat)) + (check-success+ "lux bit unsigned-shift-right" (list subjectC paramC) Nat)) (test "Can shift signed bit pattern to the right." - (check-success+ "bit shift-right" (list signedC paramC) Int)) + (check-success+ "lux bit shift-right" (list signedC paramC) Int)) )) (context: "Nat procedures" @@ -80,27 +80,27 @@ paramC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can add natural numbers." - (check-success+ "nat +" (list subjectC paramC) Nat)) + (check-success+ "lux nat +" (list subjectC paramC) Nat)) (test "Can subtract natural numbers." - (check-success+ "nat -" (list subjectC paramC) Nat)) + (check-success+ "lux nat -" (list subjectC paramC) Nat)) (test "Can multiply natural numbers." - (check-success+ "nat *" (list subjectC paramC) Nat)) + (check-success+ "lux nat *" (list subjectC paramC) Nat)) (test "Can divide natural numbers." - (check-success+ "nat /" (list subjectC paramC) Nat)) + (check-success+ "lux nat /" (list subjectC paramC) Nat)) (test "Can calculate remainder of natural numbers." - (check-success+ "nat %" (list subjectC paramC) Nat)) + (check-success+ "lux nat %" (list subjectC paramC) Nat)) (test "Can test equality of natural numbers." - (check-success+ "nat =" (list subjectC paramC) Bool)) + (check-success+ "lux nat =" (list subjectC paramC) Bool)) (test "Can compare natural numbers." - (check-success+ "nat <" (list subjectC paramC) Bool)) + (check-success+ "lux nat <" (list subjectC paramC) Bool)) (test "Can obtain minimum natural number." - (check-success+ "nat min" (list) Nat)) + (check-success+ "lux nat min" (list) Nat)) (test "Can obtain maximum natural number." - (check-success+ "nat max" (list) Nat)) + (check-success+ "lux nat max" (list) Nat)) (test "Can convert natural number to integer." - (check-success+ "nat to-int" (list subjectC) Int)) + (check-success+ "lux nat to-int" (list subjectC) Int)) (test "Can convert natural number to text." - (check-success+ "nat to-text" (list subjectC) Text)) + (check-success+ "lux nat to-text" (list subjectC) Text)) )) (context: "Int procedures" @@ -108,27 +108,27 @@ paramC (|> r;int (:: @ map code;int))] ($_ seq (test "Can add integers." - (check-success+ "int +" (list subjectC paramC) Int)) + (check-success+ "lux int +" (list subjectC paramC) Int)) (test "Can subtract integers." - (check-success+ "int -" (list subjectC paramC) Int)) + (check-success+ "lux int -" (list subjectC paramC) Int)) (test "Can multiply integers." - (check-success+ "int *" (list subjectC paramC) Int)) + (check-success+ "lux int *" (list subjectC paramC) Int)) (test "Can divide integers." - (check-success+ "int /" (list subjectC paramC) Int)) + (check-success+ "lux int /" (list subjectC paramC) Int)) (test "Can calculate remainder of integers." - (check-success+ "int %" (list subjectC paramC) Int)) + (check-success+ "lux int %" (list subjectC paramC) Int)) (test "Can test equality of integers." - (check-success+ "int =" (list subjectC paramC) Bool)) + (check-success+ "lux int =" (list subjectC paramC) Bool)) (test "Can compare integers." - (check-success+ "int <" (list subjectC paramC) Bool)) + (check-success+ "lux int <" (list subjectC paramC) Bool)) (test "Can obtain minimum integer." - (check-success+ "int min" (list) Int)) + (check-success+ "lux int min" (list) Int)) (test "Can obtain maximum integer." - (check-success+ "int max" (list) Int)) + (check-success+ "lux int max" (list) Int)) (test "Can convert integer to natural number." - (check-success+ "int to-nat" (list subjectC) Nat)) + (check-success+ "lux int to-nat" (list subjectC) Nat)) (test "Can convert integer to frac number." - (check-success+ "int to-frac" (list subjectC) Frac)) + (check-success+ "lux int to-frac" (list subjectC) Frac)) )) (context: "Deg procedures" @@ -137,29 +137,29 @@ natC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can add degrees." - (check-success+ "deg +" (list subjectC paramC) Deg)) + (check-success+ "lux deg +" (list subjectC paramC) Deg)) (test "Can subtract degrees." - (check-success+ "deg -" (list subjectC paramC) Deg)) + (check-success+ "lux deg -" (list subjectC paramC) Deg)) (test "Can multiply degrees." - (check-success+ "deg *" (list subjectC paramC) Deg)) + (check-success+ "lux deg *" (list subjectC paramC) Deg)) (test "Can divide degrees." - (check-success+ "deg /" (list subjectC paramC) Deg)) + (check-success+ "lux deg /" (list subjectC paramC) Deg)) (test "Can calculate remainder of degrees." - (check-success+ "deg %" (list subjectC paramC) Deg)) + (check-success+ "lux deg %" (list subjectC paramC) Deg)) (test "Can test equality of degrees." - (check-success+ "deg =" (list subjectC paramC) Bool)) + (check-success+ "lux deg =" (list subjectC paramC) Bool)) (test "Can compare degrees." - (check-success+ "deg <" (list subjectC paramC) Bool)) + (check-success+ "lux deg <" (list subjectC paramC) Bool)) (test "Can obtain minimum degree." - (check-success+ "deg min" (list) Deg)) + (check-success+ "lux deg min" (list) Deg)) (test "Can obtain maximum degree." - (check-success+ "deg max" (list) Deg)) + (check-success+ "lux deg max" (list) Deg)) (test "Can convert degree to frac number." - (check-success+ "deg to-frac" (list subjectC) Frac)) + (check-success+ "lux deg to-frac" (list subjectC) Frac)) (test "Can scale degree." - (check-success+ "deg scale" (list subjectC natC) Deg)) + (check-success+ "lux deg scale" (list subjectC natC) Deg)) (test "Can calculate the reciprocal of a natural number." - (check-success+ "deg reciprocal" (list natC) Deg)) + (check-success+ "lux deg reciprocal" (list natC) Deg)) )) (context: "Frac procedures" @@ -168,39 +168,39 @@ encodedC (|> (r;text +5) (:: @ map code;text))] ($_ seq (test "Can add frac numbers." - (check-success+ "frac +" (list subjectC paramC) Frac)) + (check-success+ "lux frac +" (list subjectC paramC) Frac)) (test "Can subtract frac numbers." - (check-success+ "frac -" (list subjectC paramC) Frac)) + (check-success+ "lux frac -" (list subjectC paramC) Frac)) (test "Can multiply frac numbers." - (check-success+ "frac *" (list subjectC paramC) Frac)) + (check-success+ "lux frac *" (list subjectC paramC) Frac)) (test "Can divide frac numbers." - (check-success+ "frac /" (list subjectC paramC) Frac)) + (check-success+ "lux frac /" (list subjectC paramC) Frac)) (test "Can calculate remainder of frac numbers." - (check-success+ "frac %" (list subjectC paramC) Frac)) + (check-success+ "lux frac %" (list subjectC paramC) Frac)) (test "Can test equality of frac numbers." - (check-success+ "frac =" (list subjectC paramC) Bool)) + (check-success+ "lux frac =" (list subjectC paramC) Bool)) (test "Can compare frac numbers." - (check-success+ "frac <" (list subjectC paramC) Bool)) + (check-success+ "lux frac <" (list subjectC paramC) Bool)) (test "Can obtain minimum frac number." - (check-success+ "frac min" (list) Frac)) + (check-success+ "lux frac min" (list) Frac)) (test "Can obtain maximum frac number." - (check-success+ "frac max" (list) Frac)) + (check-success+ "lux frac max" (list) Frac)) (test "Can obtain smallest frac number." - (check-success+ "frac smallest" (list) Frac)) + (check-success+ "lux frac smallest" (list) Frac)) (test "Can obtain not-a-number." - (check-success+ "frac not-a-number" (list) Frac)) + (check-success+ "lux frac not-a-number" (list) Frac)) (test "Can obtain positive infinity." - (check-success+ "frac positive-infinity" (list) Frac)) + (check-success+ "lux frac positive-infinity" (list) Frac)) (test "Can obtain negative infinity." - (check-success+ "frac negative-infinity" (list) Frac)) + (check-success+ "lux frac negative-infinity" (list) Frac)) (test "Can convert frac number to integer." - (check-success+ "frac to-int" (list subjectC) Int)) + (check-success+ "lux frac to-int" (list subjectC) Int)) (test "Can convert frac number to degree." - (check-success+ "frac to-deg" (list subjectC) Deg)) + (check-success+ "lux frac to-deg" (list subjectC) Deg)) (test "Can convert frac number to text." - (check-success+ "frac encode" (list subjectC) Text)) + (check-success+ "lux frac encode" (list subjectC) Text)) (test "Can convert text to frac number." - (check-success+ "frac encode" (list encodedC) (type (Maybe Frac)))) + (check-success+ "lux frac encode" (list encodedC) (type (Maybe Frac)))) )) (context: "Text procedures" @@ -211,25 +211,25 @@ toC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can test text equality." - (check-success+ "text =" (list subjectC paramC) Bool)) + (check-success+ "lux text =" (list subjectC paramC) Bool)) (test "Compare texts in lexicographical order." - (check-success+ "text <" (list subjectC paramC) Bool)) + (check-success+ "lux text <" (list subjectC paramC) Bool)) (test "Can prepend one text to another." - (check-success+ "text prepend" (list subjectC paramC) Text)) + (check-success+ "lux text prepend" (list subjectC paramC) Text)) (test "Can find the index of a piece of text inside a larger one that (may) contain it." - (check-success+ "text index" (list subjectC paramC fromC) (type (Maybe Nat)))) + (check-success+ "lux text index" (list subjectC paramC fromC) (type (Maybe Nat)))) (test "Can query the size/length of a text." - (check-success+ "text size" (list subjectC) Nat)) + (check-success+ "lux text size" (list subjectC) Nat)) (test "Can calculate a hash code for text." - (check-success+ "text hash" (list subjectC) Nat)) + (check-success+ "lux text hash" (list subjectC) Nat)) (test "Can replace a text inside of a larger one (once)." - (check-success+ "text replace-once" (list subjectC paramC replacementC) Text)) + (check-success+ "lux text replace-once" (list subjectC paramC replacementC) Text)) (test "Can replace a text inside of a larger one (all times)." - (check-success+ "text replace-all" (list subjectC paramC replacementC) Text)) + (check-success+ "lux text replace-all" (list subjectC paramC replacementC) Text)) (test "Can obtain the character code of a text at a given index." - (check-success+ "text char" (list subjectC fromC) Nat)) + (check-success+ "lux text char" (list subjectC fromC) Nat)) (test "Can clip a piece of text between 2 indices." - (check-success+ "text clip" (list subjectC fromC toC) Text)) + (check-success+ "lux text clip" (list subjectC fromC toC) Text)) )) (context: "Array procedures" @@ -240,12 +240,12 @@ #let [arrayT (type (array;Array elemT))]] ($_ seq (test "Can create arrays." - (check-success+ "array new" (list sizeC) arrayT)) + (check-success+ "lux array new" (list sizeC) arrayT)) (test "Can get a value inside an array." (|> (&scope;with-scope "" (&scope;with-local [var-name arrayT] (&;with-expected-type elemT - (@;analyse-procedure analyse "array get" + (@;analyse-procedure analyse "lux array get" (list idxC (code;symbol ["" var-name])))))) (macro;run (init-compiler [])) @@ -258,7 +258,7 @@ (|> (&scope;with-scope "" (&scope;with-local [var-name arrayT] (&;with-expected-type arrayT - (@;analyse-procedure analyse "array put" + (@;analyse-procedure analyse "lux array put" (list idxC elemC (code;symbol ["" var-name])))))) @@ -272,7 +272,7 @@ (|> (&scope;with-scope "" (&scope;with-local [var-name arrayT] (&;with-expected-type arrayT - (@;analyse-procedure analyse "array remove" + (@;analyse-procedure analyse "lux array remove" (list idxC (code;symbol ["" var-name])))))) (macro;run (init-compiler [])) @@ -285,7 +285,7 @@ (|> (&scope;with-scope "" (&scope;with-local [var-name arrayT] (&;with-expected-type Nat - (@;analyse-procedure analyse "array size" + (@;analyse-procedure analyse "lux array size" (list (code;symbol ["" var-name])))))) (macro;run (init-compiler [])) (case> (#R;Success _) @@ -302,28 +302,28 @@ [(test (format "Can calculate " <desc> ".") (check-success+ <proc> (list subjectC) Frac))] - ["math cos" "cosine"] - ["math sin" "sine"] - ["math tan" "tangent"] - ["math acos" "inverse/arc cosine"] - ["math asin" "inverse/arc sine"] - ["math atan" "inverse/arc tangent"] - ["math cosh" "hyperbolic cosine"] - ["math sinh" "hyperbolic sine"] - ["math tanh" "hyperbolic tangent"] - ["math exp" "exponentiation"] - ["math log" "logarithm"] - ["math root2" "square root"] - ["math root3" "cubic root"] - ["math ceil" "ceiling"] - ["math floor" "floor"] - ["math round" "rounding"]) + ["lux math cos" "cosine"] + ["lux math sin" "sine"] + ["lux math tan" "tangent"] + ["lux math acos" "inverse/arc cosine"] + ["lux math asin" "inverse/arc sine"] + ["lux math atan" "inverse/arc tangent"] + ["lux math cosh" "hyperbolic cosine"] + ["lux math sinh" "hyperbolic sine"] + ["lux math tanh" "hyperbolic tangent"] + ["lux math exp" "exponentiation"] + ["lux math log" "logarithm"] + ["lux math root2" "square root"] + ["lux math root3" "cubic root"] + ["lux math ceil" "ceiling"] + ["lux math floor" "floor"] + ["lux math round" "rounding"]) <binary> (do-template [<proc> <desc>] [(test (format "Can calculate " <desc> ".") (check-success+ <proc> (list subjectC paramC) Frac))] - ["math atan2" "inverse/arc tangent (with 2 arguments)"] - ["math pow" "power"])] + ["lux math atan2" "inverse/arc tangent (with 2 arguments)"] + ["lux math pow" "power"])] ($_ seq <unary> <binary>))) @@ -336,12 +336,12 @@ #let [atomT (type (atom;Atom elemT))]] ($_ seq (test "Can create atomic reference." - (check-success+ "atom new" (list elemC) atomT)) + (check-success+ "lux atom new" (list elemC) atomT)) (test "Can read the value of an atomic reference." (|> (&scope;with-scope "" (&scope;with-local [var-name atomT] (&;with-expected-type elemT - (@;analyse-procedure analyse "atom read" + (@;analyse-procedure analyse "lux atom read" (list (code;symbol ["" var-name])))))) (macro;run (init-compiler [])) (case> (#R;Success _) @@ -353,7 +353,7 @@ (|> (&scope;with-scope "" (&scope;with-local [var-name atomT] (&;with-expected-type Bool - (@;analyse-procedure analyse "atom compare-and-swap" + (@;analyse-procedure analyse "lux atom compare-and-swap" (list elemC elemC (code;symbol ["" var-name])))))) @@ -370,13 +370,13 @@ timeC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can query the level of concurrency." - (check-success+ "process concurrency-level" (list) Nat)) + (check-success+ "lux process concurrency-level" (list) Nat)) (test "Can run an IO computation concurrently." - (check-success+ "process future" + (check-success+ "lux process future" (list (` ((~' _lux_function) (~' _) (~' _) (~ primC)))) Unit)) (test "Can schedule an IO computation to run concurrently at some future time." - (check-success+ "process schedule" + (check-success+ "lux process schedule" (list timeC (` ((~' _lux_function) (~' _) (~' _) (~ primC)))) Unit)) @@ -387,11 +387,11 @@ exitC (|> r;nat (:: @ map code;nat))] ($_ seq (test "Can log messages to standard output." - (check-success+ "io log" (list logC) Unit)) + (check-success+ "lux io log" (list logC) Unit)) (test "Can log messages to standard output." - (check-success+ "io error" (list logC) Bottom)) + (check-success+ "lux io error" (list logC) Bottom)) (test "Can log messages to standard output." - (check-success+ "io exit" (list exitC) Bottom)) + (check-success+ "lux io exit" (list exitC) Bottom)) (test "Can query the current time (as milliseconds since epoch)." - (check-success+ "io current-time" (list) Int)) + (check-success+ "lux io current-time" (list) Int)) )) |