From ad1391ea1cdd33167339d25dbff2567f5a8d5c68 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 23 Dec 2022 20:58:58 -0400 Subject: Began work on C++ back-end. --- .../specification/lux/abstract/equivalence.lux | 30 ---------------- stdlib/source/specification/lux/abstract/hash.lux | 6 ++-- .../source/specification/lux/abstract/interval.lux | 24 ------------- .../source/specification/lux/math/arithmetic.lux | 42 +++++++++++++++------- stdlib/source/specification/lux/world/shell.lux | 6 +++- 5 files changed, 37 insertions(+), 71 deletions(-) delete mode 100644 stdlib/source/specification/lux/abstract/equivalence.lux delete mode 100644 stdlib/source/specification/lux/abstract/interval.lux (limited to 'stdlib/source/specification') diff --git a/stdlib/source/specification/lux/abstract/equivalence.lux b/stdlib/source/specification/lux/abstract/equivalence.lux deleted file mode 100644 index 439b33093..000000000 --- a/stdlib/source/specification/lux/abstract/equivalence.lux +++ /dev/null @@ -1,30 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)]] - [data - ["[0]" bit (.use "[1]#[0]" equivalence)]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" / (.only Equivalence)]]) - -(def .public (spec (open "/#[0]") random) - (All (_ a) (-> (Equivalence a) (Random a) Test)) - (do random.monad - [left random - right random] - (<| (_.for [/.Equivalence]) - (_.coverage [/.=] - (let [reflexivity! - (/#= left left) - - symmetry! - (bit#= (/#= left right) - (/#= right left))] - (and reflexivity! - symmetry! - )))))) diff --git a/stdlib/source/specification/lux/abstract/hash.lux b/stdlib/source/specification/lux/abstract/hash.lux index 2b6aa5cd6..28b1c27a2 100644 --- a/stdlib/source/specification/lux/abstract/hash.lux +++ b/stdlib/source/specification/lux/abstract/hash.lux @@ -3,8 +3,8 @@ [lux (.except) [abstract [monad (.only do)] - [\\specification - ["[0]S" equivalence]]] + ["[0]" equivalence + ["[1]T" \\test]]] [math ["[0]" random (.only Random)] [number @@ -21,7 +21,7 @@ subject random] (all _.and (_.for [/.equivalence] - (equivalenceS.spec /#equivalence random)) + (equivalenceT.spec /#equivalence random)) (_.coverage [/.Hash /.hash] (if (/#= parameter subject) (n.= (/#hash parameter) (/#hash subject)) diff --git a/stdlib/source/specification/lux/abstract/interval.lux b/stdlib/source/specification/lux/abstract/interval.lux deleted file mode 100644 index 0de229d65..000000000 --- a/stdlib/source/specification/lux/abstract/interval.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [monad (.only do)] - ["[0]" order]] - [math - ["[0]" random (.only Random)]] - [test - ["_" property (.only Test)]]]] - [\\library - ["[0]" /]]) - -(def .public (spec (open "@//[0]") gen_sample) - (All (_ a) (-> (/.Interval a) (Random a) Test)) - (<| (_.for [/.Interval]) - (do random.monad - [sample gen_sample] - (all _.and - (_.test "No value is bigger than the top." - (@//< @//top sample)) - (_.test "No value is smaller than the bottom." - (order.> @//order @//bottom sample)) - )))) diff --git a/stdlib/source/specification/lux/math/arithmetic.lux b/stdlib/source/specification/lux/math/arithmetic.lux index 9b8d1fb7d..1c13f52f5 100644 --- a/stdlib/source/specification/lux/math/arithmetic.lux +++ b/stdlib/source/specification/lux/math/arithmetic.lux @@ -17,25 +17,41 @@ Test)) (do random.monad [any random - .let [zero (- any any) - non_zero (random.only (|>> (= zero) not) + .let [@0 (- any any) + non_zero (random.only (|>> (= @0) not) random)] - left non_zero - right non_zero - .let [one (/ right right)]] + any non_zero + .let [@1 (/ any any) + @2 (+ @1 @1) + @4 (+ @2 @2) + @8 (+ @4 @4) + + power_of_two (all random.either + (in @1) + (in @2) + (in @4) + (in @8) + )] + left power_of_two + right power_of_two] (<| (_.covering /._) (_.for [/.Arithmetic]) (all _.and (_.coverage [/.+ /.-] (and (|> left (+ right) (- right) (= left)) (|> left (- right) (+ right) (= left)) - (|> left (+ zero) (= left)) - (|> left (- zero) (= left)) - (|> left (- left) (= zero)))) + + (|> left (+ @0) (= left)) + (|> left (- @0) (= left)) + + (|> left (- left) (= @0)))) (_.coverage [/.* /./] - (and (|> left (* right) (/ right) (= left)) - (|> left (* one) (= left)) - (|> left (/ one) (= left)) - (|> left (/ left) (= one)) - (|> left (* zero) (= zero)))) + (and (|> left (* @0) (= @0)) + + (|> left (* @1) (= left)) + (|> left (/ @1) (= left)) + + (|> left (/ left) (= @1)) + + (|> left (* @2) (/ @2) (= left)))) )))) diff --git a/stdlib/source/specification/lux/world/shell.lux b/stdlib/source/specification/lux/world/shell.lux index eea350b90..f0248af56 100644 --- a/stdlib/source/specification/lux/world/shell.lux +++ b/stdlib/source/specification/lux/world/shell.lux @@ -70,7 +70,11 @@ (with_expansions [ (these [/.Command /.Argument])] (def .public (spec shell) (-> (/.Shell Async) Test) - (<| (_.for [/.Shell /.Process]) + (<| (_.for [/.Shell + /.execute + + /.Process + /.read /.fail /.write /.destroy /.await]) (do [! random.monad] [message (random.alphabetic 10) seconds (of ! each (|>> (n.% 5) (n.+ 5)) random.nat)] -- cgit v1.2.3