aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux167
1 files changed, 165 insertions, 2 deletions
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index 14f3d201a..9eb52d393 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -5,6 +5,7 @@
["[0]" type ("[1]#[0]" equivalence)]
["[0]" meta]
["[0]" debug]
+ ["[0]" static]
[abstract
[monad {"+" do}]]
[control
@@ -24,8 +25,9 @@
["[0]" code]
["[0]" template]]
[math
- ["[0]" random {"+" Random}]
- [number
+ ["[0]" random {"+" Random} ("[1]#[0]" monad)]
+ [number {"+" hex}
+ ["[0]" i64]
["n" nat]
["i" int ("[1]#[0]" equivalence)]
["f" frac ("[1]#[0]" equivalence)]]]
@@ -652,6 +654,166 @@
false)))))
)))
+(def: expected_boolean (/.as_boolean (static.random_bit)))
+(def: expected_byte (/.as_byte (static.random_int)))
+(def: expected_short (/.as_short (static.random_int)))
+(def: expected_int (/.as_int (static.random_int)))
+(def: expected_long (/.as_long (static.random_int)))
+(def: expected_char (/.as_char (static.random_int)))
+(def: expected_float (/.as_float (static.random_frac)))
+(def: expected_double (/.as_double (static.random_frac)))
+(def: expected_string (/.as_string (static.random code.text (random.ascii/lower 2))))
+
+(`` (`` (/.export: Primitives
+ ... Constants
+ (actual_boolean boolean ..expected_boolean)
+ (actual_byte byte ..expected_byte)
+ (actual_short short ..expected_short)
+ (actual_int int ..expected_int)
+ (actual_long long ..expected_long)
+ (actual_char char ..expected_char)
+ (actual_float float ..expected_float)
+ (actual_double double ..expected_double)
+
+ ... Methods
+ (~~ (template [<type> <+>]
+ [(((~~ (template.symbol [<type> "_method"]))
+ [left <type>
+ right <type>])
+ <type>
+ ((~~ (template.symbol [/._] ["as_" <type>]))
+ (<+> ((~~ (template.symbol [/._] ["of_" <type>])) left)
+ ((~~ (template.symbol [/._] ["of_" <type>])) right))))]
+
+ [boolean and]
+ [byte i.+]
+ [short i.+]
+ [int i.+]
+ [long i.+]
+ [char i.+]
+ [float f.+]
+ [double f.+]
+ ))
+ )))
+
+(`` (`` (/.import: Primitives
+ ["[1]::[0]"
+ ("static" actual_boolean boolean)
+ ("static" actual_byte byte)
+ ("static" actual_short short)
+ ("static" actual_int int)
+ ("static" actual_long long)
+ ("static" actual_char char)
+ ("static" actual_float float)
+ ("static" actual_double double)
+
+ (~~ (template [<type>]
+ [("static" (~~ (template.symbol [<type> "_method"])) [<type> <type>] <type>)]
+
+ [boolean]
+ [byte]
+ [short]
+ [int]
+ [long]
+ [char]
+ [float]
+ [double]
+ ))
+ ])))
+
+(/.export: Objects
+ (actual_string java/lang/String ..expected_string)
+
+ ((string_method [left java/lang/String right java/lang/String])
+ java/lang/String
+ (/.as_string (%.format (/.of_string left) (/.of_string right))))
+
+ (([a] left [left a right a]) a left)
+ (([a] right [left a right a]) a right))
+
+(/.import: Objects
+ ["[1]::[0]"
+ ("static" actual_string java/lang/String)
+
+ ("static" string_method [java/lang/String java/lang/String] java/lang/String)
+
+ ("static" [a] left [a a] a)
+ ("static" [a] right [a a] a)])
+
+(def: tiny_int
+ (Random Int)
+ (random#each (|>> (i64.and (hex "F")) .int)
+ random.nat))
+
+(def: tiny_frac
+ (Random Frac)
+ (random#each (|>> (i64.and (hex "FFFF"))
+ .int
+ i.frac)
+ random.nat))
+
+(`` (`` (def: test|export
+ Test
+ (do [! random.monad]
+ [(~~ (template [<type> <as> <random>]
+ [(~~ (template.symbol [left_ <type>])) (# ! each (|>> <as>) <random>)
+ (~~ (template.symbol [right_ <type>])) (# ! each (|>> <as>) <random>)]
+
+ [boolean /.as_boolean random.bit]
+ [byte /.as_byte ..tiny_int]
+ [short /.as_short ..tiny_int]
+ [int /.as_int ..tiny_int]
+ [long /.as_long ..tiny_int]
+ [char /.as_char ..tiny_int]
+ [float /.as_float ..tiny_frac]
+ [double /.as_double ..tiny_frac]
+ [string /.as_string (random.ascii/lower 1)]
+ ))]
+ ($_ _.and
+ (_.cover [/.export:]
+ (and (bit#= (/.of_boolean ..expected_boolean) (/.of_boolean (Primitives::actual_boolean)))
+ (i#= (/.of_byte ..expected_byte) (/.of_byte (Primitives::actual_byte)))
+ (i#= (/.of_short ..expected_short) (/.of_short (Primitives::actual_short)))
+ (i#= (/.of_int ..expected_int) (/.of_int (Primitives::actual_int)))
+ (i#= (/.of_long ..expected_long) (/.of_long (Primitives::actual_long)))
+ (i#= (/.of_char ..expected_char) (/.of_char (Primitives::actual_char)))
+ (f#= (/.of_float ..expected_float) (/.of_float (Primitives::actual_float)))
+ (f#= (/.of_double ..expected_double) (/.of_double (Primitives::actual_double)))
+
+ (~~ (template [<=> <+> <type>]
+ [(with_expansions [<left> (template.symbol ["left_" <type>])
+ <right> (template.symbol ["right_" <type>])
+ <of> (template.symbol [/._] ["of_" <type>])
+ <method> (template.symbol ["Primitives::" <type> "_method"])]
+ (<=> (<+> (<of> <left>) (<of> <right>))
+ (<of> (<method> <left> <right>))))]
+
+ [bit#= and boolean]
+ [i#= i.+ byte]
+ [i#= i.+ short]
+ [i#= i.+ int]
+ [i#= i.+ long]
+ [i#= i.+ char]
+ [f#= f.+ float]
+ [f#= f.+ double]
+ ))
+
+ (text#= (/.of_string ..expected_string) (/.of_string (Objects::actual_string)))
+
+ (text#= (%.format (/.of_string left_string) (/.of_string right_string))
+ (/.of_string (Objects::string_method left_string right_string)))
+
+ (text#= (/.of_string left_string)
+ (/.of_string (Objects::left left_string right_string)))
+ (text#= (/.of_string right_string)
+ (/.of_string (Objects::right left_string right_string)))
+ (i#= (/.of_long left_long)
+ (/.of_long (Objects::left left_long right_long)))
+ (i#= (/.of_long right_long)
+ (/.of_long (Objects::right left_long right_long)))
+ ))
+ )))))
+
(def: .public test
(<| (_.covering /._)
($_ _.and
@@ -661,4 +823,5 @@
..for_interface
..for_class
..for_exception
+ ..test|export
)))