aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/compositor/generation/structure.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-15 00:45:15 -0400
committerEduardo Julian2021-07-15 00:45:15 -0400
commit0abd5bd3c0e38e352e9ba38268e04e1c858ab01e (patch)
treefe0af9e70413e9fc4f3848e0642920fca501c626 /stdlib/source/spec/compositor/generation/structure.lux
parent89ca40f2f101b2b38187eab5cf905371cd47eb57 (diff)
Re-named "spec" hierarchy to "specification".
Diffstat (limited to 'stdlib/source/spec/compositor/generation/structure.lux')
-rw-r--r--stdlib/source/spec/compositor/generation/structure.lux89
1 files changed, 0 insertions, 89 deletions
diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux
deleted file mode 100644
index 7c45d2a9b..000000000
--- a/stdlib/source/spec/compositor/generation/structure.lux
+++ /dev/null
@@ -1,89 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]]
- [control
- [pipe (#+ case>)]
- ["." try]]
- [data
- ["." maybe]
- [number
- ["n" nat]
- ["i" int]]
- ["." text ("#\." equivalence)
- ["%" format (#+ format)]]
- [collection
- ["." array (#+ Array)]
- ["." list ("#\." functor)]]]
- [math
- ["r" random]]
- ["." ffi (#+ import:)]
- [tool
- [compiler
- ["." analysis]
- ["." synthesis]]]]
- [///
- [common (#+ Runner)]])
-
-(import: java/lang/Integer)
-
-(def: (variant run)
- (-> Runner Test)
- (do {! r.monad}
- [num-tags (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2))))
- tag-in (|> r.nat (\ ! map (n.% num-tags)))
- #let [last?-in (|> num-tags dec (n.= tag-in))]
- value-in r.i64]
- (_.test (%.name (name-of synthesis.variant))
- (|> (synthesis.variant {#analysis.lefts (if last?-in
- (dec tag-in)
- tag-in)
- #analysis.right? last?-in
- #analysis.value (synthesis.i64 value-in)})
- (run "variant")
- (case> (#try.Success valueT)
- (let [valueT (:as (Array Any) valueT)]
- (and (n.= 3 (array.size valueT))
- (let [tag-out (:as java/lang/Integer (maybe.assume (array.read 0 valueT)))
- last?-out (array.read 1 valueT)
- value-out (:as Any (maybe.assume (array.read 2 valueT)))
- same-tag? (|> tag-out ffi.int-to-long (:as Nat) (n.= tag-in))
- same-flag? (case last?-out
- (#.Some last?-out')
- (and last?-in (text\= "" (:as Text last?-out')))
-
- #.None
- (not last?-in))
- same-value? (|> value-out (:as Int) (i.= value-in))]
- (and same-tag?
- same-flag?
- same-value?))))
-
- (#try.Failure _)
- false)))))
-
-(def: (tuple run)
- (-> Runner Test)
- (do {! r.monad}
- [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2))))
- tuple-in (r.list size r.i64)]
- (_.test (%.name (name-of synthesis.tuple))
- (|> (synthesis.tuple (list\map (|>> synthesis.i64) tuple-in))
- (run "tuple")
- (case> (#try.Success tuple-out)
- (let [tuple-out (:as (Array Any) tuple-out)]
- (and (n.= size (array.size tuple-out))
- (list.every? (function (_ [left right])
- (i.= left (:as Int right)))
- (list.zip/2 tuple-in (array.to-list tuple-out)))))
-
- (#try.Failure _)
- false)))))
-
-(def: #export (spec runner)
- (-> Runner Test)
- ($_ _.and
- (..variant runner)
- (..tuple runner)
- ))