diff options
author | Eduardo Julian | 2020-10-09 23:11:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-10-09 23:11:38 -0400 |
commit | befa21cea76282f8cd3509e0a7da1bdffd353101 (patch) | |
tree | 9f671c8a86ca43bcccb8105a668a271e72ef06ea /stdlib/source/test | |
parent | bae39f32cddb816a6123697269c20dbf4a65ac19 (diff) |
Mandatory long names for JVM imports, instead of having "long" be optional and short be default.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/aedifex.lux | 2 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/artifact.lux | 30 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/profile.lux | 14 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/json.lux | 8 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/product.lux | 64 | ||||
-rw-r--r-- | stdlib/source/test/lux/host.jvm.lux | 16 | ||||
-rw-r--r-- | stdlib/source/test/lux/host.old.lux | 55 | ||||
-rw-r--r-- | stdlib/source/test/lux/target/jvm.lux | 24 |
8 files changed, 143 insertions, 70 deletions
diff --git a/stdlib/source/test/aedifex.lux b/stdlib/source/test/aedifex.lux index 8699ad8b9..de52e6a9e 100644 --- a/stdlib/source/test/aedifex.lux +++ b/stdlib/source/test/aedifex.lux @@ -6,6 +6,7 @@ [parser [cli (#+ program:)]]]] ["." / #_ + ["#." artifact] ["#." profile] ["#." cli] ["#." parser]]) @@ -13,6 +14,7 @@ (def: test Test ($_ _.and + /artifact.test /profile.test /cli.test /parser.test diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux new file mode 100644 index 000000000..1ba27d0b6 --- /dev/null +++ b/stdlib/source/test/aedifex/artifact.lux @@ -0,0 +1,30 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + [hash (#+ Hash)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [math + ["." random (#+ Random)]]] + {#program + ["." /]}) + +(def: #export random + (Random /.Artifact) + ($_ random.and + (random.ascii/alpha 1) + (random.ascii/alpha 1) + (random.ascii/alpha 1))) + +(def: #export test + Test + (<| (_.covering /._) + (_.with-cover [/.Group /.Name /.Version + /.Artifact] + ($_ _.and + (_.with-cover [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + )))) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 3f1e08cc7..94f695a9b 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -22,10 +22,11 @@ ["." dictionary (#+ Dictionary)]]] [math ["." random (#+ Random) ("#@." monad)]]] + [// + ["@." artifact]] {#program ["." / ["/#" // #_ - ["#." artifact (#+ Artifact)] ["#." dependency (#+ Repository Dependency)] ["#." format]]]}) @@ -100,13 +101,6 @@ (Random /.Name) (random.ascii/alpha 1)) -(def: artifact - (Random Artifact) - ($_ random.and - (random.ascii/alpha 1) - (random.ascii/alpha 1) - (random.ascii/alpha 1))) - (def: repository (Random Repository) (random.ascii/alpha 1)) @@ -114,7 +108,7 @@ (def: dependency (Random Dependency) ($_ random.and - ..artifact + @artifact.random (random.ascii/alpha 1))) (def: source @@ -129,7 +123,7 @@ (Random /.Profile) ($_ random.and (..list-of ..name) - (random.maybe ..artifact) + (random.maybe @artifact.random) (random.maybe ..info) (..set-of text.hash ..repository) (..set-of //dependency.hash ..dependency) diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index dbda12366..e3311f505 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -35,6 +35,10 @@ _ false)) +(def: safe-frac + (Random Frac) + (random.filter (|>> frac.not-a-number? not) random.frac)) + (def: #export test Test (<| (_.covering /._) @@ -70,7 +74,7 @@ (!expect (#try.Failure _)))))))] [/.boolean /.boolean? /.boolean! random.bit #json.Boolean bit.equivalence] - [/.number /.number? /.number! random.frac #json.Number frac.equivalence] + [/.number /.number? /.number! ..safe-frac #json.Number frac.equivalence] [/.string /.string? /.string! (random.unicode 1) #json.String text.equivalence] )) (do {@ random.monad} @@ -118,7 +122,7 @@ (exception.match? /.empty-input error))))) (do {@ random.monad} [expected-boolean random.bit - expected-number random.frac + expected-number ..safe-frac expected-string (random.unicode 1) [boolean-field number-field string-field] (|> (random.set text.hash 3 (random.unicode 3)) (:: @ map (|>> set.to-list diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index 7c962804b..20e62ef86 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -1,23 +1,61 @@ (.module: [lux #* ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] [data - ["%" text/format (#+ format)] [number - ["i" int]]]] + ["n" nat] + ["i" int]]] + [math + ["." random]]] {1 ["." /]}) (def: #export test Test - (<| (_.context (%.name (name-of .&))) - ($_ _.and - (_.test "Can access the sides of a pair." - (and (i.= +1 (/.left [+1 +2])) - (i.= +2 (/.right [+1 +2])))) - - (_.test "Can swap the sides of a pair." - (let [[_left _right] (/.swap [+1 +2])] - (and (i.= +2 _left) - (i.= +1 _right)))) - ))) + (<| (_.covering /._) + (do random.monad + [expected random.nat + shift random.nat + dummy (random.filter (|>> (n.= expected) not) + random.nat)] + ($_ _.and + (_.with-cover [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence i.equivalence) + (random.and random.nat random.int))) + + (<| (_.cover [/.left]) + (n.= expected (/.left [expected dummy]))) + (<| (_.cover [/.right]) + (n.= expected (/.right [dummy expected]))) + (<| (_.cover [/.fork]) + (let [[left right] ((/.fork (n.+ shift) (n.- shift)) expected)] + (and (n.= (n.+ shift expected) + left) + (n.= (n.- shift expected) + right)))) + (do random.monad + [left random.nat + right random.nat] + ($_ _.and + (<| (_.cover [/.swap]) + (let [pair [left right]] + (and (n.= (/.left pair) + (/.right (/.swap pair))) + (n.= (/.right pair) + (/.left (/.swap pair)))))) + (<| (_.cover [/.uncurry]) + (n.= (n.+ left right) + ((/.uncurry n.+) [left right]))) + (<| (_.cover [/.curry]) + (n.= (n.+ left right) + ((/.curry (/.uncurry n.+)) left right))) + (<| (_.cover [/.both]) + (let [[left' right'] (/.both (n.+ shift) (n.- shift) [left right])] + (and (n.= (n.+ shift left) left') + (n.= (n.- shift right) right')))))) + )))) diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux index 65011a929..d5b44b481 100644 --- a/stdlib/source/test/lux/host.jvm.lux +++ b/stdlib/source/test/lux/host.jvm.lux @@ -14,23 +14,23 @@ {1 ["." / (#+ import: class: interface: object)]}) -(import: #long (java/util/concurrent/Callable a)) +(import: (java/util/concurrent/Callable a)) -(import: #long java/lang/Long) +(import: java/lang/Long) -(import: #long java/lang/String) +(import: java/lang/String) -(import: #long java/lang/Exception +(import: java/lang/Exception (new [java/lang/String])) -(import: #long java/lang/Object) +(import: java/lang/Object) -(import: #long (java/lang/Class a) +(import: (java/lang/Class a) (getName [] java/lang/String)) -(import: #long java/lang/Runnable) +(import: java/lang/Runnable) -(import: #long java/lang/System +(import: java/lang/System (#static out java/io/PrintStream) (#static currentTimeMillis [] #io long) (#static getenv [java/lang/String] #io #? java/lang/String)) diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux index e297c1411..457caee6a 100644 --- a/stdlib/source/test/lux/host.old.lux +++ b/stdlib/source/test/lux/host.old.lux @@ -16,20 +16,23 @@ (import: (java/util/concurrent/Callable a)) +(import: java/lang/Object) +(import: java/lang/String) + (import: java/lang/Exception - (new [String])) + (new [java/lang/String])) -(import: java/lang/Object) +(import: java/lang/Runnable) (import: (java/lang/Class a) - (getName [] String)) + (getName [] java/lang/String)) (import: java/lang/System (#static out java/io/PrintStream) (#static currentTimeMillis [] #io long) - (#static getenv [String] #io #? String)) + (#static getenv [java/lang/String] #io #? java/lang/String)) -(class: #final (TestClass A) [Runnable] +(class: #final (TestClass A) [java/lang/Runnable] ## Fields (#private foo boolean) (#private bar A) @@ -44,23 +47,23 @@ "") (#public #static (static) java/lang/Object "") - (Runnable [] (run self) void - [])) + (java/lang/Runnable [] (run self) void + [])) (def: test-runnable - (object [] [Runnable] + (object [] [java/lang/Runnable] [] - (Runnable [] (run self) void - []))) + (java/lang/Runnable [] (run self) void + []))) (def: test-callable - (object [a] [(Callable a)] + (object [a] [(java/util/concurrent/Callable a)] [] - (Callable [] (call self) a - (undefined)))) + (java/util/concurrent/Callable [] (call self) a + (undefined)))) (interface: TestInterface - ([] foo [boolean String] void #throws [Exception])) + ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) (def: conversions Test @@ -88,26 +91,26 @@ [sample (r.ascii 1)] ($_ _.and (_.test "Can check if an object is of a certain class." - (and (case (/.check String sample) (#.Some _) true #.None false) - (case (/.check Long sample) (#.Some _) false #.None true) - (case (/.check Object sample) (#.Some _) true #.None false) - (case (/.check Object (/.null)) (#.Some _) false #.None true))) + (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" (Class::getName (/.class-for java/lang/Class)))) + (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 Object) (/.??? (/.null))) + (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) (case> #.None #1 _ #0)) - (|> (: (Maybe Object) (/.??? sample)) + (|> (: (Maybe java/lang/Object) (/.??? sample)) (case> (#.Some _) #1 _ #0)))) ))) @@ -120,12 +123,13 @@ value r.int] ($_ _.and (_.test "Can create arrays of some length." - (n.= size (/.array-length (/.array Long size)))) + (n.= size (/.array-length (/.array java/lang/Long size)))) (_.test "Can set and get array values." - (let [arr (/.array Long size)] + (let [arr (/.array java/lang/Long size)] (exec (/.array-write idx value arr) - (i.= value (/.array-read idx arr)))))))) + (i.= value (/.array-read idx arr))))) + ))) (def: #export test ($_ _.and @@ -134,4 +138,5 @@ (<| (_.context "Miscellaneous.") ..miscellaneous) (<| (_.context "Arrays.") - ..arrays))) + ..arrays) + )) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 26d3cb42f..28ea97944 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -58,24 +58,24 @@ /method.public /method.static)) -(import: #long java/lang/Boolean) -(import: #long java/lang/Byte) -(import: #long java/lang/Short) -(import: #long java/lang/Integer) -(import: #long java/lang/Long) -(import: #long java/lang/Float) -(import: #long java/lang/Double +(import: java/lang/Boolean) +(import: java/lang/Byte) +(import: java/lang/Short) +(import: java/lang/Integer) +(import: java/lang/Long) +(import: java/lang/Float) +(import: java/lang/Double (#static compare [double double] int)) -(import: #long java/lang/Character) -(import: #long java/lang/String) +(import: java/lang/Character) +(import: java/lang/String) -(import: #long java/lang/reflect/Method +(import: java/lang/reflect/Method (invoke [java/lang/Object [java/lang/Object]] #try java/lang/Object)) -(import: #long (java/lang/Class c) +(import: (java/lang/Class c) (getDeclaredMethod [java/lang/String [(java/lang/Class [? < java/lang/Object])]] java/lang/reflect/Method)) -(import: #long java/lang/Object +(import: java/lang/Object (getClass [] (java/lang/Class java/lang/Object)) (toString [] java/lang/String)) |