aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2018-07-21 21:04:12 -0400
committerEduardo Julian2018-07-21 21:04:12 -0400
commita76985a039abfc877437e7eb9ec2f35c88391650 (patch)
tree0979a0b189e48fa72b70685eff9af36244d592f2 /stdlib/test
parent35b77d1ae1e0e4d59f8341089b12c0043abaddd8 (diff)
Got rid of Object-Oriented Programming modules.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/type/object/interface.lux87
-rw-r--r--stdlib/test/test/lux/type/object/protocol.lux133
-rw-r--r--stdlib/test/tests.lux5
3 files changed, 1 insertions, 224 deletions
diff --git a/stdlib/test/test/lux/type/object/interface.lux b/stdlib/test/test/lux/type/object/interface.lux
deleted file mode 100644
index 9f1c25ad2..000000000
--- a/stdlib/test/test/lux/type/object/interface.lux
+++ /dev/null
@@ -1,87 +0,0 @@
-(.module:
- [lux #*
- [data
- [collection
- ["." list]]]
- [type
- [object
- interface]]])
-
-## No parameters
-(interface: Counter
- (inc! [] @)
- (read! [] Nat))
-
-(class: NatC Counter
- Nat
-
- (def: inc!
- (update@Counter inc))
-
- (def: read!
- get@Counter))
-
-(interface: Resettable-Counter
- #super Counter
- (reset [] @))
-
-(class: NatRC Resettable-Counter
- #super NatC
- Any
-
- (def: reset
- (set@Counter +0)))
-
-## With parameters
-(interface: (Collection a)
- (add [a] @)
- (size [] Nat))
-
-(class: (ListC a) (Collection a)
- (List a)
-
- (def: (add elem)
- (update@Collection (|>> (#.Cons elem))))
-
- (def: size
- (|>> get@Collection list.size)))
-
-(interface: (Iterable a)
- #super (Collection a)
- (enumerate [] (List a)))
-
-(class: (ListI a) (Iterable a)
- #super (ListC a)
- Any
-
- (def: enumerate
- get@Collection))
-
-## Polymorphism
-(def: (poly0 counter)
- (-> Counter Nat)
- (read! counter))
-
-(def: poly0-0 Nat (poly0 (new@NatC +0)))
-(def: poly0-1 Nat (poly0 (new@NatRC +0 [])))
-
-(def: (poly1 counter)
- (-> Resettable-Counter Nat)
- (n/+ (read! counter)
- (read! (reset counter))))
-
-(def: poly1-0 Nat (poly1 (new@NatRC +0 [])))
-
-(def: (poly2 counter)
- (-> NatC Nat)
- (read! counter))
-
-(def: poly2-0 Nat (poly2 (new@NatC +0)))
-(def: poly2-1 Nat (poly2 (new@NatRC +0 [])))
-
-(def: (poly3 counter)
- (-> NatRC Nat)
- (n/+ (read! counter)
- (read! (reset counter))))
-
-(def: poly3-0 Nat (poly3 (new@NatRC +0 [])))
diff --git a/stdlib/test/test/lux/type/object/protocol.lux b/stdlib/test/test/lux/type/object/protocol.lux
deleted file mode 100644
index fe463205d..000000000
--- a/stdlib/test/test/lux/type/object/protocol.lux
+++ /dev/null
@@ -1,133 +0,0 @@
-(.module:
- [lux #*
- [data
- [text
- format]]
- [type
- [object
- protocol]]])
-
-(type: Counter (Object (Method Any Nat)))
-
-(def: (count [tick return] state)
- (Class Nat (Method Any Nat))
- (let [state' (inc state)]
- [(return state') state']))
-
-(def: counter
- (-> Nat Counter)
- (object count))
-
-(def: _test0
- [Nat Counter]
- ((counter +0) (message [])))
-
-(protocol: Protocol0
- (method0 [Bit Nat Text] Bit)
- (method1 [Nat Text Bit] Nat)
- (method2 [Text Bit Nat] Text))
-
-(type: Object0 (Object Protocol0))
-
-(def: object0
- Object0
- (loop [num-calls +0]
- (function (_ message)
- [(case message
- (#method0 [arg0 arg1 arg2] output)
- (output (n/= +0 (n/% +2 num-calls)))
-
- (#method1 [arg0 arg1 arg2] output)
- (output num-calls)
-
- (#method2 [arg0 arg1 arg2] output)
- (output (%n num-calls)))
- (recur (inc num-calls))])))
-
-(def: _test1
- [Nat Object0]
- (object0 (method1 [+0 "0" #0])))
-
-(protocol: (Read a)
- (read [] a))
-
-(def: (readM [tick return] state)
- (All [s] (Class s (Method Any s)))
- [(return state) state])
-
-(protocol: (Add n)
- (+ n Any)
- (- n Any))
-
-(protocol: (Mul n)
- (* n Any)
- (/ n Any))
-
-(do-template [<name> <op>]
- [(def: (<name> [diff return] state)
- (Class Nat (Method Nat Any))
- [(return []) (<op> diff state)])]
-
- [+M n/+]
- [-M n/-]
- [*M n/*]
- [/M n//]
- )
-
-(def: addM
- (Class Nat (Add Nat))
- (alt +M -M))
-
-(def: mulM
- (Class Nat (Mul Nat))
- (alt *M /M))
-
-(type: (Number n)
- ($_ Alt
- (Read n)
- (Add n)
- (Mul n)))
-
-## TODO: Fix when new-luxc is the official compiler.
-## (protocol: (Number n)
-## (^read (Read n))
-## (^add (Add n))
-## (^mul (Mul n)))
-
-(def: numberM
- (Class Nat (Number Nat))
- ($_ alt
- readM
- addM
- mulM))
-
-(type: NatO (Object (Number Nat)))
-
-(def: numberO
- NatO
- (object numberM +1))
-
-(def: _test2
- [Nat NatO]
- (numberO (+0 (read []))))
-
-(def: _test3
- [Any NatO]
- (numberO (+1 (+0 (+ +123)))))
-
-(def: _test4
- [Any NatO]
- (numberO (+1 (+1 (* +123)))))
-
-## TODO: Fix when new-luxc is the official compiler.
-## (def: _test2
-## [Nat NatO]
-## (numberO (^read (read []))))
-
-## (def: _test3
-## [Any NatO]
-## (numberO (^add (+ +123))))
-
-## (def: _test4
-## [Any NatO]
-## (numberO (^mul (* +123))))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index db2687876..2380365bf 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -145,10 +145,7 @@
["_." type
["_." check]
## ["_." implicit] ## TODO: Specially troublesome...
- ["_." resource]
- [object
- ["_." interface]
- ["_." protocol]]]
+ ["_." resource]]
[compiler
[default
["_default/." syntax]