diff options
Diffstat (limited to 'stdlib/source/test')
| -rw-r--r-- | stdlib/source/test/lux.lux | 3 | ||||
| -rw-r--r-- | stdlib/source/test/lux/control/maybe.lux | 3 | ||||
| -rw-r--r-- | stdlib/source/test/lux/data.lux | 5 | ||||
| -rw-r--r-- | stdlib/source/test/lux/data/collection/list.lux | 3 | ||||
| -rw-r--r-- | stdlib/source/test/lux/data/color.lux | 25 | ||||
| -rw-r--r-- | stdlib/source/test/lux/data/color/rgb.lux | 128 | ||||
| -rw-r--r-- | stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux | 4 | ||||
| -rw-r--r-- | stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux | 10 | ||||
| -rw-r--r-- | stdlib/source/test/lux/meta/extension.lux | 124 | ||||
| -rw-r--r-- | stdlib/source/test/lux/meta/type.lux | 4 | ||||
| -rw-r--r-- | stdlib/source/test/lux/meta/type/linear.lux (renamed from stdlib/source/test/lux/meta/type/resource.lux) | 0 | 
11 files changed, 223 insertions, 86 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 916f1dbc2..29e2725cf 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -895,7 +895,8 @@       item/1 random.nat       item/2 random.nat]      (all _.and -         (_.coverage [/.Either] +         (_.coverage [/.Either +                      /.#Left /.#Right]             (and (exec                    (is (/.Either Nat Text)                        {.#Left left}) diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index d99622737..7ff61a642 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -29,7 +29,8 @@  (def .public test    Test    (<| (_.covering /._) -      (_.for [.Maybe]) +      (_.for [.Maybe +              .#None .#Some])        (all _.and             (_.for [/.equivalence]                    ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat))) diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index b242a4582..74432550a 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -10,8 +10,7 @@   ["[0]" /    ["[1][0]" binary]    ["[1][0]" bit] -  ["[1][0]" color (.only) -   ["[1]/[0]" named]] +  ["[1][0]" color]    ["[1][0]" identity]    ["[1][0]" product]    ["[1][0]" sum] @@ -44,7 +43,7 @@         /binary.test         /bit.test         /color.test -       /color/named.test)) +       ))  (def test/1    Test diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index f32a5c3d5..3b079d53d 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -415,7 +415,8 @@  (def .public test    Test    (<| (_.covering /._) -      (_.for [.List]) +      (_.for [.List +              .#End .#Item])        (let [(open "/#[0]") (/.equivalence n.equivalence)              (open "/#[0]") /.functor]          (do [! random.monad] diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index e098211cb..c56352d3d 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -11,7 +11,7 @@      [collection       ["[0]" list]]]     [math -    ["[0]" random (.only Random)] +    ["[0]" random (.only Random) (.use "[1]#[0]" functor)]      [number       ["n" nat]       ["f" frac] @@ -20,12 +20,15 @@     [test      ["_" property (.only Test)]]]]   [\\library -  ["[0]" /]]) +  ["[0]" / (.only) +   ["[0]" rgb]]] + ["[0]" / +  ["[1][0]" rgb] +  ["[1][0]" named]])  (def .public random    (Random /.Color) -  (|> (all random.and random.nat random.nat random.nat) -      (at random.monad each /.of_rgb))) +  (random#each /.of_rgb /rgb.random))  (def scale    (-> Nat Frac) @@ -51,11 +54,12 @@          [tr tg tb] (/.rgb to)]      (square_root       (all f.+ -          (|> (scale tr) (f.- (scale fr)) square) -          (|> (scale tg) (f.- (scale fg)) square) -          (|> (scale tb) (f.- (scale fb)) square))))) +          (|> (scale (rgb.number tr)) (f.- (scale (rgb.number fr))) square) +          (|> (scale (rgb.number tg)) (f.- (scale (rgb.number fg))) square) +          (|> (scale (rgb.number tb)) (f.- (scale (rgb.number fb))) square))))) -(def rgb_error_margin +1.8) +(def rgb_error_margin +  +1.8)  (with_template [<field>]    [(def (<field> color) @@ -70,7 +74,7 @@  (def (encoding expected)    (-> /.Color Test)    (all _.and -       (_.coverage [/.RGB /.rgb /.of_rgb] +       (_.coverage [/.rgb /.of_rgb]           (|> expected /.rgb /.of_rgb               (at /.equivalence = expected)))         (_.coverage [/.HSL /.hsl /.of_hsl] @@ -210,4 +214,7 @@                           (_.coverage [/.translucent]                             (r.= /.transparent (r.+ /.translucent /.translucent)))                           )) + +             /rgb.test +             /named.test               )))) diff --git a/stdlib/source/test/lux/data/color/rgb.lux b/stdlib/source/test/lux/data/color/rgb.lux new file mode 100644 index 000000000..5781c9efa --- /dev/null +++ b/stdlib/source/test/lux/data/color/rgb.lux @@ -0,0 +1,128 @@ +(.require + [library +  [lux (.except) +   [abstract +    [monad (.only do)] +    [\\specification +     ["[0]S" equivalence] +     ["[0]S" hash] +     ["[0]S" monoid]]] +   [control +    ["[0]" try (.use "[1]#[0]" functor)] +    ["[0]" exception]] +   [math +    ["[0]" random (.only Random) (.use "[1]#[0]" functor)] +    [number +     ["n" nat]]] +   [test +    ["_" property (.only Test)]]]] + [\\library +  ["[0]" /]]) + +(def .public value +  (Random /.Value) +  (random.one (|>> (n.% /.limit) +                   /.value +                   try.maybe) +              random.nat)) + +(def .public random +  (Random /.RGB) +  (do random.monad +    [red ..value +     green ..value +     blue ..value] +    (in [/.#red red +         /.#green green +         /.#blue blue]))) + +(def .public test +  Test +  (<| (_.covering /._) +      (do [! random.monad] +        [expected_value ..value +         expected ..random]) +      (all _.and +           (_.for [/.Value] +                  (all _.and +                       (_.coverage [/.number /.value] +                         (|> expected_value +                             /.number +                             /.value +                             (try#each (|>> /.number +                                            (n.= (/.number expected_value)))) +                             (try.else false))) +                       (_.coverage [/.limit] +                         (and (when (/.value /.limit) +                                {try.#Failure _} true +                                {try.#Success _} false) +                              (when (/.value (-- /.limit)) +                                {try.#Failure _} false +                                {try.#Success _} true))) +                       (_.coverage [/.least] +                         (when (/.value (++ (/.number /.least))) +                           {try.#Failure _} false +                           {try.#Success _} true)) +                       (_.coverage [/.most] +                         (when (/.value (-- (/.number /.most))) +                           {try.#Failure _} false +                           {try.#Success _} true)) +                       (_.coverage [/.invalid] +                         (and (when (/.value (-- (/.number /.least))) +                                {try.#Failure it} (exception.match? /.invalid it) +                                {try.#Success _} false) +                              (when (/.value (++ (/.number /.most))) +                                {try.#Failure it} (exception.match? /.invalid it) +                                {try.#Success _} false))) +                       )) +           (_.for [/.RGB] +                  (all _.and +                       (_.for [/.equivalence] +                              (equivalenceS.spec /.equivalence ..random)) +                       (_.for [/.hash] +                              (hashS.spec /.hash ..random)) +                       (_.for [/.addition] +                              (monoidS.spec /.equivalence /.addition ..random)) +                       (_.for [/.subtraction] +                              (monoidS.spec /.equivalence /.subtraction ..random)) + +                       (_.coverage [/.rgb] +                         (`` (and (let [red (/.number expected_value) +                                        green (/.number expected_value) +                                        blue (/.number expected_value)] +                                    (when (/.rgb red green blue) +                                      {try.#Failure _} +                                      false +                                       +                                      {try.#Success it} +                                      (and (n.= (/.number expected_value) +                                                (/.number (the /.#red it))) +                                           (n.= (/.number expected_value) +                                                (/.number (the /.#green it))) +                                           (n.= (/.number expected_value) +                                                (/.number (the /.#blue it)))))) +                                  (,, (with_template [<red_offset> <green_offset> <blue_offset>] +                                        [(let [red (n.+ <red_offset> (/.number expected_value)) +                                               green (n.+ <green_offset> (/.number expected_value)) +                                               blue (n.+ <blue_offset> (/.number expected_value))] +                                           (when (/.rgb red green blue) +                                             {try.#Failure it} +                                             (exception.match? /.invalid it) +                                              +                                             {try.#Success _} +                                             false))] + +                                        [/.limit 0 0] +                                        [0 /.limit 0] +                                        [0 0 /.limit] +                                        ))))) +                       (_.coverage [/.complement] +                         (let [~expected (/.complement expected) +                               (open "/#[0]") /.equivalence] +                           (and (not (/#= expected ~expected)) +                                (/#= expected (/.complement ~expected))))) +                       (_.coverage [/.black /.white] +                         (and (at /.equivalence = /.white (/.complement /.black)) +                              (at /.equivalence = /.black (/.complement /.white)))) +                       )) +           ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux index a12f284a3..ca7bb0c3b 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/synthesis/primitive.lux @@ -77,9 +77,9 @@    Test    (<| (_.context (%.symbol (symbol ////synthesis.#Primitive)))        (`` (all _.and -               (,, (with_template [<analysis> <synthesis> <generator>] +               (,, (with_template [<analysis> <synthesis> <translator>]                       [(do r.monad -                        [expected <generator>] +                        [expected <translator>]                          (_.test (%.symbol (symbol <synthesis>))                            (|> {////analysis.#Primitive {<analysis> expected}}                                (//.phase archive.empty) diff --git a/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux index 2097736ad..57ce1b585 100644 --- a/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux +++ b/stdlib/source/test/lux/meta/compiler/meta/archive/registry.lux @@ -114,8 +114,8 @@                         [/.definition (is category.Definition [expected_name {.#None}]) /.definitions category.#Definition /.analyser expected_name]                         [/.analyser expected_name /.analysers category.#Analyser /.synthesizer expected_name] -                       [/.synthesizer expected_name /.synthesizers category.#Synthesizer /.generator expected_name] -                       [/.generator expected_name /.generators category.#Generator /.declaration expected_name] +                       [/.synthesizer expected_name /.synthesizers category.#Synthesizer /.translator expected_name] +                       [/.translator expected_name /.translators category.#Translator /.declaration expected_name]                         [/.declaration expected_name /.declarations category.#Declaration /.custom expected_name]                         [/.custom expected_name /.customs category.#Custom /.definition (is category.Definition [expected_name {.#None}])]                         )) @@ -130,7 +130,7 @@                                [/.definition (is category.Definition [expected_name {.#None}]) product.left]                                [/.analyser expected_name |>]                                [/.synthesizer expected_name |>] -                              [/.generator expected_name |>] +                              [/.translator expected_name |>]                                [/.declaration expected_name |>]                                [/.custom expected_name |>]                                )))) @@ -155,7 +155,7 @@                                                                                                  [it {.#None}]))]                                [/.analyser /.analysers text.equivalence (|>>)]                                [/.synthesizer /.synthesizers text.equivalence (|>>)] -                              [/.generator /.generators text.equivalence (|>>)] +                              [/.translator /.translators text.equivalence (|>>)]                                [/.declaration /.declarations text.equivalence (|>>)]                                [/.custom /.customs text.equivalence (|>>)]                                )))) @@ -174,7 +174,7 @@                                [/.definition (is category.Definition [expected_name {.#None}]) product.left]                                [/.analyser expected_name |>]                                [/.synthesizer expected_name |>] -                              [/.generator expected_name |>] +                              [/.translator expected_name |>]                                [/.declaration expected_name |>]                                [/.custom expected_name |>]                                )))) diff --git a/stdlib/source/test/lux/meta/extension.lux b/stdlib/source/test/lux/meta/extension.lux index e27b0282f..1302a74fc 100644 --- a/stdlib/source/test/lux/meta/extension.lux +++ b/stdlib/source/test/lux/meta/extension.lux @@ -45,7 +45,7 @@                   ["[0]" unit]]]                 [language                  [lux -                 ["[0]" generation] +                 ["[0]" translation]                   ["[0]" declaration]                   ["[0]" analysis (.only)                    ["[0]" type] @@ -53,16 +53,16 @@                   ["[0]" synthesis (.only)                    ["<[1]>" \\parser]]                   [phase -                  [generation +                  [translation                     (.,, (.for "JVM" (.,, (.these ["[0]" jvm                                                    ["[1]/[0]" runtime]]))                                (.,, (.these))))]]]]]]               [test                ["_" property (.only Test)]]]]             [\\library -            ["[0]" / (.only analysis synthesis generation declaration)]]))) +            ["[0]" / (.only analysis synthesis translation declaration)]]))) -... Generation +... Translation  (for @.old       (these) @@ -97,57 +97,57 @@                                  [location.dummy]                                  (is analysis.Analysis))))))) -      ... Generation -      (def my_generation|generation -        Generation -        (generation (_ phase archive [pass_through <synthesis>.any]) -          (phase archive pass_through))) +      ... Translation +      (def my_translation|translation +        Translation +        (translation (_ phase archive [pass_through <synthesis>.any]) +                     (phase archive pass_through))) -      (def my_generation|synthesis +      (def my_translation|synthesis          Synthesis          (synthesis (_ phase archive [parameters (<>.some <analysis>.any)])            (let [! phase.monad]              (|> parameters                  (monad.each ! (phase archive)) -                (at ! each (|>> {synthesis.#Extension (symbol ..my_generation|generation)} +                (at ! each (|>> {synthesis.#Extension (symbol ..my_translation|translation)}                                  [location.dummy]                                  (is synthesis.Synthesis))))))) -      (def my_generation +      (def my_translation          Analysis          (analysis (_ phase archive [parameters (<>.some <code>.any)])            (let [! phase.monad]              (|> parameters                  (monad.each ! (phase archive))                  (at ! each (|>> (is (List analysis.Analysis)) -                                {analysis.#Extension (symbol ..my_generation|synthesis)} +                                {analysis.#Extension (symbol ..my_translation|synthesis)}                                  [location.dummy]                                  (is analysis.Analysis))))))) -      (def dummy_generation|generation -        Generation -        (generation (_ phase archive []) -          (let [[_ self] (symbol ..dummy_generation)] -            (at phase.monad in -                (for @.jvm (jvm.string self) -                     @.js (js.string self) -                     @.python (python.unicode self) -                     @.lua (lua.string self) -                     @.ruby (ruby.string self) -                     @.php (php.string self) -                     @.scheme (scheme.string self)))))) - -      (def dummy_generation|synthesis +      (def dummy_translation|translation +        Translation +        (translation (_ phase archive []) +                     (let [[_ self] (symbol ..dummy_translation)] +                       (at phase.monad in +                           (for @.jvm (jvm.string self) +                                @.js (js.string self) +                                @.python (python.unicode self) +                                @.lua (lua.string self) +                                @.ruby (ruby.string self) +                                @.php (php.string self) +                                @.scheme (scheme.string self)))))) + +      (def dummy_translation|synthesis          Synthesis          (synthesis (_ phase archive [])            (at phase.monad in (is synthesis.Synthesis -                                 [location.dummy {synthesis.#Extension (symbol ..dummy_generation|generation) (list)}])))) +                                 [location.dummy {synthesis.#Extension (symbol ..dummy_translation|translation) (list)}])))) -      (def dummy_generation +      (def dummy_translation          Analysis          (analysis (_ phase archive [])            (at phase.monad in (is analysis.Analysis -                                 [location.dummy {analysis.#Extension (symbol ..dummy_generation|synthesis) (list)}])))) +                                 [location.dummy {analysis.#Extension (symbol ..dummy_translation|synthesis) (list)}]))))        ... Declaration        (def my_declaration @@ -166,37 +166,37 @@               expressionS (declaration.lifted_synthesis                            (synthesis_phase lux archive expressionA)) -             generation_phase declaration.generation -             expressionG (declaration.lifted_generation -                          (generation_phase lux archive expressionS)) +             translation_phase declaration.translation +             expressionG (declaration.lifted_translation +                          (translation_phase lux archive expressionS)) -             _ (declaration.lifted_generation -                (generation.with_new_context archive unit.none +             _ (declaration.lifted_translation +                (translation.with_new_context archive unit.none                    (do ! -                    [[module_id artifact_id] (generation.context archive) +                    [[module_id artifact_id] (translation.context archive)                       .let [commentary (format "Successfully installed declaration " (%.text self) "!")] -                     _ (generation.save! artifact_id {.#None} -                                         (for @.jvm (let [$class (jvm/runtime.class_name [module_id artifact_id])] -                                                      (<| [$class] -                                                          (try.else (binary.empty 0)) -                                                          (try#each (binaryF.result class.format)) -                                                          (class.class version.v6_0 class.public -                                                            (name.internal $class) -                                                            {.#None} -                                                            (name.internal "java.lang.Object") -                                                            (list) -                                                            (list) -                                                            (list) -                                                            (list)))) -                                              @.js (js.comment commentary -                                                     (js.statement (js.string commentary))) -                                              @.python (python.comment commentary -                                                         (python.statement (python.string commentary))) -                                              @.lua (lua.comment commentary -                                                      (lua.statement expressionG)) -                                              @.ruby (ruby.comment commentary -                                                       (ruby.statement (ruby.string commentary)))))] -                    (generation.log! commentary))))] +                     _ (translation.save! artifact_id {.#None} +                                          (for @.jvm (let [$class (jvm/runtime.class_name [module_id artifact_id])] +                                                       (<| [$class] +                                                           (try.else (binary.empty 0)) +                                                           (try#each (binaryF.result class.format)) +                                                           (class.class version.v6_0 class.public +                                                             (name.internal $class) +                                                             {.#None} +                                                             (name.internal "java.lang.Object") +                                                             (list) +                                                             (list) +                                                             (list) +                                                             (list)))) +                                               @.js (js.comment commentary +                                                      (js.statement (js.string commentary))) +                                               @.python (python.comment commentary +                                                          (python.statement (python.string commentary))) +                                               @.lua (lua.comment commentary +                                                       (lua.statement expressionG)) +                                               @.ruby (ruby.comment commentary +                                                        (ruby.statement (ruby.string commentary)))))] +                    (translation.log! commentary))))]              (in declaration.no_requirements))))        (..my_declaration (n.* 2 3)) @@ -216,13 +216,13 @@                         [/.analysis ..my_analysis]                         [/.synthesis ..my_synthesis])) -                 (_.coverage [/.generation] +                 (_.coverage [/.translation]                     (for @.old false                          (and (n.= expected -                                  (..my_generation expected)) -                             (let [[_ expected] (symbol ..dummy_generation)] +                                  (..my_translation expected)) +                             (let [[_ expected] (symbol ..dummy_translation)]                                 (text#= expected -                                       (..dummy_generation)))))) +                                       (..dummy_translation))))))                   (_.coverage [/.declaration]                     true)                   ))))) diff --git a/stdlib/source/test/lux/meta/type.lux b/stdlib/source/test/lux/meta/type.lux index 488bdabc0..50cccc419 100644 --- a/stdlib/source/test/lux/meta/type.lux +++ b/stdlib/source/test/lux/meta/type.lux @@ -39,7 +39,7 @@    ["[1][0]" implicit]    ["[1][0]" quotient]    ["[1][0]" refinement] -  ["[1][0]" resource] +  ["[1][0]" linear]    ["[1][0]" unit]    ["[1][0]" variance]    ["[1][0]" poly] @@ -569,7 +569,7 @@             /implicit.test             /quotient.test             /refinement.test -           /resource.test +           /linear.test             /unit.test             /variance.test             /poly.test diff --git a/stdlib/source/test/lux/meta/type/resource.lux b/stdlib/source/test/lux/meta/type/linear.lux index 4b134ebbe..4b134ebbe 100644 --- a/stdlib/source/test/lux/meta/type/resource.lux +++ b/stdlib/source/test/lux/meta/type/linear.lux  | 
