aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2021-07-18 23:10:18 -0400
committerEduardo Julian2021-07-18 23:10:18 -0400
commita40f40f230e6312ae432f06e7f73aa5945d8fa49 (patch)
tree5005ef744b01f9327c2e4df23146928f1723c495 /stdlib/source/test
parent442d1557b879a8a4bd76f441f72a17bfb71cf05f (diff)
New JVM compiler can now compile JVM interfaces.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/aedifex/metadata/artifact.lux84
-rw-r--r--stdlib/source/test/aedifex/metadata/snapshot.lux71
-rw-r--r--stdlib/source/test/aedifex/pom.lux49
-rw-r--r--stdlib/source/test/aedifex/project.lux4
-rw-r--r--stdlib/source/test/lux.lux37
-rw-r--r--stdlib/source/test/lux/target/jvm.lux48
6 files changed, 210 insertions, 83 deletions
diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux
index 5e5f67bec..5ba4bdbe4 100644
--- a/stdlib/source/test/aedifex/metadata/artifact.lux
+++ b/stdlib/source/test/aedifex/metadata/artifact.lux
@@ -9,8 +9,19 @@
[control
["." try ("#\." functor)]
[parser
- ["<.>" xml]]]
+ ["." environment]
+ ["<.>" xml]]
+ [concurrency
+ ["." promise]]]
+ [data
+ ["." maybe]
+ ["." text ("#\." equivalence)]
+ [collection
+ ["." list]]]
+ [macro
+ ["." code]]
[math
+ ["." random (#+ Random)]
[number
["n" nat]]]
["." time
@@ -19,12 +30,16 @@
["." month]
["." instant]
["." duration]]
- [math
- ["." random (#+ Random)]]
- [macro
- ["." code]]]]
+ [world
+ ["." file]
+ ["." program]]]]
[\\program
- ["." /]])
+ ["." /
+ ["/#" //
+ ["/#" // #_
+ ["#." artifact]
+ ["#." repository #_
+ ["#/." local]]]]]])
(def: #export random
(Random /.Metadata)
@@ -55,16 +70,47 @@
Test
(<| (_.covering /._)
(_.for [/.Metadata])
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence ..random))
- (do random.monad
- [expected ..random]
- (_.cover [/.format /.parser]
- (|> expected
- /.format
- list
- (<xml>.run /.parser)
- (try\map (\ /.equivalence = expected))
- (try.default false))))
- )))
+ (do random.monad
+ [expected ..random
+ #let [artifact {#///artifact.group (get@ #/.group expected)
+ #///artifact.name (get@ #/.name expected)
+ #///artifact.version (|> expected
+ (get@ #/.versions)
+ list.head
+ (maybe.default ""))}]]
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+
+ (do random.monad
+ [expected ..random]
+ (_.cover [/.format /.parser]
+ (|> expected
+ /.format
+ list
+ (<xml>.run /.parser)
+ (try\map (\ /.equivalence = expected))
+ (try.default false))))
+ (_.cover [/.uri]
+ (text\= (//.remote_project_uri artifact)
+ (/.uri artifact)))
+ (do random.monad
+ [home (random.ascii/lower 5)
+ working_directory (random.ascii/lower 5)
+ #let [program (program.async (program.mock environment.empty home working_directory))
+ fs (file.mock (\ file.default separator))
+ repository (///repository/local.repository program fs)]]
+ (wrap (do promise.monad
+ [wrote? (/.write repository artifact expected)
+ actual (/.read repository artifact)]
+ (_.cover' [/.write /.read]
+ (and (case wrote?
+ (#try.Success _) true
+ (#try.Failure _) false)
+ (case actual
+ (#try.Success actual)
+ (\ /.equivalence = expected actual)
+
+ (#try.Failure _)
+ false))))))
+ ))))
diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux
index 5a821c452..431370048 100644
--- a/stdlib/source/test/aedifex/metadata/snapshot.lux
+++ b/stdlib/source/test/aedifex/metadata/snapshot.lux
@@ -9,8 +9,19 @@
[control
["." try ("#\." functor)]
[parser
- ["<.>" xml]]]
+ ["." environment]
+ ["<.>" xml]]
+ [concurrency
+ ["." promise]]]
+ [data
+ ["." maybe]
+ ["." text ("#\." equivalence)]
+ [collection
+ ["." list]]]
+ [macro
+ ["." code]]
[math
+ ["." random (#+ Random) ("#\." monad)]
[number
["n" nat]]]
["." time
@@ -19,10 +30,9 @@
["." month]
["." instant (#+ Instant)]
["." duration]]
- [math
- ["." random (#+ Random) ("#\." monad)]]
- [macro
- ["." code]]]]
+ [world
+ ["." file]
+ ["." program]]]]
["$." /// #_
["#." artifact
["#/." type]
@@ -31,10 +41,13 @@
["#/." version]]]]
[\\program
["." /
- [///
- [artifact
- [versioning (#+ Versioning)]
- ["#." snapshot]]]]])
+ ["/#" //
+ ["/#" // #_
+ [artifact
+ [versioning (#+ Versioning)]
+ ["#." snapshot]]
+ ["#." repository #_
+ ["#/." local]]]]]])
(def: random_instant
(Random Instant)
@@ -60,7 +73,7 @@
(def: random_versioning
(Random Versioning)
($_ random.and
- (random\wrap #/snapshot.Local)
+ (random\wrap #///snapshot.Local)
$///artifact/time.random
(random.list 5 $///artifact/snapshot/version.random)
))
@@ -76,16 +89,40 @@
Test
(<| (_.covering /._)
(_.for [/.Metadata])
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence ..random))
- (do random.monad
- [expected ..random]
+ (do random.monad
+ [expected ..random
+ #let [artifact (get@ #/.artifact expected)]]
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+
(_.cover [/.format /.parser]
(|> expected
/.format
list
(<xml>.run /.parser)
(try\map (\ /.equivalence = expected))
- (try.default false))))
- )))
+ (try.default false)))
+ (_.cover [/.uri]
+ (text\= (//.remote_artifact_uri artifact)
+ (/.uri artifact)))
+ (do random.monad
+ [home (random.ascii/lower 5)
+ working_directory (random.ascii/lower 5)
+ #let [program (program.async (program.mock environment.empty home working_directory))
+ fs (file.mock (\ file.default separator))
+ repository (///repository/local.repository program fs)]]
+ (wrap (do promise.monad
+ [wrote? (/.write repository artifact expected)
+ actual (/.read repository artifact)]
+ (_.cover' [/.write /.read]
+ (and (case wrote?
+ (#try.Success _) true
+ (#try.Failure _) false)
+ (case actual
+ (#try.Success actual)
+ (\ /.equivalence = expected actual)
+
+ (#try.Failure _)
+ false))))))
+ ))))
diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux
index 24ca3c3c6..01b90c33e 100644
--- a/stdlib/source/test/aedifex/pom.lux
+++ b/stdlib/source/test/aedifex/pom.lux
@@ -10,6 +10,7 @@
["<>" parser
["<.>" xml]]]
[data
+ ["." text ("#\." equivalence)]
[format
["." xml]]]
[math
@@ -24,27 +25,33 @@
(def: #export test
Test
(<| (_.covering /._)
- (do random.monad
- [expected @profile.random]
- (_.cover [/.write /.parser]
- (case [(/.write expected)
- (get@ #//.identity expected)]
- [(#try.Success pom)
- (#.Some _)]
- (case (<xml>.run /.parser (list pom))
- (#try.Success actual)
- (\ //.equivalence =
- (|> (\ //.monoid identity)
- (set@ #//.dependencies (get@ #//.dependencies expected))
- (set@ #//.repositories (get@ #//.repositories expected)))
- actual)
+ ($_ _.and
+ (_.cover [/.file]
+ (|> /.file
+ (text\= "")
+ not))
+ (do random.monad
+ [expected @profile.random]
+ (_.cover [/.write /.parser]
+ (case [(/.write expected)
+ (get@ #//.identity expected)]
+ [(#try.Success pom)
+ (#.Some _)]
+ (case (<xml>.run /.parser (list pom))
+ (#try.Success actual)
+ (\ //.equivalence =
+ (|> (\ //.monoid identity)
+ (set@ #//.dependencies (get@ #//.dependencies expected))
+ (set@ #//.repositories (get@ #//.repositories expected)))
+ actual)
- (#try.Failure error)
- false)
+ (#try.Failure error)
+ false)
- [(#try.Failure error)
- #.None]
- (exception.match? //.no_identity error)
+ [(#try.Failure error)
+ #.None]
+ (exception.match? //.no_identity error)
- _
- false)))))
+ _
+ false)))
+ )))
diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux
index bdeee7993..5b6de5403 100644
--- a/stdlib/source/test/aedifex/project.lux
+++ b/stdlib/source/test/aedifex/project.lux
@@ -46,6 +46,10 @@
(_.for [/.monoid]
($monoid.spec /.equivalence /.monoid ..random))
+ (_.cover [/.file]
+ (|> /.file
+ (text\= "")
+ not))
(do random.monad
[[super_name super_profile] ..profile
[dummy_name dummy_profile] (random.filter (|>> product.left (text\= super_name) not)
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index 1e9976f4e..dffa24069 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -277,16 +277,20 @@
false))
)))
-(interface: (Returner a)
+(/.interface: (Returner a)
(: (-> Any a)
return))
-(implementation: (global_returner value)
+(/.implementation: (global_returner value)
(All [a] (-> a (Returner a)))
(def: (return _)
value))
+(def: static_return 123)
+
+(/.open: "global\." (..global_returner ..static_return))
+
(def: for_interface
Test
(do random.monad
@@ -301,6 +305,13 @@
(n.= expected (\ (global_returner expected) return [])))
(_.cover [/.implementation]
(n.= expected (\ local_returner return [])))
+ (_.cover [/.open:]
+ (n.= static_return (global\return [])))
+ (_.cover [/.^open]
+ (let [(/.^open "local\.") local_returner]
+ (n.= expected (local\return []))))
+ (_.cover [/.\]
+ (n.= expected (/.\ local_returner return [])))
))))
(def: for_module
@@ -587,6 +598,27 @@
false)))
)))
+(def: option/0 "0")
+(def: option/1 "1")
+(def: static_char "@")
+
+(def: for_static
+ Test
+ (do random.monad
+ [sample (random.either (wrap option/0)
+ (wrap option/1))]
+ ($_ _.and
+ (_.cover [/.static]
+ (case sample
+ (^ (/.static option/0)) true
+ (^ (/.static option/1)) true
+ _ false))
+ (_.cover [/.char]
+ (|> (`` (/.char (~~ (/.static static_char))))
+ text.from_code
+ (text\= static_char)))
+ )))
+
(def: test
Test
(<| (_.covering /._)
@@ -612,6 +644,7 @@
..for_i64
..for_function
..for_template
+ ..for_static
..sub_tests
)))
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index 3486821ce..d7d9030df 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -115,7 +115,7 @@
(list)
(list (/method.method ..method_modifier
method_name
- (/type.method [(list) ..$Object (list)])
+ (/type.method [(list) (list) ..$Object (list)])
(list)
(#.Some (do /.monad
[_ bytecode]
@@ -143,7 +143,7 @@
(def: $Boolean
(/type.class "java.lang.Boolean" (list)))
(def: $Boolean::wrap
- (/.invokestatic ..$Boolean "valueOf" (/type.method [(list /type.boolean) ..$Boolean (list)])))
+ (/.invokestatic ..$Boolean "valueOf" (/type.method [(list) (list /type.boolean) ..$Boolean (list)])))
(def: $Boolean::random (:as (Random java/lang/Boolean) random.bit))
(def: !false (|> 0 .i64 i32.i32 /.int))
(def: !true (|> 1 .i64 i32.i32 /.int))
@@ -163,7 +163,7 @@
(def: $Byte
(/type.class "java.lang.Byte" (list)))
(def: $Byte::wrap
- (/.invokestatic ..$Byte "valueOf" (/type.method [(list /type.byte) ..$Byte (list)])))
+ (/.invokestatic ..$Byte "valueOf" (/type.method [(list) (list /type.byte) ..$Byte (list)])))
(def: $Byte::random
(Random java/lang/Byte)
(\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_byte) random.int))
@@ -181,7 +181,7 @@
(def: $Short
(/type.class "java.lang.Short" (list)))
(def: $Short::wrap
- (/.invokestatic ..$Short "valueOf" (/type.method [(list /type.short) ..$Short (list)])))
+ (/.invokestatic ..$Short "valueOf" (/type.method [(list) (list /type.short) ..$Short (list)])))
(def: $Short::random
(Random java/lang/Short)
(\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_short) random.int))
@@ -199,7 +199,7 @@
(def: $Integer
(/type.class "java.lang.Integer" (list)))
(def: $Integer::wrap
- (/.invokestatic ..$Integer "valueOf" (/type.method [(list /type.int) ..$Integer (list)])))
+ (/.invokestatic ..$Integer "valueOf" (/type.method [(list) (list /type.int) ..$Integer (list)])))
(def: $Integer::random
(Random java/lang/Integer)
(\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_int) random.int))
@@ -215,7 +215,7 @@
#literal ..$Integer::literal})
(def: $Long (/type.class "java.lang.Long" (list)))
-(def: $Long::wrap (/.invokestatic ..$Long "valueOf" (/type.method [(list /type.long) ..$Long (list)])))
+(def: $Long::wrap (/.invokestatic ..$Long "valueOf" (/type.method [(list) (list /type.long) ..$Long (list)])))
(def: $Long::random (:as (Random java/lang/Long) random.int))
(def: $Long::literal (-> java/lang/Long (Bytecode Any)) (|>> (:as Int) /.long))
(def: $Long::primitive
@@ -227,7 +227,7 @@
#literal ..$Long::literal})
(def: $Float (/type.class "java.lang.Float" (list)))
-(def: $Float::wrap (/.invokestatic ..$Float "valueOf" (/type.method [(list /type.float) ..$Float (list)])))
+(def: $Float::wrap (/.invokestatic ..$Float "valueOf" (/type.method [(list) (list /type.float) ..$Float (list)])))
(def: $Float::random
(Random java/lang/Float)
(\ random.monad map
@@ -247,7 +247,7 @@
#literal ..$Float::literal})
(def: $Double (/type.class "java.lang.Double" (list)))
-(def: $Double::wrap (/.invokestatic ..$Double "valueOf" (/type.method [(list /type.double) ..$Double (list)])))
+(def: $Double::wrap (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)])))
(def: $Double::random (:as (Random java/lang/Double) random.frac))
(def: $Double::literal
(-> java/lang/Double (Bytecode Any))
@@ -267,7 +267,7 @@
(def: $Character
(/type.class "java.lang.Character" (list)))
(def: $Character::wrap
- (/.invokestatic ..$Character "valueOf" (/type.method [(list /type.char) ..$Character (list)])))
+ (/.invokestatic ..$Character "valueOf" (/type.method [(list) (list /type.char) ..$Character (list)])))
(def: $Character::random
(Random java/lang/Character)
(\ random.monad map (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int))
@@ -747,7 +747,7 @@
(do /.monad
[_ (/.new ..$Object)
_ /.dup]
- (/.invokespecial ..$Object "<init>" (/type.method [(list) /type.void (list)]))))]
+ (/.invokespecial ..$Object "<init>" (/type.method [(list) (list) /type.void (list)]))))]
($_ _.and
(<| (_.lift "ACONST_NULL")
(..bytecode (|>> (:as Bit) not))
@@ -796,7 +796,7 @@
(|>> (:as java/lang/Double) "jvm object cast" ("jvm double =" ("jvm object cast" expected)))}))
(do /.monad
[_ (/.double expected)]
- (/.invokestatic ..$Double "valueOf" (/type.method [(list /type.double) ..$Double (list)]))))
+ (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)]))))
(<| (_.lift "INVOKEVIRTUAL")
(do random.monad
[expected ..$Double::random])
@@ -804,7 +804,7 @@
(do /.monad
[_ (/.double expected)
_ ..$Double::wrap
- _ (/.invokevirtual ..$Double "isNaN" (/type.method [(list) /type.boolean (list)]))]
+ _ (/.invokevirtual ..$Double "isNaN" (/type.method [(list) (list) /type.boolean (list)]))]
..$Boolean::wrap))
(<| (_.lift "INVOKESPECIAL")
(do random.monad
@@ -819,14 +819,14 @@
[_ (/.new ..$Double)
_ /.dup
_ (/.double expected)]
- (/.invokespecial ..$Double "<init>" (/type.method [(list /type.double) /type.void (list)]))))
+ (/.invokespecial ..$Double "<init>" (/type.method [(list) (list /type.double) /type.void (list)]))))
(<| (_.lift "INVOKEINTERFACE")
(do random.monad
[subject ..$String::random])
(..bytecode (|>> (:as Nat) (n.= (text.size (:as Text subject)))))
(do /.monad
[_ (/.string (:as Text subject))
- _ (/.invokeinterface (/type.class "java.lang.CharSequence" (list)) "length" (/type.method [(list) /type.int (list)]))
+ _ (/.invokeinterface (/type.class "java.lang.CharSequence" (list)) "length" (/type.method [(list) (list) /type.int (list)]))
_ /.i2l]
..$Long::wrap))
))
@@ -848,7 +848,7 @@
class_field "class_field"
object_field "object_field"
constructor "<init>"
- constructor::type (/type.method [(list /type.long) /type.void (list)])
+ constructor::type (/type.method [(list) (list /type.long) /type.void (list)])
static_method "static_method"
bytecode (|> (/class.class /version.v6_0 /class.public
(/name.internal class_name)
@@ -862,7 +862,7 @@
(list)
(#.Some (do /.monad
[_ /.aload_0
- _ (/.invokespecial ..$Object constructor (/type.method [(list) /type.void (list)]))
+ _ (/.invokespecial ..$Object constructor (/type.method [(list) (list) /type.void (list)]))
_ (..$Long::literal part0)
_ (/.putstatic $Self class_field /type.long)
_ /.aload_0
@@ -873,7 +873,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) ..$Long (list)])
+ (/type.method [(list) (list) ..$Long (list)])
(list)
(#.Some (do /.monad
[_ (/.new $Self)
@@ -1321,7 +1321,7 @@
(do random.monad
[class_name ..class_name
primitive_method_name (random.ascii/upper 10)
- #let [primitive_method_type (/type.method [(list) (get@ #unboxed primitive) (list)])]
+ #let [primitive_method_type (/type.method [(list) (list) (get@ #unboxed primitive) (list)])]
object_method_name (|> (random.ascii/upper 10)
(random.filter (|>> (text\= primitive_method_name) not)))
expected (get@ #random primitive)
@@ -1341,7 +1341,7 @@
return)))
(/method.method ..method_modifier
object_method_name
- (/type.method [(list) (get@ #boxed primitive) (list)])
+ (/type.method [(list) (list) (get@ #boxed primitive) (list)])
(list)
(#.Some (do /.monad
[_ (/.invokestatic $Self primitive_method_name primitive_method_type)
@@ -1433,7 +1433,7 @@
(do /.monad
[_ (/.new ..$Object)
_ /.dup]
- (/.invokespecial ..$Object "<init>" (/type.method [(list) /type.void (list)]))))
+ (/.invokespecial ..$Object "<init>" (/type.method [(list) (list) /type.void (list)]))))
reference_comparison ($_ _.and
(_.lift "IF_ACMPEQ" (if! /.if_acmpeq (do /.monad [_ new_object] /.dup)))
(_.lift "IF_ACMPNE" (if! /.if_acmpne (do /.monad [_ new_object] new_object)))
@@ -1543,7 +1543,7 @@
_ (/.new $Exception)
_ /.dup
_ (..$String::literal exception)
- _ (/.invokespecial $Exception "<init>" (/type.method [(list ..$String) /type.void (list)]))
+ _ (/.invokespecial $Exception "<init>" (/type.method [(list) (list ..$String) /type.void (list)]))
_ /.athrow
_ (/.set_label @skipped)
_ (..$Long::literal dummy)
@@ -1606,8 +1606,8 @@
$Abstract (/type.class abstract_class (list))
$Interface (/type.class interface_class (list))
- constructor::type (/type.method [(list) /type.void (list)])
- method::type (/type.method [(list) /type.long (list)])
+ constructor::type (/type.method [(list) (list) /type.void (list)])
+ method::type (/type.method [(list) (list) /type.long (list)])
inherited_method "inherited_method"
overriden_method "overriden_method"
@@ -1682,7 +1682,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) ..$Long (list)])
+ (/type.method [(list) (list) ..$Long (list)])
(list)
(#.Some (do /.monad
[_ (/.new $Concrete)