From da27db478b368724ee4659eb674dcdbeb2cd8747 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 24 May 2021 19:29:13 -0400 Subject: Re-named lux/host to lux/ffi. --- stdlib/source/test/lux.lux | 4 +- .../source/test/lux/control/function/contract.lux | 10 +- stdlib/source/test/lux/ffi.js.lux | 88 ++++++++++++ stdlib/source/test/lux/ffi.jvm.lux | 151 +++++++++++++++++++++ stdlib/source/test/lux/ffi.lua.lux | 24 ++++ stdlib/source/test/lux/ffi.old.lux | 145 ++++++++++++++++++++ stdlib/source/test/lux/ffi.php.lux | 24 ++++ stdlib/source/test/lux/ffi.py.lux | 24 ++++ stdlib/source/test/lux/ffi.rb.lux | 24 ++++ stdlib/source/test/lux/ffi.scm.lux | 24 ++++ stdlib/source/test/lux/host.js.lux | 88 ------------ stdlib/source/test/lux/host.jvm.lux | 151 --------------------- stdlib/source/test/lux/host.lua.lux | 24 ---- stdlib/source/test/lux/host.old.lux | 145 -------------------- stdlib/source/test/lux/host.php.lux | 24 ---- stdlib/source/test/lux/host.py.lux | 24 ---- stdlib/source/test/lux/host.rb.lux | 24 ---- stdlib/source/test/lux/host.scm.lux | 24 ---- stdlib/source/test/lux/math/number/frac.lux | 4 +- stdlib/source/test/lux/target/jvm.lux | 142 +++++++++---------- stdlib/source/test/lux/time/instant.lux | 4 +- 21 files changed, 586 insertions(+), 586 deletions(-) create mode 100644 stdlib/source/test/lux/ffi.js.lux create mode 100644 stdlib/source/test/lux/ffi.jvm.lux create mode 100644 stdlib/source/test/lux/ffi.lua.lux create mode 100644 stdlib/source/test/lux/ffi.old.lux create mode 100644 stdlib/source/test/lux/ffi.php.lux create mode 100644 stdlib/source/test/lux/ffi.py.lux create mode 100644 stdlib/source/test/lux/ffi.rb.lux create mode 100644 stdlib/source/test/lux/ffi.scm.lux delete mode 100644 stdlib/source/test/lux/host.js.lux delete mode 100644 stdlib/source/test/lux/host.jvm.lux delete mode 100644 stdlib/source/test/lux/host.lua.lux delete mode 100644 stdlib/source/test/lux/host.old.lux delete mode 100644 stdlib/source/test/lux/host.php.lux delete mode 100644 stdlib/source/test/lux/host.py.lux delete mode 100644 stdlib/source/test/lux/host.rb.lux delete mode 100644 stdlib/source/test/lux/host.scm.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 8532b3e12..40a797177 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -39,7 +39,7 @@ ## ["#." tool] ## TODO: Update & expand tests for this ["#." type] ["#." world] - ["#." host] + ["#." ffi] ["#." extension] ["#." target #_ ]])) @@ -220,7 +220,7 @@ ## /tool.test /type.test /world.test - /host.test + /ffi.test (for {@.jvm (#.Cons /target/jvm.test tail) @.old (#.Cons /target/jvm.test tail)} tail) diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux index 47962d04a..76eb07104 100644 --- a/stdlib/source/test/lux/control/function/contract.lux +++ b/stdlib/source/test/lux/control/function/contract.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["_" test (#+ Test)] - ["." host] + ["." ffi] [abstract [monad (#+ do)]] [control @@ -20,16 +20,16 @@ [expected random.nat]) ($_ _.and (_.cover [/.pre] - (case (host.try (/.pre (n.even? expected) - true)) + (case (ffi.try (/.pre (n.even? expected) + true)) (#try.Success output) output (#try.Failure error) (not (n.even? expected)))) (_.cover [/.post] - (case (host.try (/.post n.odd? - expected)) + (case (ffi.try (/.post n.odd? + expected)) (#try.Success actual) (is? expected actual) diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux new file mode 100644 index 000000000..5ffe1fbeb --- /dev/null +++ b/stdlib/source/test/lux/ffi.js.lux @@ -0,0 +1,88 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(/.import: Uint8Array) + +## On Nashorn +(/.import: java/lang/String + (new [Uint8Array /.String]) + (getBytes [/.String] Uint8Array)) + +## On Node +(/.import: Buffer + (#static from [/.String /.String] Buffer) + (toString [/.String] /.String)) + +## On the browser +(/.import: TextEncoder + (new [/.String]) + (encode [/.String] Uint8Array)) + +(/.import: TextDecoder + (new [/.String]) + (decode [Uint8Array] /.String)) + +(def: #export test + Test + (do {! random.monad} + [boolean random.bit + number (\ ! map (|>> (nat.% 100) nat.frac) random.nat) + string (random.ascii 5) + function (\ ! map (function (_ shift) + (: (-> Nat Nat) + (nat.+ shift))) + random.nat) + ## I64s get compiled as JavaScript objects with a specific structure. + object random.nat] + (<| (_.covering /._) + ($_ _.and + (_.cover [/.on_browser? /.on_node_js? /.on_nashorn?] + (or /.on_nashorn? + /.on_node_js? + /.on_browser?)) + (_.cover [/.type_of] + (and (text\= "boolean" (/.type_of boolean)) + (text\= "number" (/.type_of number)) + (text\= "string" (/.type_of string)) + (text\= "function" (/.type_of function)) + (text\= "object" (/.type_of object)))) + (_.cover [/.try] + (case (/.try (error! string)) + (#try.Success _) + false + + (#try.Failure error) + (text\= string error))) + (_.cover [/.import:] + (let [encoding "utf8"] + (text\= string + (cond /.on_nashorn? + (let [binary (java/lang/String::getBytes [encoding] (:coerce java/lang/String string))] + (|> (java/lang/String::new [binary encoding]) + (:coerce Text))) + + /.on_node_js? + (|> (Buffer::from [string encoding]) + (Buffer::toString [encoding])) + + ## On the browser + (let [binary (|> (TextEncoder::new [encoding]) + (TextEncoder::encode [string]))] + (|> (TextDecoder::new [encoding]) + (TextDecoder::decode [binary]))) + )))) + )))) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux new file mode 100644 index 000000000..9edaecd0c --- /dev/null +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -0,0 +1,151 @@ +(.module: + [lux #* + [abstract/monad (#+ Monad do)] + [control + pipe] + [data + ["." text ("#\." equivalence)]] + [math + ["r" random] + [number + ["n" nat] + ["i" int]]] + ["_" test (#+ Test)]] + {1 + ["." / (#+ import: class: interface: object)]}) + +(import: (java/util/concurrent/Callable a)) + +(import: java/lang/Long) + +(import: java/lang/String) + +(import: java/lang/Exception + ["#::." + (new [java/lang/String])]) + +(import: java/lang/Object) + +(import: (java/lang/Class a) + ["#::." + (getName [] java/lang/String)]) + +(import: java/lang/Runnable) + +(import: java/lang/System + ["#::." + (#static out java/io/PrintStream) + (#static currentTimeMillis [] #io long) + (#static getenv [java/lang/String] #io #? java/lang/String)]) + +## TODO: Handle "class:" ASAP. +## (class: #final (TestClass A) [java/lang/Runnable] +## ## Fields +## (#private foo boolean) +## (#private bar A) +## (#private baz java/lang/Object) +## ## Methods +## (#public [] (new self {value A}) [] +## (exec (:= ::foo #1) +## (:= ::bar value) +## (:= ::baz "") +## [])) +## (#public (virtual self) java/lang/Object +## "") +## (#public #static (static) java/lang/Object +## "") +## (java/lang/Runnable [] (run self) void +## [])) + +(def: test_runnable + (object [] [java/lang/Runnable] + [] + (java/lang/Runnable + [] (run self) void + []))) + +(def: test_callable + (object [a] [(java/util/concurrent/Callable a)] + [] + ((java/util/concurrent/Callable a) + [] (call self) a #throws [java/lang/Exception] + (undefined)))) + +## (interface: TestInterface +## ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) + +(def: conversions + Test + (do r.monad + [sample r.int] + (`` ($_ _.and + (~~ (template [ ] + [(_.test + (or (|> sample (:coerce java/lang/Long) (:coerce Int) (i.= sample)) + (let [capped_sample (|> sample (:coerce java/lang/Long) )] + (|> capped_sample (:coerce Int) (i.= (:coerce Int capped_sample))))))] + + [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] + [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] + [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] + [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] + [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] + [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] + )) + )))) + +(def: miscellaneous + Test + (do {! r.monad} + [sample (\ ! map (|>> (:coerce java/lang/Object)) + (r.ascii 1))] + ($_ _.and + (_.test "Can check if an object is of a certain class." + (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) + (case (/.check java/lang/Long sample) (#.Some _) false #.None true) + (case (/.check java/lang/Object sample) (#.Some _) true #.None false) + (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) + + (_.test "Can run code in a 'synchronized' block." + (/.synchronized sample #1)) + + (_.test "Can access Class instances." + (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) + + (_.test "Can check if a value is null." + (and (/.null? (/.null)) + (not (/.null? sample)))) + + (_.test "Can safely convert nullable references into Maybe values." + (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) + (case> #.None #1 + _ #0)) + (|> (: (Maybe java/lang/Object) (/.??? sample)) + (case> (#.Some _) #1 + _ #0)))) + ))) + +(def: arrays + Test + (do {! r.monad} + [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1)))) + idx (|> r.nat (\ ! map (n.% size))) + value (\ ! map (|>> (:coerce java/lang/Long)) r.int)] + ($_ _.and + (_.test "Can create arrays of some length." + (n.= size (/.array_length (/.array java/lang/Long size)))) + + (_.test "Can set and get array values." + (let [arr (/.array java/lang/Long size)] + (exec (/.array_write idx value arr) + (i.= (:coerce Int value) + (:coerce Int (/.array_read idx arr))))))))) + +(def: #export test + ($_ _.and + (<| (_.context "Conversions.") + ..conversions) + (<| (_.context "Miscellaneous.") + ..miscellaneous) + (<| (_.context "Arrays.") + ..arrays))) diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux new file mode 100644 index 000000000..0b6cac81b --- /dev/null +++ b/stdlib/source/test/lux/ffi.lua.lux @@ -0,0 +1,24 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(def: #export test + Test + (do {! random.monad} + [] + (<| (_.covering /._) + (_.test "TBD" + true)))) diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux new file mode 100644 index 000000000..b14dac30d --- /dev/null +++ b/stdlib/source/test/lux/ffi.old.lux @@ -0,0 +1,145 @@ +(.module: + [lux #* + [abstract/monad (#+ Monad do)] + [control + pipe] + [data + ["." text ("#\." equivalence)]] + [math + ["r" random] + [number + ["n" nat] + ["i" int]]] + ["_" test (#+ Test)]] + {1 + ["." / (#+ import: class: interface: object)]}) + +(import: (java/util/concurrent/Callable a)) + +(import: java/lang/Object) +(import: java/lang/String) + +(import: java/lang/Exception + ["#::." + (new [java/lang/String])]) + +(import: java/lang/Runnable) + +(import: (java/lang/Class a) + ["#::." + (getName [] java/lang/String)]) + +(import: java/lang/System + ["#::." + (#static out java/io/PrintStream) + (#static currentTimeMillis [] #io long) + (#static getenv [java/lang/String] #io #? java/lang/String)]) + +(class: #final (TestClass A) [java/lang/Runnable] + ## Fields + (#private foo boolean) + (#private bar A) + (#private baz java/lang/Object) + ## Methods + (#public [] (new {value A}) [] + (exec (:= ::foo #1) + (:= ::bar value) + (:= ::baz "") + [])) + (#public (virtual self) java/lang/Object + "") + (#public #static (static) java/lang/Object + "") + (java/lang/Runnable [] (run self) void + [])) + +(def: test_runnable + (object [] [java/lang/Runnable] + [] + (java/lang/Runnable [] (run self) void + []))) + +(def: test_callable + (object [a] [(java/util/concurrent/Callable a)] + [] + (java/util/concurrent/Callable [] (call self) a + (undefined)))) + +(interface: TestInterface + ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) + +(def: conversions + Test + (do r.monad + [sample r.int] + (`` ($_ _.and + (~~ (template [ ] + [(_.test + (or (|> sample (i.= sample)) + (let [capped_sample (|> sample )] + (|> capped_sample (i.= capped_sample)))))] + + [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] + [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] + [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] + [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] + [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] + [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] + )) + )))) + +(def: miscellaneous + Test + (do r.monad + [sample (r.ascii 1)] + ($_ _.and + (_.test "Can check if an object is of a certain class." + (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) + (case (/.check java/lang/Long sample) (#.Some _) false #.None true) + (case (/.check java/lang/Object sample) (#.Some _) true #.None false) + (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) + + (_.test "Can run code in a 'synchronized' block." + (/.synchronized sample #1)) + + (_.test "Can access Class instances." + (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) + + (_.test "Can check if a value is null." + (and (/.null? (/.null)) + (not (/.null? sample)))) + + (_.test "Can safely convert nullable references into Maybe values." + (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) + (case> #.None #1 + _ #0)) + (|> (: (Maybe java/lang/Object) (/.??? sample)) + (case> (#.Some _) #1 + _ #0)))) + ))) + +(def: arrays + Test + (do {! r.monad} + [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1)))) + idx (|> r.nat (\ ! map (n.% size))) + value r.int] + ($_ _.and + (_.test "Can create arrays of some length." + (n.= size (/.array_length (/.array java/lang/Long size)))) + + (_.test "Can set and get array values." + (let [arr (/.array java/lang/Long size)] + (exec (/.array_write idx value arr) + (i.= value (/.array_read idx arr))))) + ))) + +(def: #export test + ($_ _.and + (<| (_.context "Conversions.") + ..conversions) + (<| (_.context "Miscellaneous.") + ..miscellaneous) + (<| (_.context "Arrays.") + ..arrays) + )) diff --git a/stdlib/source/test/lux/ffi.php.lux b/stdlib/source/test/lux/ffi.php.lux new file mode 100644 index 000000000..0b6cac81b --- /dev/null +++ b/stdlib/source/test/lux/ffi.php.lux @@ -0,0 +1,24 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(def: #export test + Test + (do {! random.monad} + [] + (<| (_.covering /._) + (_.test "TBD" + true)))) diff --git a/stdlib/source/test/lux/ffi.py.lux b/stdlib/source/test/lux/ffi.py.lux new file mode 100644 index 000000000..0b6cac81b --- /dev/null +++ b/stdlib/source/test/lux/ffi.py.lux @@ -0,0 +1,24 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(def: #export test + Test + (do {! random.monad} + [] + (<| (_.covering /._) + (_.test "TBD" + true)))) diff --git a/stdlib/source/test/lux/ffi.rb.lux b/stdlib/source/test/lux/ffi.rb.lux new file mode 100644 index 000000000..0b6cac81b --- /dev/null +++ b/stdlib/source/test/lux/ffi.rb.lux @@ -0,0 +1,24 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(def: #export test + Test + (do {! random.monad} + [] + (<| (_.covering /._) + (_.test "TBD" + true)))) diff --git a/stdlib/source/test/lux/ffi.scm.lux b/stdlib/source/test/lux/ffi.scm.lux new file mode 100644 index 000000000..0b6cac81b --- /dev/null +++ b/stdlib/source/test/lux/ffi.scm.lux @@ -0,0 +1,24 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["." nat] + ["." frac]]]] + {1 + ["." /]}) + +(def: #export test + Test + (do {! random.monad} + [] + (<| (_.covering /._) + (_.test "TBD" + true)))) diff --git a/stdlib/source/test/lux/host.js.lux b/stdlib/source/test/lux/host.js.lux deleted file mode 100644 index 5ffe1fbeb..000000000 --- a/stdlib/source/test/lux/host.js.lux +++ /dev/null @@ -1,88 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(/.import: Uint8Array) - -## On Nashorn -(/.import: java/lang/String - (new [Uint8Array /.String]) - (getBytes [/.String] Uint8Array)) - -## On Node -(/.import: Buffer - (#static from [/.String /.String] Buffer) - (toString [/.String] /.String)) - -## On the browser -(/.import: TextEncoder - (new [/.String]) - (encode [/.String] Uint8Array)) - -(/.import: TextDecoder - (new [/.String]) - (decode [Uint8Array] /.String)) - -(def: #export test - Test - (do {! random.monad} - [boolean random.bit - number (\ ! map (|>> (nat.% 100) nat.frac) random.nat) - string (random.ascii 5) - function (\ ! map (function (_ shift) - (: (-> Nat Nat) - (nat.+ shift))) - random.nat) - ## I64s get compiled as JavaScript objects with a specific structure. - object random.nat] - (<| (_.covering /._) - ($_ _.and - (_.cover [/.on_browser? /.on_node_js? /.on_nashorn?] - (or /.on_nashorn? - /.on_node_js? - /.on_browser?)) - (_.cover [/.type_of] - (and (text\= "boolean" (/.type_of boolean)) - (text\= "number" (/.type_of number)) - (text\= "string" (/.type_of string)) - (text\= "function" (/.type_of function)) - (text\= "object" (/.type_of object)))) - (_.cover [/.try] - (case (/.try (error! string)) - (#try.Success _) - false - - (#try.Failure error) - (text\= string error))) - (_.cover [/.import:] - (let [encoding "utf8"] - (text\= string - (cond /.on_nashorn? - (let [binary (java/lang/String::getBytes [encoding] (:coerce java/lang/String string))] - (|> (java/lang/String::new [binary encoding]) - (:coerce Text))) - - /.on_node_js? - (|> (Buffer::from [string encoding]) - (Buffer::toString [encoding])) - - ## On the browser - (let [binary (|> (TextEncoder::new [encoding]) - (TextEncoder::encode [string]))] - (|> (TextDecoder::new [encoding]) - (TextDecoder::decode [binary]))) - )))) - )))) diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux deleted file mode 100644 index 9edaecd0c..000000000 --- a/stdlib/source/test/lux/host.jvm.lux +++ /dev/null @@ -1,151 +0,0 @@ -(.module: - [lux #* - [abstract/monad (#+ Monad do)] - [control - pipe] - [data - ["." text ("#\." equivalence)]] - [math - ["r" random] - [number - ["n" nat] - ["i" int]]] - ["_" test (#+ Test)]] - {1 - ["." / (#+ import: class: interface: object)]}) - -(import: (java/util/concurrent/Callable a)) - -(import: java/lang/Long) - -(import: java/lang/String) - -(import: java/lang/Exception - ["#::." - (new [java/lang/String])]) - -(import: java/lang/Object) - -(import: (java/lang/Class a) - ["#::." - (getName [] java/lang/String)]) - -(import: java/lang/Runnable) - -(import: java/lang/System - ["#::." - (#static out java/io/PrintStream) - (#static currentTimeMillis [] #io long) - (#static getenv [java/lang/String] #io #? java/lang/String)]) - -## TODO: Handle "class:" ASAP. -## (class: #final (TestClass A) [java/lang/Runnable] -## ## Fields -## (#private foo boolean) -## (#private bar A) -## (#private baz java/lang/Object) -## ## Methods -## (#public [] (new self {value A}) [] -## (exec (:= ::foo #1) -## (:= ::bar value) -## (:= ::baz "") -## [])) -## (#public (virtual self) java/lang/Object -## "") -## (#public #static (static) java/lang/Object -## "") -## (java/lang/Runnable [] (run self) void -## [])) - -(def: test_runnable - (object [] [java/lang/Runnable] - [] - (java/lang/Runnable - [] (run self) void - []))) - -(def: test_callable - (object [a] [(java/util/concurrent/Callable a)] - [] - ((java/util/concurrent/Callable a) - [] (call self) a #throws [java/lang/Exception] - (undefined)))) - -## (interface: TestInterface -## ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) - -(def: conversions - Test - (do r.monad - [sample r.int] - (`` ($_ _.and - (~~ (template [ ] - [(_.test - (or (|> sample (:coerce java/lang/Long) (:coerce Int) (i.= sample)) - (let [capped_sample (|> sample (:coerce java/lang/Long) )] - (|> capped_sample (:coerce Int) (i.= (:coerce Int capped_sample))))))] - - [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] - [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] - [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] - [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] - [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] - [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] - )) - )))) - -(def: miscellaneous - Test - (do {! r.monad} - [sample (\ ! map (|>> (:coerce java/lang/Object)) - (r.ascii 1))] - ($_ _.and - (_.test "Can check if an object is of a certain class." - (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) - (case (/.check java/lang/Long sample) (#.Some _) false #.None true) - (case (/.check java/lang/Object sample) (#.Some _) true #.None false) - (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) - - (_.test "Can run code in a 'synchronized' block." - (/.synchronized sample #1)) - - (_.test "Can access Class instances." - (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) - - (_.test "Can check if a value is null." - (and (/.null? (/.null)) - (not (/.null? sample)))) - - (_.test "Can safely convert nullable references into Maybe values." - (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) - (case> #.None #1 - _ #0)) - (|> (: (Maybe java/lang/Object) (/.??? sample)) - (case> (#.Some _) #1 - _ #0)))) - ))) - -(def: arrays - Test - (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1)))) - idx (|> r.nat (\ ! map (n.% size))) - value (\ ! map (|>> (:coerce java/lang/Long)) r.int)] - ($_ _.and - (_.test "Can create arrays of some length." - (n.= size (/.array_length (/.array java/lang/Long size)))) - - (_.test "Can set and get array values." - (let [arr (/.array java/lang/Long size)] - (exec (/.array_write idx value arr) - (i.= (:coerce Int value) - (:coerce Int (/.array_read idx arr))))))))) - -(def: #export test - ($_ _.and - (<| (_.context "Conversions.") - ..conversions) - (<| (_.context "Miscellaneous.") - ..miscellaneous) - (<| (_.context "Arrays.") - ..arrays))) diff --git a/stdlib/source/test/lux/host.lua.lux b/stdlib/source/test/lux/host.lua.lux deleted file mode 100644 index 0b6cac81b..000000000 --- a/stdlib/source/test/lux/host.lua.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(def: #export test - Test - (do {! random.monad} - [] - (<| (_.covering /._) - (_.test "TBD" - true)))) diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux deleted file mode 100644 index b14dac30d..000000000 --- a/stdlib/source/test/lux/host.old.lux +++ /dev/null @@ -1,145 +0,0 @@ -(.module: - [lux #* - [abstract/monad (#+ Monad do)] - [control - pipe] - [data - ["." text ("#\." equivalence)]] - [math - ["r" random] - [number - ["n" nat] - ["i" int]]] - ["_" test (#+ Test)]] - {1 - ["." / (#+ import: class: interface: object)]}) - -(import: (java/util/concurrent/Callable a)) - -(import: java/lang/Object) -(import: java/lang/String) - -(import: java/lang/Exception - ["#::." - (new [java/lang/String])]) - -(import: java/lang/Runnable) - -(import: (java/lang/Class a) - ["#::." - (getName [] java/lang/String)]) - -(import: java/lang/System - ["#::." - (#static out java/io/PrintStream) - (#static currentTimeMillis [] #io long) - (#static getenv [java/lang/String] #io #? java/lang/String)]) - -(class: #final (TestClass A) [java/lang/Runnable] - ## Fields - (#private foo boolean) - (#private bar A) - (#private baz java/lang/Object) - ## Methods - (#public [] (new {value A}) [] - (exec (:= ::foo #1) - (:= ::bar value) - (:= ::baz "") - [])) - (#public (virtual self) java/lang/Object - "") - (#public #static (static) java/lang/Object - "") - (java/lang/Runnable [] (run self) void - [])) - -(def: test_runnable - (object [] [java/lang/Runnable] - [] - (java/lang/Runnable [] (run self) void - []))) - -(def: test_callable - (object [a] [(java/util/concurrent/Callable a)] - [] - (java/util/concurrent/Callable [] (call self) a - (undefined)))) - -(interface: TestInterface - ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) - -(def: conversions - Test - (do r.monad - [sample r.int] - (`` ($_ _.and - (~~ (template [ ] - [(_.test - (or (|> sample (i.= sample)) - (let [capped_sample (|> sample )] - (|> capped_sample (i.= capped_sample)))))] - - [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] - [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] - [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] - [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] - [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] - [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] - )) - )))) - -(def: miscellaneous - Test - (do r.monad - [sample (r.ascii 1)] - ($_ _.and - (_.test "Can check if an object is of a certain class." - (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) - (case (/.check java/lang/Long sample) (#.Some _) false #.None true) - (case (/.check java/lang/Object sample) (#.Some _) true #.None false) - (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) - - (_.test "Can run code in a 'synchronized' block." - (/.synchronized sample #1)) - - (_.test "Can access Class instances." - (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) - - (_.test "Can check if a value is null." - (and (/.null? (/.null)) - (not (/.null? sample)))) - - (_.test "Can safely convert nullable references into Maybe values." - (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) - (case> #.None #1 - _ #0)) - (|> (: (Maybe java/lang/Object) (/.??? sample)) - (case> (#.Some _) #1 - _ #0)))) - ))) - -(def: arrays - Test - (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1)))) - idx (|> r.nat (\ ! map (n.% size))) - value r.int] - ($_ _.and - (_.test "Can create arrays of some length." - (n.= size (/.array_length (/.array java/lang/Long size)))) - - (_.test "Can set and get array values." - (let [arr (/.array java/lang/Long size)] - (exec (/.array_write idx value arr) - (i.= value (/.array_read idx arr))))) - ))) - -(def: #export test - ($_ _.and - (<| (_.context "Conversions.") - ..conversions) - (<| (_.context "Miscellaneous.") - ..miscellaneous) - (<| (_.context "Arrays.") - ..arrays) - )) diff --git a/stdlib/source/test/lux/host.php.lux b/stdlib/source/test/lux/host.php.lux deleted file mode 100644 index 0b6cac81b..000000000 --- a/stdlib/source/test/lux/host.php.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(def: #export test - Test - (do {! random.monad} - [] - (<| (_.covering /._) - (_.test "TBD" - true)))) diff --git a/stdlib/source/test/lux/host.py.lux b/stdlib/source/test/lux/host.py.lux deleted file mode 100644 index 0b6cac81b..000000000 --- a/stdlib/source/test/lux/host.py.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(def: #export test - Test - (do {! random.monad} - [] - (<| (_.covering /._) - (_.test "TBD" - true)))) diff --git a/stdlib/source/test/lux/host.rb.lux b/stdlib/source/test/lux/host.rb.lux deleted file mode 100644 index 0b6cac81b..000000000 --- a/stdlib/source/test/lux/host.rb.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(def: #export test - Test - (do {! random.monad} - [] - (<| (_.covering /._) - (_.test "TBD" - true)))) diff --git a/stdlib/source/test/lux/host.scm.lux b/stdlib/source/test/lux/host.scm.lux deleted file mode 100644 index 0b6cac81b..000000000 --- a/stdlib/source/test/lux/host.scm.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["." nat] - ["." frac]]]] - {1 - ["." /]}) - -(def: #export test - Test - (do {! random.monad} - [] - (<| (_.covering /._) - (_.test "TBD" - true)))) diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 5f37be2ef..ddeab3763 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -2,7 +2,7 @@ [lux #* ["_" test (#+ Test)] ["@" target] - ["." host] + ["." ffi] [abstract [monad (#+ do)] {[0 #spec] @@ -118,7 +118,7 @@ )) ))) -(with_expansions [ (as_is (host.import: java/lang/Double +(with_expansions [ (as_is (ffi.import: java/lang/Double ["#::." (#static doubleToRawLongBits [double] long) (#static longBitsToDouble [long] double)]))] diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index f2c8963d3..6e22d611f 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -1,6 +1,6 @@ (.module: [lux (#- Type type primitive int) - ["." host (#+ import:)] + ["." ffi (#+ import:)] ["@" target] [abstract ["." monad (#+ do)]] @@ -96,7 +96,7 @@ (def: (get_method name class) (-> Text (java/lang/Class java/lang/Object) java/lang/reflect/Method) (java/lang/Class::getDeclaredMethod name - (host.array (java/lang/Class java/lang/Object) 0) + (ffi.array (java/lang/Class java/lang/Object) 0) class)) (def: $Object (/type.class "java.lang.Object" (list))) @@ -124,8 +124,8 @@ loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method method_name class))] - (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) + method (ffi.try (get_method method_name class))] + (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) (test actual) @@ -165,10 +165,10 @@ (/.invokestatic ..$Byte "valueOf" (/type.method [(list /type.byte) ..$Byte (list)]))) (def: $Byte::random (Random java/lang/Byte) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_byte) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_byte) random.int)) (def: $Byte::literal (-> java/lang/Byte (Bytecode Any)) - (|>> host.byte_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.byte_to_long (:coerce I64) i32.i32 /.int)) (def: $Byte::primitive (Primitive java/lang/Byte) {#unboxed /type.byte @@ -183,10 +183,10 @@ (/.invokestatic ..$Short "valueOf" (/type.method [(list /type.short) ..$Short (list)]))) (def: $Short::random (Random java/lang/Short) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_short) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_short) random.int)) (def: $Short::literal (-> java/lang/Short (Bytecode Any)) - (|>> host.short_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.short_to_long (:coerce I64) i32.i32 /.int)) (def: $Short::primitive (Primitive java/lang/Short) {#unboxed /type.short @@ -201,10 +201,10 @@ (/.invokestatic ..$Integer "valueOf" (/type.method [(list /type.int) ..$Integer (list)]))) (def: $Integer::random (Random java/lang/Integer) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int) random.int)) (def: $Integer::literal (-> java/lang/Integer (Bytecode Any)) - (|>> host.int_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.int_to_long (:coerce I64) i32.i32 /.int)) (def: $Integer::primitive (Primitive java/lang/Integer) {#unboxed /type.int @@ -230,12 +230,12 @@ (def: $Float::random (Random java/lang/Float) (\ random.monad map - (|>> (:coerce java/lang/Double) host.double_to_float) + (|>> (:coerce java/lang/Double) ffi.double_to_float) random.frac)) (def: $Float::literal /.float) (def: valid_float (Random java/lang/Float) - (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) + (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)) (def: $Float::primitive (Primitive java/lang/Float) @@ -269,10 +269,10 @@ (/.invokestatic ..$Character "valueOf" (/type.method [(list /type.char) ..$Character (list)]))) (def: $Character::random (Random java/lang/Character) - (\ random.monad map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_char) random.int)) + (\ random.monad map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int)) (def: $Character::literal (-> java/lang/Character (Bytecode Any)) - (|>> host.char_to_long (:coerce I64) i32.i32 /.int)) + (|>> ffi.char_to_long (:coerce I64) i32.i32 /.int)) (def: $Character::primitive (Primitive java/lang/Character) {#unboxed /type.char @@ -314,8 +314,8 @@ [_ ( (|> expected .int try.assume))] ))))] - [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" host.byte_to_long /signed.s1] - [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" host.short_to_long /signed.s2] + [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" ffi.byte_to_long /signed.s1] + [short 15 java/lang/Short /.sipush ..$Short::wrap "SIPUSH" ffi.short_to_long /signed.s2] ) (template [ ] @@ -382,7 +382,7 @@ shift (: (-> (-> java/lang/Integer java/lang/Integer java/lang/Integer) (Bytecode Any) (Random Bit)) (function (_ reference instruction) (do {! random.monad} - [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) host.long_to_int) random.nat) + [parameter (\ ! map (|>> (n.% 32) .int (:coerce java/lang/Long) ffi.long_to_int) random.nat) subject ..$Integer::random] (int (reference parameter subject) (do /.monad @@ -390,13 +390,13 @@ _ (..$Integer::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "ICONST_M1" (int (host.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1)) - (_.lift "ICONST_0" (int (host.long_to_int (:coerce java/lang/Long +0)) /.iconst_0)) - (_.lift "ICONST_1" (int (host.long_to_int (:coerce java/lang/Long +1)) /.iconst_1)) - (_.lift "ICONST_2" (int (host.long_to_int (:coerce java/lang/Long +2)) /.iconst_2)) - (_.lift "ICONST_3" (int (host.long_to_int (:coerce java/lang/Long +3)) /.iconst_3)) - (_.lift "ICONST_4" (int (host.long_to_int (:coerce java/lang/Long +4)) /.iconst_4)) - (_.lift "ICONST_5" (int (host.long_to_int (:coerce java/lang/Long +5)) /.iconst_5)) + (_.lift "ICONST_M1" (int (ffi.long_to_int (:coerce java/lang/Long -1)) /.iconst_m1)) + (_.lift "ICONST_0" (int (ffi.long_to_int (:coerce java/lang/Long +0)) /.iconst_0)) + (_.lift "ICONST_1" (int (ffi.long_to_int (:coerce java/lang/Long +1)) /.iconst_1)) + (_.lift "ICONST_2" (int (ffi.long_to_int (:coerce java/lang/Long +2)) /.iconst_2)) + (_.lift "ICONST_3" (int (ffi.long_to_int (:coerce java/lang/Long +3)) /.iconst_3)) + (_.lift "ICONST_4" (int (ffi.long_to_int (:coerce java/lang/Long +4)) /.iconst_4)) + (_.lift "ICONST_5" (int (ffi.long_to_int (:coerce java/lang/Long +5)) /.iconst_5)) (_.lift "LDC_W/INTEGER" (do random.monad [expected ..$Integer::random] @@ -410,7 +410,7 @@ (_.lift "INEG" (unary (function (_ value) ((int/2 "jvm isub" "jvm int -") value - (host.long_to_int (:coerce java/lang/Long +0)))) + (ffi.long_to_int (:coerce java/lang/Long +0)))) /.ineg))) bitwise ($_ _.and (_.lift "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand)) @@ -463,10 +463,10 @@ (do {! random.monad} [parameter (\ ! map (|>> (n.% 64) (:coerce java/lang/Long)) random.nat) subject ..$Long::random] - (long (reference (host.long_to_int parameter) subject) + (long (reference (ffi.long_to_int parameter) subject) (do /.monad [_ (..$Long::literal subject) - _ (..$Integer::literal (host.long_to_int parameter))] + _ (..$Integer::literal (ffi.long_to_int parameter))] instruction))))) literal ($_ _.and (_.lift "LCONST_0" (long (:coerce java/lang/Long +0) /.lconst_0)) @@ -534,14 +534,14 @@ (<| (..bytecode (for {@.old (function (_ actual) (or (|> actual (:coerce java/lang/Float) ("jvm feq" expected)) - (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) - (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual))))))) + (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected))) + (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual))))))) @.jvm (function (_ actual) (or (|> actual (:coerce java/lang/Float) "jvm object cast" ("jvm float =" ("jvm object cast" expected))) - (and (f.not_a_number? (:coerce Frac (host.float_to_double expected))) - (f.not_a_number? (:coerce Frac (host.float_to_double (:coerce java/lang/Float actual)))))))})) + (and (f.not_a_number? (:coerce Frac (ffi.float_to_double expected))) + (f.not_a_number? (:coerce Frac (ffi.float_to_double (:coerce java/lang/Float actual)))))))})) (do /.monad [_ bytecode] ..$Float::wrap)))) @@ -568,9 +568,9 @@ _ (..$Float::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "FCONST_0" (float (host.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0)) - (_.lift "FCONST_1" (float (host.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1)) - (_.lift "FCONST_2" (float (host.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2)) + (_.lift "FCONST_0" (float (ffi.double_to_float (:coerce java/lang/Double +0.0)) /.fconst_0)) + (_.lift "FCONST_1" (float (ffi.double_to_float (:coerce java/lang/Double +1.0)) /.fconst_1)) + (_.lift "FCONST_2" (float (ffi.double_to_float (:coerce java/lang/Double +2.0)) /.fconst_2)) (_.lift "LDC_W/FLOAT" (do random.monad [expected ..$Float::random] @@ -584,12 +584,12 @@ (_.lift "FNEG" (unary (function (_ value) ((float/2 "jvm fsub" "jvm float -") value - (host.double_to_float (:coerce java/lang/Double +0.0)))) + (ffi.double_to_float (:coerce java/lang/Double +0.0)))) /.fneg))) comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit)) (function (_ instruction standard) (do random.monad - [#let [valid_float (random.filter (|>> host.float_to_double (:coerce Frac) f.not_a_number? not) + [#let [valid_float (random.filter (|>> ffi.float_to_double (:coerce Frac) f.not_a_number? not) ..$Float::random)] reference valid_float subject valid_float @@ -892,8 +892,8 @@ (case (do try.monad [_ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method static_method class)) - output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] + method (ffi.try (get_method static_method class)) + output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) (i.= (:coerce Int expected) (:coerce Int actual)) @@ -927,7 +927,7 @@ (-> a Any Bit) (Random Bit))) (function (_ size constructor value literal [*store *load *wrap] test) - (let [!index ($Integer::literal (host.long_to_int (:coerce java/lang/Long +0)))] + (let [!index ($Integer::literal (ffi.long_to_int (:coerce java/lang/Long +0)))] (<| (..bytecode (test value)) (do /.monad [_ (!length size) @@ -957,18 +957,18 @@ (array (/.newarray /instruction.t_byte) $Byte::random $Byte::literal [/.bastore /.baload $Byte::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))})))) (_.context "short" (array (/.newarray /instruction.t_short) $Short::random $Short::literal [/.sastore /.saload $Short::wrap] (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) + (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))) + (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))})))) (_.context "int" (array (/.newarray /instruction.t_int) $Integer::random $Integer::literal [/.iastore /.iaload $Integer::wrap] (function (_ expected) @@ -1028,7 +1028,7 @@ (<| (_.lift "MULTIANEWARRAY") (..bytecode (|>> (:coerce Nat) (n.= sizesH))) (do {! /.monad} - [_ (monad.map ! (|>> (:coerce java/lang/Long) host.long_to_int ..$Integer::literal) + [_ (monad.map ! (|>> (:coerce java/lang/Long) ffi.long_to_int ..$Integer::literal) (#.Cons sizesH sizesT)) _ (/.multianewarray type (|> dimensions /unsigned.u1 try.assume)) _ ?length] @@ -1064,40 +1064,40 @@ ($_ _.and (<| (_.context "int") ($_ _.and - (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> host.int_to_long) long::=)) - (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> host.int_to_float) float::=)) - (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> host.int_to_double) double::=)) - (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> host.int_to_byte) + (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> ffi.int_to_long) long::=)) + (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> ffi.int_to_float) float::=)) + (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=)) + (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Byte) host.byte_to_long ("jvm leq" (host.byte_to_long expected))) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) @.jvm - (|>> (:coerce java/lang/Byte) host.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.byte_to_long (:coerce java/lang/Byte expected)))))})))) - (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> host.int_to_char) + (|>> (:coerce java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:coerce java/lang/Byte expected)))))})))) + (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char) (!::= java/lang/Character "jvm ceq" "jvm char ="))) - (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> host.int_to_short) + (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short) (function (_ expected) (for {@.old - (|>> (:coerce java/lang/Short) host.short_to_long ("jvm leq" (host.short_to_long expected))) + (|>> (:coerce java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) @.jvm - (|>> (:coerce java/lang/Short) host.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (host.short_to_long (:coerce java/lang/Short expected)))))})))))) + (|>> (:coerce java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:coerce java/lang/Short expected)))))})))))) (<| (_.context "long") ($_ _.and - (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> host.long_to_int) int::=)) - (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> host.long_to_float) float::=)) - (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> host.long_to_double) double::=)))) + (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=)) + (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=)) + (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> ffi.long_to_double) double::=)))) (<| (_.context "float") ($_ _.and - (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> host.float_to_int) int::=)) - (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> host.float_to_long) long::=)) - (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> host.float_to_double) double::=)))) + (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> ffi.float_to_int) int::=)) + (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> ffi.float_to_long) long::=)) + (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> ffi.float_to_double) double::=)))) (<| (_.context "double") ($_ _.and - (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> host.double_to_int) int::=)) - (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> host.double_to_long) long::=)) - (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> host.double_to_float) float::=)))) + (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> ffi.double_to_int) int::=)) + (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> ffi.double_to_long) long::=)) + (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=)))) ))) (def: value @@ -1156,13 +1156,13 @@ #let [expected (: java/lang/Long (for {@.old ("jvm ladd" - (host.byte_to_long base) + (ffi.byte_to_long base) (.int (/unsigned.value increment))) @.jvm ("jvm object cast" ("jvm long +" - ("jvm object cast" (host.byte_to_long base)) + ("jvm object cast" (ffi.byte_to_long base)) ("jvm object cast" (:coerce java/lang/Long (/unsigned.value increment)))))}))]] (..bytecode (|>> (:coerce Int) (i.= (:coerce Int expected))) (do /.monad @@ -1357,8 +1357,8 @@ loader (/loader.memory (/loader.new_library []))] _ (/loader.define class_name bytecode loader) class (io.run (/loader.load class_name loader)) - method (host.try (get_method object_method_name class))] - (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)) + method (ffi.try (get_method object_method_name class))] + (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)) (#try.Success actual) (test expected actual) @@ -1498,7 +1498,7 @@ random.nat) choice (\ ! map (n.% options) random.nat) options (|> random.int - (\ ! map (|>> (:coerce java/lang/Long) host.long_to_int host.int_to_long (:coerce Int))) + (\ ! map (|>> (:coerce java/lang/Long) ffi.long_to_int ffi.int_to_long (:coerce Int))) (random.set i.hash options) (\ ! map set.to_list)) #let [choice (maybe.assume (list.nth choice options))] @@ -1509,7 +1509,7 @@ [@right /.new_label @wrong /.new_label @return /.new_label - _ (..$Integer::literal (host.long_to_int (:coerce java/lang/Long choice))) + _ (..$Integer::literal (ffi.long_to_int (:coerce java/lang/Long choice))) _ (/.lookupswitch @wrong (list\map (function (_ option) [(|> option /signed.s4 try.assume) (if (i.= choice option) @right @wrong)]) @@ -1709,8 +1709,8 @@ _ (/loader.define interface_class interface_bytecode loader) _ (/loader.define concrete_class concrete_bytecode loader) class (io.run (/loader.load concrete_class loader)) - method (host.try (get_method static_method class)) - output (java/lang/reflect/Method::invoke (host.null) (host.array java/lang/Object 0) method)] + method (ffi.try (get_method static_method class)) + output (java/lang/reflect/Method::invoke (ffi.null) (ffi.array java/lang/Object 0) method)] (wrap (:coerce Int output))) (#try.Success actual) (i.= (:coerce Int expected) (:coerce Int actual)) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 4f6080b48..316ef8783 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -1,7 +1,7 @@ (.module: [lux #* ["_" test (#+ Test)] - ["." host] + ["." ffi] [abstract [monad (#+ do)] {[0 #spec] @@ -97,7 +97,7 @@ (apply duration.inverse day\pred 6) (apply duration.inverse day\pred 7))))) (_.cover [/.now] - (case (host.try /.now) + (case (ffi.try /.now) (#try.Success _) true -- cgit v1.2.3