aboutsummaryrefslogtreecommitdiffstats
path: root/spec/input_spec.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-09 14:49:08 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:23:21 +0000
commit61eb86951287667ca0ee305baa5c3cd6ad29ba36 (patch)
tree7551d6b9c8af01c049adab0ee027dbad68f28808 /spec/input_spec.moon
parentmore internal doc fixes (diff)
downloadalive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.tar.gz
alive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.zip
add types.T, fix spec + docs
Diffstat (limited to 'spec/input_spec.moon')
-rw-r--r--spec/input_spec.moon112
1 files changed, 71 insertions, 41 deletions
diff --git a/spec/input_spec.moon b/spec/input_spec.moon
index 8a8defe..8dbd726 100644
--- a/spec/input_spec.moon
+++ b/spec/input_spec.moon
@@ -1,130 +1,160 @@
import do_setup, do_teardown from require 'spec.test_setup'
-import Input, Primitive, Result, SigStream, EvtStream, IOStream
- from require 'alv.base'
+import Input, T, Result, IOStream from require 'alv.base'
setup do_setup
teardown do_teardown
-my_io = Primitive 'my-io'
-
class MyIO extends IOStream
- new: => super my_io
+ new: => super T.my_io
dirty: => @is_dirty
-basic_tests = (stream, input) ->
+basic_tests = (result, input) ->
it 'gives access to the Result', ->
- assert.is.equal stream, input.stream
+ assert.is.equal result, input.result
it 'forwards :unwrap', ->
- assert.is.same stream\unwrap!, input\unwrap!
- assert.is.same stream\unwrap!, input!
+ assert.is.same result\unwrap!, input\unwrap!
+ assert.is.same result\unwrap!, input!
it 'gives access to the type string', ->
- assert.is.equal stream.type, input\type!
+ assert.is.equal result.type, input\type!
it 'gives access to the metatype string', ->
- assert.is.equal stream.metatype, input\metatype!
+ assert.is.equal result.metatype, input\metatype!
describe 'Input.cold', ->
- stream = SigStream.num 1
- input = Input.cold stream
+ result = T.num\mk_sig 1
+ input = Input.cold result
- basic_tests stream, input
+ basic_tests result, input
it 'is never dirty', ->
assert.is.false input\dirty!
- stream\set 2
+ result\set 2
assert.is.false input\dirty!
input\setup nil
assert.is.false input\dirty!
input\finish_setup!
- new_input = Input.cold SigStream.num 3
+ new_input = Input.cold T.num\mk_sig 3
new_input\setup input
assert.is.false new_input\dirty!
- new_input.stream\set 4
+ new_input.result\set 4
assert.is.false new_input\dirty!
input\finish_setup!
describe 'Input.hot', ->
+ describe 'with Constant', ->
+ result = T.num\mk_const 1
+ input = Input.hot result
+
+ basic_tests result, input
+
+ describe 'at evaltime', ->
+ it 'is dirty when new', ->
+ assert.is.false result\dirty!
+
+ newinput = Input.hot result
+ newinput\setup nil
+ assert.is.true newinput\dirty!
+ newinput\finish_setup!
+
+ it 'is dirty when different', ->
+ newval = T.num\mk_const 2
+
+ assert.is.false newval\dirty!
+ newinput = Input.hot newval
+ newinput\setup input
+ assert.is.true newinput\dirty!
+ newinput\finish_setup!
+
+ it 'is not dirty when equal', ->
+ newval = T.num\mk_const 1
+
+ assert.is.false newval\dirty!
+ newinput = Input.hot newval
+ newinput\setup input
+ assert.is.false newinput\dirty!
+ newinput\finish_setup!
+
describe 'with EvtStream', ->
- stream = EvtStream Primitive 'num'
- input = Input.hot stream
+ result = T.num\mk_evt!
+ input = Input.hot result
- basic_tests stream, input
+ basic_tests result, input
it 'is marked for lifting', ->
assert.is.nil input.io
it 'is dirty when the EvtStream is dirty', ->
assert.is.false input\dirty!
- assert.is.false stream\dirty!
+ assert.is.false result\dirty!
input\setup nil
assert.is.false input\dirty!
input\finish_setup!
COPILOT\next_tick!
- stream\add 1
+ result\add 1
assert.is.true input\dirty!
- assert.is.true stream\dirty!
+ assert.is.true result\dirty!
input\setup nil
assert.is.true input\dirty!
input\finish_setup!
assert.is.true input\dirty!
- assert.is.true stream\dirty!
+ assert.is.true result\dirty!
describe 'with IOStream', ->
- stream = MyIO!
- input = Input.hot stream
+ result = MyIO!
+ input = Input.hot result
- basic_tests stream, input
+ basic_tests result, input
it 'is marked for lifting', ->
assert.is.true input.io
it 'is dirty when the IOStream is dirty', ->
- stream.is_dirty = false
+ result.is_dirty = false
assert.is.false input\dirty!
- assert.is.false stream\dirty!
+ assert.is.false result\dirty!
input\setup nil
assert.is.false input\dirty!
input\finish_setup!
COPILOT\next_tick!
- stream.is_dirty = true
+ result.is_dirty = true
assert.is.true input\dirty!
- assert.is.true stream\dirty!
+ assert.is.true result\dirty!
input\setup nil
assert.is.true input\dirty!
input\finish_setup!
assert.is.true input\dirty!
- assert.is.true stream\dirty!
+ assert.is.true result\dirty!
describe 'with SigStream', ->
- stream = SigStream.num 1
+ result = T.num\mk_sig 1
local input
describe 'at evaltime', ->
it 'is dirty when new', ->
- assert.is.false stream\dirty!
+ assert.is.false result\dirty!
- input = Input.hot stream
+ input = Input.hot result
input\setup nil
assert.is.true input\dirty!
input\finish_setup!
it 'is dirty when different', ->
- newval = SigStream.num 2
+ newval = T.num\mk_sig 2
assert.is.false newval\dirty!
newinput = Input.hot newval
@@ -133,7 +163,7 @@ describe 'Input.hot', ->
newinput\finish_setup!
it 'is not dirty when equal', ->
- newval = SigStream.num!
+ newval = T.num\mk_sig!
newval\set 1
assert.is.true newval\dirty!
@@ -143,11 +173,11 @@ describe 'Input.hot', ->
newinput\finish_setup!
describe 'at runtime', ->
- it 'is dirty when the stream is dirty', ->
- stream\set 3
- assert.is.true stream\dirty!
+ it 'is dirty when the result is dirty', ->
+ result\set 3
+ assert.is.true result\dirty!
assert.is.true input\dirty!
COPILOT\next_tick!
- assert.is.false stream\dirty!
+ assert.is.false result\dirty!
assert.is.false input\dirty!