aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/ffi.js.lux41
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux167
-rw-r--r--stdlib/source/test/lux/ffi.lua.lux26
-rw-r--r--stdlib/source/test/lux/ffi.py.lux26
-rw-r--r--stdlib/source/test/lux/ffi.rb.lux22
-rw-r--r--stdlib/source/test/lux/ffi/export.js.lux33
-rw-r--r--stdlib/source/test/lux/ffi/export.jvm.lux186
-rw-r--r--stdlib/source/test/lux/ffi/export.lua.lux33
-rw-r--r--stdlib/source/test/lux/ffi/export.py.lux33
-rw-r--r--stdlib/source/test/lux/ffi/export.rb.lux43
10 files changed, 399 insertions, 211 deletions
diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux
index a3c827d26..2b3cb7f96 100644
--- a/stdlib/source/test/lux/ffi.js.lux
+++ b/stdlib/source/test/lux/ffi.js.lux
@@ -1,23 +1,26 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [control
- ["[0]" try]]
- [data
- ["[0]" bit ("[1]#[0]" equivalence)]
- ["[0]" text ("[1]#[0]" equivalence)]]
- [math
- ["[0]" random {"+" Random}]
- [number
- ["[0]" nat]
- ["[0]" frac]]]]]
- [\\library
- ["[0]" /]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" try]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["[0]" nat]
+ ["[0]" frac]]]]]
+ [\\library
+ ["[0]" /]]
+ ["$[0]" / "_"
+ ["[1][0]" export]])
-(/.import: Uint8Array)
+(/.import: Uint8Array
+ ["[1]::[0]"])
... On Nashorn
(/.import: java/lang/String
@@ -138,4 +141,6 @@
(|> (TextDecoder::new [encoding])
(TextDecoder::decode [binary])))
))))
+
+ $/export.test
)))))
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index 9eb52d393..2a988f398 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -35,7 +35,9 @@
["[0]" jvm "_"
["[1]" type ("[1]#[0]" equivalence)]]]]]
[\\library
- ["[0]" /]])
+ ["[0]" /]]
+ ["$[0]" / "_"
+ ["[1][0]" export]])
(/.import: java/lang/Boolean)
(/.import: java/lang/Long)
@@ -654,166 +656,6 @@
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
@@ -823,5 +665,6 @@
..for_interface
..for_class
..for_exception
- ..test|export
+
+ $/export.test
)))
diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux
index e4b83e8ad..682e34763 100644
--- a/stdlib/source/test/lux/ffi.lua.lux
+++ b/stdlib/source/test/lux/ffi.lua.lux
@@ -1,15 +1,17 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [control
- ["[0]" io]]
- [math
- ["[0]" random]]]]
- [\\library
- ["[0]" /]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" io]]
+ [math
+ ["[0]" random]]]]
+ [\\library
+ ["[0]" /]]
+ ["$[0]" / "_"
+ ["[1][0]" export]])
(/.import: (os/getenv [/.String] "io" "?" /.String))
@@ -56,4 +58,6 @@
(case (io.run! (..os/getenv string))
{.#Some _} true
{.#None} true))
+
+ $/export.test
)))))
diff --git a/stdlib/source/test/lux/ffi.py.lux b/stdlib/source/test/lux/ffi.py.lux
index d2eb3f293..efa966c7d 100644
--- a/stdlib/source/test/lux/ffi.py.lux
+++ b/stdlib/source/test/lux/ffi.py.lux
@@ -1,15 +1,17 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [math
- ["[0]" random]
- [number
- ["i" int]]]]]
- [\\library
- ["[0]" /]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [math
+ ["[0]" random]
+ [number
+ ["i" int]]]]]
+ [\\library
+ ["[0]" /]]
+ ["$[0]" / "_"
+ ["[1][0]" export]])
(/.import: os
["[1]::[0]"
@@ -58,4 +60,6 @@
(_.cover [/.import:]
(and (i.= (os::R_OK) (os::R_OK))
(not (i.= (os::W_OK) (os::R_OK)))))
+
+ $/export.test
)))))
diff --git a/stdlib/source/test/lux/ffi.rb.lux b/stdlib/source/test/lux/ffi.rb.lux
index b2bc3f369..b7e488547 100644
--- a/stdlib/source/test/lux/ffi.rb.lux
+++ b/stdlib/source/test/lux/ffi.rb.lux
@@ -1,13 +1,15 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [math
- ["[0]" random]]]]
- [\\library
- ["[0]" /]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [math
+ ["[0]" random]]]]
+ [\\library
+ ["[0]" /]]
+ ["$[0]" / "_"
+ ["[1][0]" export]])
(/.import: File
["[1]::[0]"
@@ -49,4 +51,6 @@
(_.cover [/.import:]
(same? (..File::SEPARATOR)
(..File::SEPARATOR)))
+
+ $/export.test
)))))
diff --git a/stdlib/source/test/lux/ffi/export.js.lux b/stdlib/source/test/lux/ffi/export.js.lux
new file mode 100644
index 000000000..67e276b8c
--- /dev/null
+++ b/stdlib/source/test/lux/ffi/export.js.lux
@@ -0,0 +1,33 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" static]
+ [math
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //]]])
+
+(with_expansions [<nat> (static.random_nat)]
+ (/.export:
+ (def: constant
+ Nat
+ <nat>)
+ (def: shift
+ (-> Nat Nat)
+ (|>> (n.+ <nat>))))
+
+ (//.import: (constant Nat))
+ (//.import: (shift (-> Nat Nat)))
+
+ (def: .public test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.cover [/.export:]
+ (and (n.= <nat> ..constant)
+ (n.= (n.+ <nat> <nat>) (..shift <nat>))))
+ )))
+ )
diff --git a/stdlib/source/test/lux/ffi/export.jvm.lux b/stdlib/source/test/lux/ffi/export.jvm.lux
new file mode 100644
index 000000000..24ef68929
--- /dev/null
+++ b/stdlib/source/test/lux/ffi/export.jvm.lux
@@ -0,0 +1,186 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" meta]
+ ["[0]" debug]
+ ["[0]" static]
+ [abstract
+ [monad {"+" do}]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format]]]
+ [macro
+ ["[0]" code]
+ ["[0]" template]]
+ [math
+ ["[0]" random {"+" Random} ("[1]#[0]" monad)]
+ [number {"+" hex}
+ ["[0]" i64]
+ ["[0]" int ("[1]#[0]" equivalence)]
+ ["[0]" frac ("[1]#[0]" equivalence)]]]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //]]])
+
+(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 int.+]
+ [short int.+]
+ [int int.+]
+ [long int.+]
+ [char int.+]
+ [float frac.+]
+ [double frac.+]
+ ))
+ )))
+
+(`` (`` (//.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
+ int.frac)
+ random.nat))
+
+(`` (`` (def: .public test
+ Test
+ (<| (_.covering /._)
+ (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)))
+ (int#= (//.of_byte ..expected_byte) (//.of_byte (Primitives::actual_byte)))
+ (int#= (//.of_short ..expected_short) (//.of_short (Primitives::actual_short)))
+ (int#= (//.of_int ..expected_int) (//.of_int (Primitives::actual_int)))
+ (int#= (//.of_long ..expected_long) (//.of_long (Primitives::actual_long)))
+ (int#= (//.of_char ..expected_char) (//.of_char (Primitives::actual_char)))
+ (frac#= (//.of_float ..expected_float) (//.of_float (Primitives::actual_float)))
+ (frac#= (//.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]
+ [int#= int.+ byte]
+ [int#= int.+ short]
+ [int#= int.+ int]
+ [int#= int.+ long]
+ [int#= int.+ char]
+ [frac#= frac.+ float]
+ [frac#= frac.+ 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)))
+ (int#= (//.of_long left_long)
+ (//.of_long (Objects::left left_long right_long)))
+ (int#= (//.of_long right_long)
+ (//.of_long (Objects::right left_long right_long)))
+ ))
+ ))))))
diff --git a/stdlib/source/test/lux/ffi/export.lua.lux b/stdlib/source/test/lux/ffi/export.lua.lux
new file mode 100644
index 000000000..63cc558ef
--- /dev/null
+++ b/stdlib/source/test/lux/ffi/export.lua.lux
@@ -0,0 +1,33 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" static]
+ [math
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //]]])
+
+(with_expansions [<nat> (static.random_nat)]
+ (/.export:
+ (def: constant
+ Nat
+ <nat>)
+ (def: shift
+ (-> Nat Nat)
+ (|>> (n.+ <nat>))))
+
+ (//.import: (constant Nat))
+ (//.import: (shift (-> Nat Nat)))
+
+ (def: .public test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.cover [/.export:]
+ (and (n.= <nat> (..constant))
+ (n.= (n.+ <nat> <nat>) ((..shift) <nat>))))
+ )))
+ )
diff --git a/stdlib/source/test/lux/ffi/export.py.lux b/stdlib/source/test/lux/ffi/export.py.lux
new file mode 100644
index 000000000..67e276b8c
--- /dev/null
+++ b/stdlib/source/test/lux/ffi/export.py.lux
@@ -0,0 +1,33 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" static]
+ [math
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //]]])
+
+(with_expansions [<nat> (static.random_nat)]
+ (/.export:
+ (def: constant
+ Nat
+ <nat>)
+ (def: shift
+ (-> Nat Nat)
+ (|>> (n.+ <nat>))))
+
+ (//.import: (constant Nat))
+ (//.import: (shift (-> Nat Nat)))
+
+ (def: .public test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.cover [/.export:]
+ (and (n.= <nat> ..constant)
+ (n.= (n.+ <nat> <nat>) (..shift <nat>))))
+ )))
+ )
diff --git a/stdlib/source/test/lux/ffi/export.rb.lux b/stdlib/source/test/lux/ffi/export.rb.lux
new file mode 100644
index 000000000..0ceaf7e00
--- /dev/null
+++ b/stdlib/source/test/lux/ffi/export.rb.lux
@@ -0,0 +1,43 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" static]
+ [math
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //]]])
+
+(with_expansions [<nat> (static.random_nat)]
+ (/.export:
+ (def: nullary
+ Nat
+ <nat>)
+ (def: unary
+ (-> Nat Nat)
+ (|>> (n.+ <nat>)))
+ (def: CONSTANT
+ Nat
+ <nat>)
+ (def: $global
+ (-> Nat Nat)
+ (|>> (n.+ <nat>))))
+
+ (//.import: (nullary [] Nat))
+ (//.import: (unary [Nat] Nat))
+ (//.import: (CONSTANT Nat))
+ (//.import: ($global (-> Nat Nat)))
+
+ (def: .public test
+ Test
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.cover [/.export:]
+ (and (n.= <nat> (..nullary []))
+ (n.= (n.+ <nat> <nat>) (..unary <nat>))
+ (n.= <nat> (..CONSTANT))
+ (n.= (n.+ <nat> <nat>) ((..$global) <nat>))))
+ )))
+ )