diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/case.lux | 92 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/primitive.lux | 79 | ||||
-rw-r--r-- | new-luxc/test/test/luxc/lang/translation/reference.lux | 74 |
3 files changed, 107 insertions, 138 deletions
diff --git a/new-luxc/test/test/luxc/lang/translation/case.lux b/new-luxc/test/test/luxc/lang/translation/case.lux index 44df51014..f7df17c42 100644 --- a/new-luxc/test/test/luxc/lang/translation/case.lux +++ b/new-luxc/test/test/luxc/lang/translation/case.lux @@ -6,12 +6,9 @@ (data ["e" error] text/format (coll [list])) - ["r" math/random "r/" Monad<Random>] - [macro] - (macro [code]) + ["r" math/random] + (lang ["//." synthesis #+ Path Synthesis]) test) - (luxc [lang] - (lang ["ls" synthesis])) (test/luxc common)) (def: struct-limit Nat +10) @@ -20,26 +17,24 @@ (-> Nat Nat Bool) (n/= (n/dec size) idx)) -(def: upper-alpha-ascii - (r.Random Nat) - (|> r.nat (:: r.Functor<Random> map (|>> (n/% +91) (n/max +65))))) - (def: gen-case - (r.Random [ls.Synthesis ls.Path]) + (r.Random [Synthesis Path]) (<| r.rec (function (_ gen-case)) (`` ($_ r.either - (r/wrap [(' []) (' ("lux case pop"))]) - (~~ (do-template [<gen> <synth>] + (do r.Monad<Random> + [value r.int] + (wrap [(//synthesis.path/i64 value) + //synthesis.path/pop])) + (~~ (do-template [<gen> <synth> <path>] [(do r.Monad<Random> [value <gen>] - (wrap [(<synth> value) (<synth> value)]))] - - [r.bool code.bool] - [r.nat code.nat] - [r.int code.int] - [r.deg code.deg] - [r.frac code.frac] - [(r.text' upper-alpha-ascii +5) code.text])) + (wrap [(<synth> value) + (<path> value)]))] + + [r.bool //synthesis.bool //synthesis.path/bool] + [r.int //synthesis.i64 //synthesis.path/i64] + [r.frac //synthesis.f64 //synthesis.path/f64] + [(r.unicode +5) //synthesis.text //synthesis.path/text])) (do r.Monad<Random> [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) idx (|> r.nat (:: @ map (n/% size))) @@ -47,11 +42,10 @@ #let [caseS (` [(~+ (list.concat (list (list.repeat idx (' [])) (list subS) (list.repeat (|> size n/dec (n/- idx)) (' [])))))]) - caseP (` ("lux case seq" - (~ (if (tail? size idx) - (` ("lux case tuple right" (~ (code.nat idx)))) - (` ("lux case tuple left" (~ (code.nat idx)))))) - (~ subP)))]] + caseP (//synthesis.path/seq [(if (tail? size idx) + (` ("lux case tuple right" (~ (code.nat idx)))) + (` ("lux case tuple left" (~ (code.nat idx))))) + subP])]] (wrap [caseS caseP])) (do r.Monad<Random> [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) @@ -101,34 +95,34 @@ (<| (times +100) (pattern-matching-spec run-jvm))) -(context: "[JS] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-js))) +## (context: "[JS] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-js))) -(context: "[Lua] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-lua))) +## (context: "[Lua] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-lua))) -(context: "[Ruby] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-ruby))) +## (context: "[Ruby] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-ruby))) -(context: "[Python] Function." - (<| (times +100) - (pattern-matching-spec run-python))) +## (context: "[Python] Function." +## (<| (times +100) +## (pattern-matching-spec run-python))) -(context: "[R] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-r))) +## (context: "[R] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-r))) -(context: "[Scheme] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-scheme))) +## (context: "[Scheme] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-scheme))) -(context: "[Common Lisp] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-common-lisp))) +## (context: "[Common Lisp] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-common-lisp))) -(context: "[PHP] Pattern-matching." - (<| (times +100) - (pattern-matching-spec run-php))) +## (context: "[PHP] Pattern-matching." +## (<| (times +100) +## (pattern-matching-spec run-php))) diff --git a/new-luxc/test/test/luxc/lang/translation/primitive.lux b/new-luxc/test/test/luxc/lang/translation/primitive.lux index e69590975..42d78f646 100644 --- a/new-luxc/test/test/luxc/lang/translation/primitive.lux +++ b/new-luxc/test/test/luxc/lang/translation/primitive.lux @@ -8,18 +8,11 @@ [bool "bool/" Eq<Bool>] [text "text/" Eq<Text>]) ["r" math/random] - [macro] - (macro [code]) + (lang ["//." synthesis]) test) - (luxc [lang] - (lang [".L" host] - [synthesis #+ Synthesis])) + (luxc (lang [".L" host])) (test/luxc common)) -(def: upper-alpha-ascii - (r.Random Nat) - (|> r.nat (:: r.Functor<Random> map (|>> (n/% +91) (n/max +65))))) - (def: (spec run) (-> Runner Test) (do r.Monad<Random> @@ -28,16 +21,8 @@ %int% r.int %deg% r.deg %frac% r.frac - %text% (r.text' upper-alpha-ascii +5)] + %text% (r.ascii +5)] (`` ($_ seq - (test "Can translate unit." - (|> (run (' [])) - (case> (#e.Success valueT) - (text/= hostL.unit (:! Text valueT)) - - (#e.Error error) - (exec (log! error) - false)))) (~~ (do-template [<desc> <type> <synthesis> <sample> <test>] [(test (format "Can translate " <desc> ".") (|> (run (<synthesis> <sample>)) @@ -48,46 +33,44 @@ (exec (log! error) false))))] - ["bool" Bool code.bool %bool% bool/=] - ["nat" Nat code.nat %nat% n/=] - ["int" Int code.int %int% i/=] - ["deg" Deg code.deg %deg% d/=] - ["frac" Frac code.frac %frac% f/=] - ["text" Text code.text %text% text/=])) + ["bool" Bool //synthesis.bool %bool% bool/=] + ["int" Int //synthesis.i64 %int% i/=] + ["frac" Frac //synthesis.f64 %frac% f/=] + ["text" Text //synthesis.text %text% text/=])) )))) (context: "[JVM] Primitives." (<| (times +100) (spec run-jvm))) -(context: "[JS] Primitives." - (<| (times +100) - (spec run-js))) +## (context: "[JS] Primitives." +## (<| (times +100) +## (spec run-js))) -(context: "[Lua] Primitives." - (<| (times +100) - (spec run-lua))) +## (context: "[Lua] Primitives." +## (<| (times +100) +## (spec run-lua))) -(context: "[Ruby] Primitives." - (<| (times +100) - (spec run-ruby))) +## (context: "[Ruby] Primitives." +## (<| (times +100) +## (spec run-ruby))) -(context: "[Python] Primitives." - (<| (times +100) - (spec run-python))) +## (context: "[Python] Primitives." +## (<| (times +100) +## (spec run-python))) -(context: "[R] Primitives." - (<| (times +100) - (spec run-r))) +## (context: "[R] Primitives." +## (<| (times +100) +## (spec run-r))) -(context: "[Scheme] Primitives." - (<| (times +100) - (spec run-scheme))) +## (context: "[Scheme] Primitives." +## (<| (times +100) +## (spec run-scheme))) -(context: "[Common Lisp] Primitives." - (<| (times +100) - (spec run-common-lisp))) +## (context: "[Common Lisp] Primitives." +## (<| (times +100) +## (spec run-common-lisp))) -(context: "[PHP] Primitives." - (<| (times +100) - (spec run-php))) +## (context: "[PHP] Primitives." +## (<| (times +100) +## (spec run-php))) diff --git a/new-luxc/test/test/luxc/lang/translation/reference.lux b/new-luxc/test/test/luxc/lang/translation/reference.lux index d6c848c27..41032f0c7 100644 --- a/new-luxc/test/test/luxc/lang/translation/reference.lux +++ b/new-luxc/test/test/luxc/lang/translation/reference.lux @@ -1,18 +1,13 @@ (.module: lux - (lux [io #+ IO] - (control [monad #+ do] + (lux (control [monad #+ do] pipe) (data ["e" error] [text]) + (lang ["//." synthesis]) ["r" math/random] - [macro] - (macro [code]) test) - (luxc [lang] - (lang ["_." module] - ["ls" synthesis] - (translation (jvm [".T_jvm" statement]) + (luxc (lang (translation (jvm [".T_jvm" statement]) ## (js [".T_js" statement]) ## (lua [".T_lua" statement]) ## (ruby [".T_ruby" statement]) @@ -20,17 +15,13 @@ ## (r [".T_r" statement]) ## (scheme [".T_scheme" statement]) ## (common-lisp [".T_common-lisp" statement]) - (php [".T_php" statement]) + ## (php [".T_php" statement]) ))) (test/luxc common)) -(def: upper-alpha-ascii - (r.Random Nat) - (|> r.nat (:: r.Functor<Random> map (|>> (n/% +26) (n/+ +65))))) - (def: ident-part (r.Random Text) - (|> (r.text' upper-alpha-ascii +5) + (|> (r.ascii +5) (r.filter (function (_ sample) (not (or (text.contains? "/" sample) (text.contains? "[" sample) @@ -42,7 +33,7 @@ [def-name (r.seq ident-part ident-part) def-value r.int] (test "Can refer to definitions." - (|> (define def-name (code.int def-value)) + (|> (define def-name (//synthesis.i64 def-value)) (case> (#e.Success valueT) (i/= def-value (:! Int valueT)) @@ -56,8 +47,9 @@ [register (|> r.nat (:: @ map (n/% +100))) value r.int] (test "Can refer to local variables/registers." - (|> (run (` ("lux let" (~ (code.nat register)) (~ (code.int value)) - ((~ (code.int (nat-to-int register))))))) + (|> (run (//synthesis.branch/let [(//synthesis.i64 value) + register + (//synthesis.variable/local register)])) (case> (#e.Success outputT) (i/= value (:! Int outputT)) @@ -74,34 +66,34 @@ (<| (times +100) (references-spec run-jvm def-jvm))) -(context: "[JS] References." - (<| (times +100) - (references-spec run-js def-js))) +## (context: "[JS] References." +## (<| (times +100) +## (references-spec run-js def-js))) -(context: "[Lua] References." - (<| (times +100) - (references-spec run-lua def-lua))) +## (context: "[Lua] References." +## (<| (times +100) +## (references-spec run-lua def-lua))) -(context: "[Ruby] References." - (<| (times +100) - (references-spec run-ruby def-ruby))) +## (context: "[Ruby] References." +## (<| (times +100) +## (references-spec run-ruby def-ruby))) -(context: "[Python] References." - (<| (times +100) - (references-spec run-python def-python))) +## (context: "[Python] References." +## (<| (times +100) +## (references-spec run-python def-python))) -(context: "[R] References." - (<| (times +100) - (references-spec run-r def-r))) +## (context: "[R] References." +## (<| (times +100) +## (references-spec run-r def-r))) -(context: "[Scheme] References." - (<| (times +100) - (references-spec run-scheme def-scheme))) +## (context: "[Scheme] References." +## (<| (times +100) +## (references-spec run-scheme def-scheme))) -(context: "[Common Lisp] References." - (<| (times +100) - (references-spec run-common-lisp def-common-lisp))) +## (context: "[Common Lisp] References." +## (<| (times +100) +## (references-spec run-common-lisp def-common-lisp))) -(context: "[PHP] References." - (<| (times +100) - (references-spec run-php def-php))) +## (context: "[PHP] References." +## (<| (times +100) +## (references-spec run-php def-php))) |