From d0f33f630aedb67d2888e32ceb7bc237839b274e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 6 Jan 2022 19:47:43 -0400 Subject: Small optimizations to JVM bytecode generation. --- stdlib/source/test/lux/tool.lux | 4 +- stdlib/source/test/lux/tool/compiler/reference.lux | 95 ++++++++++++++++++++++ .../test/lux/tool/compiler/reference/variable.lux | 6 +- 3 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 stdlib/source/test/lux/tool/compiler/reference.lux (limited to 'stdlib/source/test') 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 [] + [(_.cover [] + (case ( expected_register) + (^ ( 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] -- cgit v1.2.3