From fb9202536a4c668f477da2d85af484800e2a3f0c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 3 Feb 2019 00:13:56 -0400 Subject: Relative imports can now alter the start of a path. --- stdlib/test/test.lux | 196 ++++++++++++++++++++++++++++++++++ stdlib/test/test/lux/cli.lux | 5 +- stdlib/test/test/lux/host.jvm.lux | 88 ++++++++------- stdlib/test/test/lux/host/jvm.jvm.lux | 55 +++++----- stdlib/test/tests.lux | 196 ---------------------------------- 5 files changed, 275 insertions(+), 265 deletions(-) create mode 100644 stdlib/test/test.lux delete mode 100644 stdlib/test/tests.lux (limited to 'stdlib/test') diff --git a/stdlib/test/test.lux b/stdlib/test/test.lux new file mode 100644 index 000000000..53efb1c05 --- /dev/null +++ b/stdlib/test/test.lux @@ -0,0 +1,196 @@ +(.module: + [lux #* + [cli (#+ program:)] + ["." io (#+ io)] + ["_" test] + + ## These modules do not need to be tested. + [type + [variance (#+)]] + [locale (#+) + [language (#+)] + [territory (#+)]] + + ## TODO: Test these modules + [data + [format + [css (#+)]]] + ## [control + ## ["._" contract] + ## ["._" concatenative] + ## ["._" predicate] + ## [monad + ## ["._" free]]] + ## [data + ## ["._" env] + ## ["._" trace] + ## ["._" store] + ## [format + ## ["._" context] + ## ["._" html] + ## ["._" css] + ## ["._" binary]] + ## [collection + ## [tree + ## [rose + ## ["._" parser]]] + ## [dictionary + ## ["._" plist]] + ## [set + ## ["._" multi]]] + ## [text + ## ["._" buffer]]] + ## ["._" macro + ## [poly + ## ["._" json]]] + ## [type + ## ["._" unit] + ## ["._" refinement] + ## ["._" quotient]] + ## [world + ## ["._" environment] + ## ["._" console]] + ## [compiler + ## [host + ## [".H" scheme]] + ## ["._" cli] + ## ["._" default + ## ["._" evaluation] + ## [phase + ## ["._" translation + ## [scheme + ## ["._scheme" primitive] + ## ["._scheme" structure] + ## ["._scheme" reference] + ## ["._scheme" function] + ## ["._scheme" loop] + ## ["._scheme" case] + ## ["._scheme" extension] + ## ["._scheme" extension/common] + ## ["._scheme" expression]]] + ## [extension + ## ["._" statement]]] + ## ["._default" cache]] + ## [meta + ## ["._meta" io + ## ["._meta_io" context] + ## ["._meta_io" archive]] + ## ["._meta" archive] + ## ["._meta" cache]]] + ## ["._" interpreter + ## ["._interpreter" type]] + ] + ## TODO: Must have 100% coverage on tests. + [/ + ["/." lux + ## [io (#+)] + ## [time + ## [instant (#+)] + ## [duration (#+)] + ## [date (#+)]] + ## [control + ## ## [exception (#+)] + ## ## [interval (#+)] + ## ## [pipe (#+)] + ## ## [continuation (#+)] + ## ## [reader (#+)] + ## ## [writer (#+)] + ## ## [state (#+)] + ## ## [parser (#+)] + ## ## [thread (#+)] + ## ## [region (#+)] + ## ## [security + ## ## [privacy (#+)] + ## ## [integrity (#+)]] + ## [concurrency + ## [actor (#+)] + ## [atom (#+)] + ## [frp (#+)] + ## [promise (#+)] + ## [stm (#+)] + ## ## [semaphore (#+)] + ## ]] + ## [data + ## [bit (#+)] + ## [color (#+)] + ## [error (#+)] + ## [name (#+)] + ## [identity (#+)] + ## [lazy (#+)] + ## [maybe (#+)] + ## [product (#+)] + ## [sum (#+)] + ## [number (#+) ## TODO: FIX Specially troublesome... + ## [i64 (#+)] + ## [ratio (#+)] + ## [complex (#+)]] + ## [text (#+) + ## ## [format (#+)] + ## [lexer (#+)] + ## [regex (#+)]] + ## [format + ## ## [json (#+)] + ## [xml (#+)]] + ## ## [collection + ## ## [array (#+)] + ## ## [bits (#+)] + ## ## [list (#+)] + ## ## [stack (#+)] + ## ## [row (#+)] + ## ## [sequence (#+)] + ## ## [dictionary (#+) + ## ## ["dictionary_." ordered]] + ## ## [set (#+) + ## ## ["set_." ordered]] + ## ## [queue (#+) + ## ## [priority (#+)]] + ## ## [tree + ## ## [rose (#+) + ## ## [zipper (#+)]]]] + ## ] + ## [math (#+) + ## [random (#+)] + ## [modular (#+)] + ## [logic + ## [continuous (#+)] + ## [fuzzy (#+)]]] + ## [macro + ## [code (#+)] + ## [syntax (#+)] + ## [poly + ## ["poly_." equivalence] + ## ["poly_." functor]]] + ## [type ## (#+) + ## ## [check (#+)] + ## ## [implicit (#+)] ## TODO: FIX Specially troublesome... + ## ## [resource (#+)] + ## [dynamic (#+)]] + ## [compiler + ## [default + ## ["_default/." syntax] + ## [phase + ## [analysis + ## ["_.A" primitive] + ## ["_.A" structure] + ## ["_.A" reference] + ## ["_.A" case] + ## ["_.A" function] + ## [procedure + ## ["_.A" common]]] + ## [synthesis + ## ["_.S" primitive] + ## ["_.S" structure] + ## ["_.S" case] + ## ["_.S" function]]]]] + ## [world + ## [binary (#+)] + ## [file (#+)] + ## [net + ## [tcp (#+)] + ## [udp (#+)]]] + ]] + ) + +(program: args + (io (_.run! (<| (_.times 100) + /lux.test)))) diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux index bf7bc72a7..7c50a679b 100644 --- a/stdlib/test/test/lux/cli.lux +++ b/stdlib/test/test/lux/cli.lux @@ -13,8 +13,9 @@ ["." list]]] [math ["r" random]] - ["/" cli] - ["_" test (#+ Test)]]) + ["_" test (#+ Test)]] + {[-1 ""] + ["." /]}) (def: #export test Test diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index c3dcf6791..f1151f010 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -5,10 +5,11 @@ pipe] [data [text ("text/." Equivalence)]] - ["&" host (#+ import: class: interface: object)] [math ["r" random]] - ["_" test (#+ Test)]]) + ["_" test (#+ Test)]] + {[-1 ""] + ["." / (#+ import: class: interface: object)]}) (import: (java/util/concurrent/Callable a)) @@ -58,7 +59,8 @@ (interface: TestInterface ([] foo [boolean String] void #throws [Exception])) -(def: conversions Test +(def: conversions + Test (do r.Monad [sample r.int] (`` ($_ _.and @@ -68,55 +70,59 @@ (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."] + [/.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 - ($_ _.and - (_.test "Can check if an object is of a certain class." - (and (case (&.check String "") (#.Some _) true #.None false) - (case (&.check Long "") (#.Some _) false #.None true) - (case (&.check Object "") (#.Some _) true #.None false) - (case (&.check Object (&.null)) (#.Some _) false #.None true))) - - (_.test "Can run code in a 'synchronized' block." - (&.synchronized "" #1)) - - (_.test "Can access Class instances." - (text/= "java.lang.Class" (Class::getName (&.class-for java/lang/Class)))) - - (_.test "Can check if a value is null." - (and (&.null? (&.null)) - (not (&.null? "")))) - - (_.test "Can safely convert nullable references into Maybe values." - (and (|> (: (Maybe Object) (&.??? (&.null))) - (case> #.None #1 - _ #0)) - (|> (: (Maybe Object) (&.??? "")) - (case> (#.Some _) #1 - _ #0)))) - )) - -(def: arrays Test +(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 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))) + + (_.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)))) + + (_.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))) + (case> #.None #1 + _ #0)) + (|> (: (Maybe 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 Long size)))) + (n/= size (/.array-length (/.array Long size)))) (_.test "Can set and get array values." - (let [arr (&.array Long size)] - (exec (&.array-write idx value arr) - (i/= value (&.array-read idx arr)))))))) + (let [arr (/.array Long size)] + (exec (/.array-write idx value arr) + (i/= value (/.array-read idx arr)))))))) (def: #export test ($_ _.and diff --git a/stdlib/test/test/lux/host/jvm.jvm.lux b/stdlib/test/test/lux/host/jvm.jvm.lux index caa3efd1f..bacfd480b 100644 --- a/stdlib/test/test/lux/host/jvm.jvm.lux +++ b/stdlib/test/test/lux/host/jvm.jvm.lux @@ -17,19 +17,19 @@ [world ["." file (#+ File)] [binary (#+ Binary)]] - [host - [jvm - ["/." loader (#+ Library)] - ["/." version] - ["/." name] - ["/." descriptor] - ["/." field] - ["/." class] - [modifier - ["/.M" inner]]]] [math ["r" random]] - ["_" test (#+ Test)]]) + ["_" test (#+ Test)]] + {[-1 ""] + [/ + ["/." loader (#+ Library)] + ["/." version] + ["/." name] + ["/." descriptor] + ["/." field] + ["/." class] + [modifier + ["/.M" inner]]]}) (def: (write-class! name bytecode) (-> Text Binary (IO Text)) @@ -46,21 +46,24 @@ (#error.Failure error) error))))) -(def: class Test - (let [package "my.package" - name "MyClass" - full-name (format package "." name) - input (/class.class /version.v6_0 /class.public - (/name.internal "java.lang.Object") - (/name.internal full-name) - (list (/name.internal "java.io.Serializable") - (/name.internal "java.lang.Runnable")) - (list (/field.field /field.public "foo" /descriptor.long (row.row)) - (/field.field /field.public "bar" /descriptor.double (row.row))) - (row.row) - (row.row)) - bytecode (binary.write /class.format input) - loader (/loader.memory (/loader.new-library []))] +(def: class + Test + (do r.Monad + [_ (wrap []) + #let [package "my.package" + name "MyClass" + full-name (format package "." name) + input (/class.class /version.v6_0 /class.public + (/name.internal "java.lang.Object") + (/name.internal full-name) + (list (/name.internal "java.io.Serializable") + (/name.internal "java.lang.Runnable")) + (list (/field.field /field.public "foo" /descriptor.long (row.row)) + (/field.field /field.public "bar" /descriptor.double (row.row))) + (row.row) + (row.row)) + bytecode (binary.write /class.format input) + loader (/loader.memory (/loader.new-library []))]] ($_ _.and (_.test "Can read a generated class." (case (binary.read /class.format bytecode) diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux deleted file mode 100644 index 5c7838634..000000000 --- a/stdlib/test/tests.lux +++ /dev/null @@ -1,196 +0,0 @@ -(.module: - [lux #* - [cli (#+ program:)] - ["." io (#+ io)] - ["_" test] - - ## These modules do not need to be tested. - [type - [variance (#+)]] - [locale (#+) - [language (#+)] - [territory (#+)]] - - ## TODO: Test these modules - [data - [format - [css (#+)]]] - ## [control - ## ["._" contract] - ## ["._" concatenative] - ## ["._" predicate] - ## [monad - ## ["._" free]]] - ## [data - ## ["._" env] - ## ["._" trace] - ## ["._" store] - ## [format - ## ["._" context] - ## ["._" html] - ## ["._" css] - ## ["._" binary]] - ## [collection - ## [tree - ## [rose - ## ["._" parser]]] - ## [dictionary - ## ["._" plist]] - ## [set - ## ["._" multi]]] - ## [text - ## ["._" buffer]]] - ## ["._" macro - ## [poly - ## ["._" json]]] - ## [type - ## ["._" unit] - ## ["._" refinement] - ## ["._" quotient]] - ## [world - ## ["._" environment] - ## ["._" console]] - ## [compiler - ## [host - ## [".H" scheme]] - ## ["._" cli] - ## ["._" default - ## ["._" evaluation] - ## [phase - ## ["._" translation - ## [scheme - ## ["._scheme" primitive] - ## ["._scheme" structure] - ## ["._scheme" reference] - ## ["._scheme" function] - ## ["._scheme" loop] - ## ["._scheme" case] - ## ["._scheme" extension] - ## ["._scheme" extension/common] - ## ["._scheme" expression]]] - ## [extension - ## ["._" statement]]] - ## ["._default" cache]] - ## [meta - ## ["._meta" io - ## ["._meta_io" context] - ## ["._meta_io" archive]] - ## ["._meta" archive] - ## ["._meta" cache]]] - ## ["._" interpreter - ## ["._interpreter" type]] - ] - ## TODO: Must have 100% coverage on tests. - [test - ["/." lux - ## [io (#+)] - ## [time - ## [instant (#+)] - ## [duration (#+)] - ## [date (#+)]] - ## [control - ## ## [exception (#+)] - ## ## [interval (#+)] - ## ## [pipe (#+)] - ## ## [continuation (#+)] - ## ## [reader (#+)] - ## ## [writer (#+)] - ## ## [state (#+)] - ## ## [parser (#+)] - ## ## [thread (#+)] - ## ## [region (#+)] - ## ## [security - ## ## [privacy (#+)] - ## ## [integrity (#+)]] - ## [concurrency - ## [actor (#+)] - ## [atom (#+)] - ## [frp (#+)] - ## [promise (#+)] - ## [stm (#+)] - ## ## [semaphore (#+)] - ## ]] - ## [data - ## [bit (#+)] - ## [color (#+)] - ## [error (#+)] - ## [name (#+)] - ## [identity (#+)] - ## [lazy (#+)] - ## [maybe (#+)] - ## [product (#+)] - ## [sum (#+)] - ## [number (#+) ## TODO: FIX Specially troublesome... - ## [i64 (#+)] - ## [ratio (#+)] - ## [complex (#+)]] - ## [text (#+) - ## ## [format (#+)] - ## [lexer (#+)] - ## [regex (#+)]] - ## [format - ## ## [json (#+)] - ## [xml (#+)]] - ## ## [collection - ## ## [array (#+)] - ## ## [bits (#+)] - ## ## [list (#+)] - ## ## [stack (#+)] - ## ## [row (#+)] - ## ## [sequence (#+)] - ## ## [dictionary (#+) - ## ## ["dictionary_." ordered]] - ## ## [set (#+) - ## ## ["set_." ordered]] - ## ## [queue (#+) - ## ## [priority (#+)]] - ## ## [tree - ## ## [rose (#+) - ## ## [zipper (#+)]]]] - ## ] - ## [math (#+) - ## [random (#+)] - ## [modular (#+)] - ## [logic - ## [continuous (#+)] - ## [fuzzy (#+)]]] - ## [macro - ## [code (#+)] - ## [syntax (#+)] - ## [poly - ## ["poly_." equivalence] - ## ["poly_." functor]]] - ## [type ## (#+) - ## ## [check (#+)] - ## ## [implicit (#+)] ## TODO: FIX Specially troublesome... - ## ## [resource (#+)] - ## [dynamic (#+)]] - ## [compiler - ## [default - ## ["_default/." syntax] - ## [phase - ## [analysis - ## ["_.A" primitive] - ## ["_.A" structure] - ## ["_.A" reference] - ## ["_.A" case] - ## ["_.A" function] - ## [procedure - ## ["_.A" common]]] - ## [synthesis - ## ["_.S" primitive] - ## ["_.S" structure] - ## ["_.S" case] - ## ["_.S" function]]]]] - ## [world - ## [binary (#+)] - ## [file (#+)] - ## [net - ## [tcp (#+)] - ## [udp (#+)]]] - ]] - ) - -(program: args - (io (_.run! (<| (_.times 100) - /lux.test)))) -- cgit v1.2.3