aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/reference.lux39
-rw-r--r--stdlib/source/specification/lux/abstract/equivalence.lux32
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/reference.lux95
-rw-r--r--stdlib/source/test/lux/tool/compiler/reference/variable.lux6
8 files changed, 140 insertions, 51 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
index b28f5b5a7..a22654346 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux
@@ -252,9 +252,7 @@
{.#Some _}
($_ _.composite
(_.set_label @else)
- _.pop ... TODO: Comment this line
//runtime.pm_failure
- _.aconst_null ... TODO: Comment this line
(_.goto @end)
)))
))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux
index fd110c5d2..343aa7f1f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux
@@ -68,9 +68,8 @@
(Bytecode Any)]))
(let [classT (type.class class (list))
fields (: (List (Resource Field))
- (list& /arity.constant
- (list#composite (/foreign.variables environment)
- (/partial.variables arity))))
+ (list#composite (/foreign.variables environment)
+ (/partial.variables arity)))
methods (: (List (Resource Method))
(list& (/init.method classT environment arity)
(/reset.method classT environment arity)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux
index 878bbac3a..1828fe5c1 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux
@@ -4,19 +4,13 @@
[target
[jvm
["[0]" type]
- ["[0]" field {"+" Field}]
[constant
[pool {"+" Resource}]]]]]]
["[0]" //
[/////////
[arity {"+" Arity}]]])
-(def: .public name "arity")
-(def: .public type type.int)
-
(def: .public minimum Arity 1)
(def: .public maximum Arity 8)
-(def: .public constant
- (Resource Field)
- (//.constant ..name ..type))
+(def: .public type type.int)
diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux
index 2e57e77d9..56f9b9589 100644
--- a/stdlib/source/library/lux/tool/compiler/reference.lux
+++ b/stdlib/source/library/lux/tool/compiler/reference.lux
@@ -1,21 +1,21 @@
(.using
- [library
- [lux {"-" local}
- [abstract
- [equivalence {"+" Equivalence}]
- [hash {"+" Hash}]]
- [control
- [pipe {"+" case>}]]
- [data
- [text
- ["%" format {"+" Format}]]]
- [math
- [number
- ["n" nat]]]
- [meta
- ["[0]" symbol]]]]
- ["[0]" / "_"
- ["[1][0]" variable {"+" Variable}]])
+ [library
+ [lux {"-" local}
+ [abstract
+ [equivalence {"+" Equivalence}]
+ [hash {"+" Hash}]]
+ [control
+ [pipe {"+" case>}]]
+ [data
+ [text
+ ["%" format {"+" Format}]]]
+ [math
+ [number
+ ["n" nat]]]
+ [meta
+ ["[0]" symbol]]]]
+ ["[0]" / "_"
+ ["[1][0]" variable {"+" Variable}]])
(type: .public Constant
Symbol)
@@ -75,9 +75,8 @@
[constant ..#Constant]
)
-(def: .public self
- Reference
- (..local 0))
+(`` (template: .public self
+ [(..variable (~~ (/variable.self)))]))
(def: .public format
(Format Reference)
diff --git a/stdlib/source/specification/lux/abstract/equivalence.lux b/stdlib/source/specification/lux/abstract/equivalence.lux
index 84bcea50f..42d9e3750 100644
--- a/stdlib/source/specification/lux/abstract/equivalence.lux
+++ b/stdlib/source/specification/lux/abstract/equivalence.lux
@@ -1,24 +1,24 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [math
- ["[0]" random {"+" Random}]]]]
- [\\library
- ["[0]" / {"+" Equivalence}]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random {"+" Random}]]]]
+ [\\library
+ ["[0]" / {"+" Equivalence}]])
-(def: .public (spec (^open "_//[0]") random)
+(def: .public (spec (^open "/#[0]") random)
(All (_ a) (-> (Equivalence a) (Random a) Test))
(do random.monad
[left random
right random]
(<| (_.for [/.Equivalence])
($_ _.and
- (_.test "Reflexivity."
- (_//= left left))
- (_.test "Symmetry."
- (if (_//= left right)
- (_//= right left)
- (not (_//= right left))))))))
+ (_.test "Reflexivity"
+ (/#= left left))
+ (_.test "Symmetry"
+ (bit#= (/#= left right) (/#= right left)))))))
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 37e45bcee..ef83286b4 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -5,7 +5,7 @@
["[0]" / "_"
[compiler
["[1][0]" arity]
- ["[1][0]" reference/variable]
+ ["[1][0]" reference]
... [language
... [lux
... ["[1][0]" syntax]
@@ -18,7 +18,7 @@
Test
($_ _.and
/arity.test
- /reference/variable.test
+ /reference.test
... /syntax.test
... /analysis.test
... /synthesis.test
diff --git a/stdlib/source/test/lux/tool/compiler/reference.lux b/stdlib/source/test/lux/tool/compiler/reference.lux
new file mode 100644
index 000000000..fd76a5146
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/reference.lux
@@ -0,0 +1,95 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [data
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format]]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]]]
+ [meta
+ ["[0]" symbol ("[1]#[0]" equivalence)]]]]
+ [\\library
+ ["[0]" /
+ ["[0]" variable {"+" Register}]]]
+ ["[0]" / "_"
+ ["[1][0]" variable]])
+
+(def: constant
+ (Random /.Constant)
+ ($_ random.and
+ (random.ascii/upper 5)
+ (random.ascii/lower 5)
+ ))
+
+(def: .public random
+ (Random /.Reference)
+ ($_ random.or
+ /variable.random
+ ..constant
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Reference /.Constant])
+ (do random.monad
+ [expected_register random.nat
+ expected_constant ..constant])
+ (`` ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
+ (~~ (template [<tag>]
+ [(_.cover [<tag>]
+ (case (<tag> expected_register)
+ (^ (<tag> actual_register))
+ (n.= expected_register actual_register)
+
+ _
+ false))]
+
+ [/.local]
+ [/.foreign]
+ ))
+
+ (_.cover [/.variable /.self]
+ (and (# /.equivalence = (/.self) (/.variable (variable.self)))
+ (case (/.self)
+ (^ (/.self))
+ true
+
+ _
+ false)
+ (case (/.variable (variable.self))
+ (^ (/.self))
+ true
+
+ _
+ false)))
+ (_.cover [/.constant]
+ (case (/.constant expected_constant)
+ (^ (/.constant actual_constant))
+ (symbol#= expected_constant actual_constant)
+
+ _
+ false))
+ (_.cover [/.format]
+ (and (text#= (/.format (/.local expected_register))
+ (variable.format {variable.#Local expected_register}))
+ (text#= (/.format (/.foreign expected_register))
+ (variable.format {variable.#Foreign expected_register}))
+ (text#= (/.format (/.constant expected_constant))
+ (%.symbol expected_constant))))
+
+ /variable.test
+ ))))
diff --git a/stdlib/source/test/lux/tool/compiler/reference/variable.lux b/stdlib/source/test/lux/tool/compiler/reference/variable.lux
index 980a280f0..15d0997e4 100644
--- a/stdlib/source/test/lux/tool/compiler/reference/variable.lux
+++ b/stdlib/source/test/lux/tool/compiler/reference/variable.lux
@@ -32,7 +32,11 @@
($equivalence.spec /.equivalence ..random))
(_.for [/.hash]
($hash.spec /.hash ..random))
- (_.cover [/.self /.self?]
+ (_.cover [/.self]
+ (case (/.self)
+ (^ (/.self)) true
+ _ false))
+ (_.cover [/.self?]
(/.self? (/.self)))
(_.for [/.Register]
(_.cover [/.format]