aboutsummaryrefslogtreecommitdiffstats
path: root/spec
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
parentmore internal doc fixes (diff)
downloadalive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.tar.gz
alive-61eb86951287667ca0ee305baa5c3cd6ad29ba36.zip
add types.T, fix spec + docs
Diffstat (limited to 'spec')
-rw-r--r--spec/input_spec.moon112
-rw-r--r--spec/match_spec.moon6
-rw-r--r--spec/result/const_spec.moon45
-rw-r--r--spec/result/sig_spec.moon76
-rw-r--r--spec/rtnode_spec.moon27
-rw-r--r--spec/scope_spec.moon25
-rw-r--r--spec/type_spec.moon35
7 files changed, 193 insertions, 133 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!
diff --git a/spec/match_spec.moon b/spec/match_spec.moon
index 1e2ce61..afaef56 100644
--- a/spec/match_spec.moon
+++ b/spec/match_spec.moon
@@ -1,13 +1,13 @@
import val, evt from require 'alv.base.match'
-import RTNode, Primitive, SigStream, EvtStream, Error from require 'alv'
+import RTNode, T, Error from require 'alv'
mk_val = (type, const) ->
- result = SigStream Primitive type
+ result = T[type]\mk_sig!
with RTNode :result
.side_inputs = { 'fake' } unless const
mk_evt = (type, const) ->
- result = EvtStream Primitive type
+ result = T[type]\mk_evt!
with RTNode :result
.side_inputs = { 'fake' } unless const
diff --git a/spec/result/const_spec.moon b/spec/result/const_spec.moon
index dfcdafa..a6ab43e 100644
--- a/spec/result/const_spec.moon
+++ b/spec/result/const_spec.moon
@@ -1,5 +1,5 @@
import do_setup from require 'spec.test_setup'
-import Constant, RTNode, Scope, SimpleRegistry, Primitive from require 'alv'
+import Constant, RTNode, Scope, SimpleRegistry, T from require 'alv'
import Op, Builtin from require 'alv.base'
class TestOp extends Op
@@ -11,15 +11,20 @@ class TestBuiltin extends Builtin
setup do_setup
describe 'Constant', ->
+ it 'requires a value', ->
+ assert.has.error -> Constant.num!
+ assert.has.error -> Constant T.num
+ assert.has.no.error -> Constant T.bool, false
+
describe '.wrap', ->
it 'wraps numbers', ->
got = Constant.wrap 3
- assert.is.equal Primitive.num, got.type
+ assert.is.equal T.num, got.type
assert.is.equal 3, got.value
it 'wraps strings', ->
got = Constant.wrap "im a happy string"
- assert.is.equal Primitive.str, got.type
+ assert.is.equal T.str, got.type
assert.is.equal "im a happy string", got.value
it 'wraps Constants', ->
@@ -31,27 +36,27 @@ describe 'Constant', ->
it 'wraps Opdefs', ->
got = Constant.wrap TestOp
- assert.is.equal Primitive.op, got.type
+ assert.is.equal T.opdef, got.type
assert.is.equal TestOp, got.value
it 'wraps Bultins', ->
got = Constant.wrap TestBuiltin
- assert.is.equal Primitive.builtin, got.type
+ assert.is.equal T.builtin, got.type
assert.is.equal TestBuiltin, got.value
it 'wraps Scopes', ->
sub = Scope!
got = Constant.wrap sub
- assert.is.equal Primitive.scope, got.type
+ assert.is.equal T.scope, got.type
assert.is.equal sub, got.value
it 'wraps tables', ->
pi = Constant.num 3.14
got = Constant.wrap { :pi }
- assert.is.equal Primitive.scope, got.type
+ assert.is.equal T.scope, got.type
assert.is.equal pi, (got.value\get 'pi')\const!
describe ':unwrap', ->
@@ -61,23 +66,23 @@ describe 'Constant', ->
assert.is.equal 'hi', (Constant.sym 'hi')\unwrap!
test 'can assert the type', ->
- assert.is.equal 3.14, (Constant.num 3.14)\unwrap Primitive.num
- assert.is.equal 'hi', (Constant.str 'hi')\unwrap Primitive.str
- assert.is.equal 'hi', (Constant.sym 'hi')\unwrap Primitive.sym
- assert.has_error -> (Constant.num 3.14)\unwrap Primitive.sym
- assert.has_error -> (Constant.str 'hi')\unwrap Primitive.num
- assert.has_error -> (Constant.sym 'hi')\unwrap Primitive.str
+ assert.is.equal 3.14, (Constant.num 3.14)\unwrap T.num
+ assert.is.equal 'hi', (Constant.str 'hi')\unwrap T.str
+ assert.is.equal 'hi', (Constant.sym 'hi')\unwrap T.sym
+ assert.has_error -> (Constant.num 3.14)\unwrap T.sym
+ assert.has_error -> (Constant.str 'hi')\unwrap T.num
+ assert.has_error -> (Constant.sym 'hi')\unwrap T.str
test 'has __call shorthand', ->
assert.is.equal 3.14, (Constant.num 3.14)!
assert.is.equal 'hi', (Constant.str 'hi')!
assert.is.equal 'hi', (Constant.sym 'hi')!
- assert.is.equal 3.14, (Constant.num 3.14) Primitive.num
- assert.is.equal 'hi', (Constant.str 'hi') Primitive.str
- assert.is.equal 'hi', (Constant.sym 'hi') Primitive.sym
- assert.has_error -> (Constant.num 3.14) Primitive.sym
- assert.has_error -> (Constant.str 'hi') Primitive.num
- assert.has_error -> (Constant.sym 'hi') Primitive.str
+ assert.is.equal 3.14, (Constant.num 3.14) T.num
+ assert.is.equal 'hi', (Constant.str 'hi') T.str
+ assert.is.equal 'hi', (Constant.sym 'hi') T.sym
+ assert.has_error -> (Constant.num 3.14) T.sym
+ assert.has_error -> (Constant.str 'hi') T.num
+ assert.has_error -> (Constant.sym 'hi') T.str
describe 'overrides __eq', ->
it 'compares the type', ->
@@ -134,7 +139,7 @@ describe 'Constant', ->
it 'is equal to the original', ->
a = Constant.num 2
b = Constant.str 'asdf'
- c = Constant (Primitive 'weird'), {}, '(raw)'
+ c = Constant T.weird, {}, '(raw)'
aa, bb, cc = a\fork!, b\fork!, c\fork!
assert.is.equal a, aa
diff --git a/spec/result/sig_spec.moon b/spec/result/sig_spec.moon
index 93a9eb4..4d04b9c 100644
--- a/spec/result/sig_spec.moon
+++ b/spec/result/sig_spec.moon
@@ -1,5 +1,5 @@
import do_setup from require 'spec.test_setup'
-import SigStream, RTNode, Scope, SimpleRegistry, Primitive from require 'alv'
+import SigStream, RTNode, Scope, SimpleRegistry, T from require 'alv'
import Op, Builtin from require 'alv.base'
class TestOp extends Op
@@ -13,55 +13,55 @@ setup do_setup
describe 'SigStream', ->
describe ':unwrap', ->
it 'returns the raw value!', ->
- assert.is.equal 3.14, (SigStream.num 3.14)\unwrap!
- assert.is.equal 'hi', (SigStream.str 'hi')\unwrap!
- assert.is.equal 'hi', (SigStream.sym 'hi')\unwrap!
+ assert.is.equal 3.14, (SigStream T.num, 3.14)\unwrap!
+ assert.is.equal 'hi', (SigStream T.str, 'hi')\unwrap!
+ assert.is.equal 'hi', (SigStream T.sym, 'hi')\unwrap!
test 'can assert the type', ->
- assert.is.equal 3.14, (SigStream.num 3.14)\unwrap Primitive 'num'
- assert.is.equal 'hi', (SigStream.str 'hi')\unwrap Primitive 'str'
- assert.is.equal 'hi', (SigStream.sym 'hi')\unwrap Primitive 'sym'
- assert.has_error -> (SigStream.num 3.14)\unwrap Primitive 'sym'
- assert.has_error -> (SigStream.str 'hi')\unwrap Primitive 'num'
- assert.has_error -> (SigStream.sym 'hi')\unwrap Primitive 'str'
+ assert.is.equal 3.14, (SigStream T.num, 3.14)\unwrap T.num
+ assert.is.equal 'hi', (SigStream T.str, 'hi')\unwrap T.str
+ assert.is.equal 'hi', (SigStream T.sym, 'hi')\unwrap T.sym
+ assert.has_error -> (SigStream T.num, 3.14)\unwrap T.sym
+ assert.has_error -> (SigStream T.str, 'hi')\unwrap T.num
+ assert.has_error -> (SigStream T.sym, 'hi')\unwrap T.str
test 'has __call shorthand', ->
- assert.is.equal 3.14, (SigStream.num 3.14)!
- assert.is.equal 'hi', (SigStream.str 'hi')!
- assert.is.equal 'hi', (SigStream.sym 'hi')!
- assert.is.equal 3.14, (SigStream.num 3.14) Primitive 'num'
- assert.is.equal 'hi', (SigStream.str 'hi') Primitive 'str'
- assert.is.equal 'hi', (SigStream.sym 'hi') Primitive 'sym'
- assert.has_error -> (SigStream.num 3.14) Primitive 'sym'
- assert.has_error -> (SigStream.str 'hi') Primitive 'num'
- assert.has_error -> (SigStream.sym 'hi') Primitive 'str'
+ assert.is.equal 3.14, (SigStream T.num, 3.14)!
+ assert.is.equal 'hi', (SigStream T.str, 'hi')!
+ assert.is.equal 'hi', (SigStream T.sym, 'hi')!
+ assert.is.equal 3.14, (SigStream T.num, 3.14) T.num
+ assert.is.equal 'hi', (SigStream T.str, 'hi') T.str
+ assert.is.equal 'hi', (SigStream T.sym, 'hi') T.sym
+ assert.has_error -> (SigStream T.num, 3.14) T.sym
+ assert.has_error -> (SigStream T.str, 'hi') T.num
+ assert.has_error -> (SigStream T.sym, 'hi') T.str
describe 'overrides __eq', ->
it 'compares the type', ->
- val = SigStream.num 3
- assert.is.equal (SigStream.num 3), val
- assert.not.equal (SigStream.str '3'), val
+ val = SigStream T.num, 3
+ assert.is.equal (SigStream T.num, 3), val
+ assert.not.equal (SigStream T.str, '3'), val
- val = SigStream.str 'hello'
- assert.is.equal (SigStream.str 'hello'), val
- assert.not.equal (SigStream.sym 'hello'), val
+ val = SigStream T.str, 'hello'
+ assert.is.equal (SigStream T.str, 'hello'), val
+ assert.not.equal (SigStream T.sym, 'hello'), val
it 'compares the value', ->
- val = SigStream.num 3
- assert.is.equal (SigStream.num 3), val
- assert.not.equal (SigStream.num 4), val
+ val = SigStream T.num, 3
+ assert.is.equal (SigStream T.num, 3), val
+ assert.not.equal (SigStream T.num, 4), val
describe ':set', ->
it 'sets the value', ->
- val = SigStream.num 3
- assert.is.equal (SigStream.num 3), val
+ val = SigStream T.num, 3
+ assert.is.equal (SigStream T.num, 3), val
val\set 4
- assert.is.equal (SigStream.num 4), val
- assert.not.equal (SigStream.num 3), val
+ assert.is.equal (SigStream T.num, 4), val
+ assert.not.equal (SigStream T.num, 3), val
it 'marks the value dirty', ->
- val = SigStream.num 3
+ val = SigStream T.num, 3
assert.is.false val\dirty!
val\set 4
@@ -69,9 +69,9 @@ describe 'SigStream', ->
describe ':fork', ->
it 'is equal to the original', ->
- a = SigStream.num 2
- b = SigStream.str 'asdf'
- c = with SigStream 'weird', {}, '(raw)'
+ a = SigStream T.num, 2
+ b = SigStream T.str, 'asdf'
+ c = with SigStream T.weird, {}, '(raw)'
\set {}
aa, bb, cc = a\fork!, b\fork!, c\fork!
@@ -86,8 +86,8 @@ describe 'SigStream', ->
assert.is.equal c.raw, cc.raw
it 'isolates the original from the fork', ->
- a = SigStream.num 3
- b = with SigStream 'weird', {}, '(raw)'
+ a = SigStream T.num, 3
+ b = with SigStream T.weird, {}, '(raw)'
\set {}
aa, bb = a\fork!, b\fork!
diff --git a/spec/rtnode_spec.moon b/spec/rtnode_spec.moon
index a6cd63d..5dfebf7 100644
--- a/spec/rtnode_spec.moon
+++ b/spec/rtnode_spec.moon
@@ -1,11 +1,8 @@
import do_setup from require 'spec.test_setup'
import RTNode, Scope, SimpleRegistry from require 'alv'
-import Primitive, Input, Op, Constant, SigStream, EvtStream, IOStream
- from require 'alv.base'
+import T, Input, Op, Constant, IOStream from require 'alv.base'
setup do_setup
-num = Primitive 'num'
-bang = Primitive 'bang'
op_with_inputs = (inputs) ->
with Op!
@@ -16,7 +13,7 @@ node_with_sideinput = (result, input) ->
.side_inputs = { [result]: input }
class DirtyIO extends IOStream
- new: => super Primitive 'dirty-io'
+ new: => super T.dirty_io
dirty: => true
describe 'RTNode', ->
@@ -34,7 +31,7 @@ describe 'RTNode', ->
it ':type gets type and assets value', ->
node = RTNode result: Constant.num 2
- assert.is.equal num, node\type!
+ assert.is.equal T.num, node\type!
node = RTNode!
assert.has.error -> node\type!
@@ -52,7 +49,7 @@ describe 'RTNode', ->
assert.has.error (-> impure\const 'test'), 'test'
it ':make_ref', ->
- result = SigStream.num 2
+ result = T.num\mk_sig 2
input = Input.hot result
op = op_with_inputs { input }
thick = RTNode :result, :op, children: { RTNode!, RTNode! }
@@ -65,10 +62,10 @@ describe 'RTNode', ->
assert.is.nil ref.op
it 'lifts up inputs from op', ->
- event = EvtStream bang
+ event = T.bang\mk_evt!
event_input = Input.hot event
- value = SigStream num, 4
+ value = T.num\mk_sig 4
value_input = Input.hot value
op = op_with_inputs { event_input, value_input }
@@ -79,10 +76,10 @@ describe 'RTNode', ->
node.side_inputs
it 'does not lift up op inputs that are also child values', ->
- event = EvtStream bang
+ event = T.bang\mk_evt!
event_input = Input.hot event
- result = SigStream num, 4
+ result = T.num\mk_sig 4
value_input = Input.hot result
op = op_with_inputs { event_input, value_input }
@@ -91,12 +88,12 @@ describe 'RTNode', ->
assert.is.same { [event]: event_input }, node.side_inputs
it 'lifts up side_inputs from children', ->
- event_value = EvtStream bang
+ event_value = T.bang\mk_evt!
event_input = Input.hot event_value
event = RTNode op: op_with_inputs { event_input }
assert.is.same { [event_value]: event_input }, event.side_inputs
- value_value = SigStream num, 4
+ value_value = T.num\mk_sig 4
value_input = Input.hot value_value
value = RTNode op: op_with_inputs { value_input }
assert.is.same { [value_value]: value_input }, value.side_inputs
@@ -109,11 +106,11 @@ describe 'RTNode', ->
local a_value, a_child, a_input
local b_value, b_child, b_input
before_each ->
- a_value = EvtStream num
+ a_value = T.num\mk_evt!
a_input = Input.hot a_value
a_child = node_with_sideinput a_value, a_input
- b_value = EvtStream num
+ b_value = T.num\mk_evt!
b_input = Input.hot b_value
b_child = node_with_sideinput b_value, b_input
diff --git a/spec/scope_spec.moon b/spec/scope_spec.moon
index 7278b9e..637b5f5 100644
--- a/spec/scope_spec.moon
+++ b/spec/scope_spec.moon
@@ -1,4 +1,4 @@
-import Scope, Primitive, Constant, RTNode from require 'alv'
+import Scope, T, Constant, RTNode from require 'alv'
import Op from require 'alv.base'
import Logger from require 'alv.logger'
Logger\init 'silent'
@@ -8,11 +8,6 @@ class TestOp extends Op
wrap_res = (result) -> RTNode :result
-num = Primitive 'num'
-str = Primitive 'str'
-opdef = Primitive 'opdef'
-scope_t = Primitive 'scope'
-
describe 'Scope', ->
describe 'constifies', ->
scope = Scope!
@@ -38,21 +33,21 @@ describe 'Scope', ->
scope\set_raw 'test', TestOp
got = (scope\get 'test')\const!
- assert.is.equal TestOp, got opdef
+ assert.is.equal TestOp, got T.opdef
test 'Scopes', ->
sub = Scope!
scope\set_raw 'sub', sub
got = (scope\get 'sub')\const!
- assert.is.equal sub, got scope_t
+ assert.is.equal sub, got T.scope
test 'tables', ->
pi = Constant.num 3.14
scope\set_raw 'math', { :pi }
got = (scope\get 'math')\const!
- assert.is.equal scope_t, got.type
+ assert.is.equal T.scope, got.type
assert.is.equal Scope, got.value.__class
assert.is.equal pi, (got.value\get 'pi')\const!
assert.is.equal pi, (scope\get 'math/pi')\const!
@@ -68,18 +63,18 @@ describe 'Scope', ->
}
got = (scope\get 'num')\const!
- assert.is.equal 3, got num
+ assert.is.equal 3, got T.num
got = (scope\get 'str')\const!
- assert.is.equal "im a happy string", got str
+ assert.is.equal "im a happy string", got T.str
assert.is.equal pi, (scope\get 'pi')\const!
got = (scope\get 'test')\const!
- assert.is.equal TestOp, got opdef
+ assert.is.equal TestOp, got T.opdef
got = (scope\get 'math')\const!
- assert.is.equal scope_t, got.type
+ assert.is.equal T.scope, got.type
assert.is.equal pi, (scope\get 'math/pi')\const!
it 'gets from nested scopes', ->
@@ -116,13 +111,13 @@ describe 'Scope', ->
it 'allows access', ->
got = (scope\get 'inherited')\const!
- assert.is.equal "inherited string", got str
+ assert.is.equal "inherited string", got T.str
it 'can be shadowed', ->
scope\set_raw 'hidden', "overwritten"
got = (scope\get 'hidden')\const!
- assert.is.equal "overwritten", got str
+ assert.is.equal "overwritten", got T.str
describe 'dynamic inheritance', ->
root = Scope!
diff --git a/spec/type_spec.moon b/spec/type_spec.moon
index 14d7894..d33fcb4 100644
--- a/spec/type_spec.moon
+++ b/spec/type_spec.moon
@@ -1,5 +1,5 @@
require 'spec.test_setup'
-import Primitive, Array, Struct from require 'alv'
+import T, Primitive, Array, Struct from require 'alv'
bool = Primitive 'bool'
num = Primitive 'num'
@@ -43,3 +43,36 @@ describe 'Struct', ->
assert.not.equal play, Struct { note: str }
assert.not.equal play, Struct { note: str, dur: str }
assert.not.equal play, Struct { note: str, dur: num, extra: num }
+
+describe 'T', ->
+ it 'provides shorthand for Primitives', ->
+ assert.is.equal num, T.num
+ assert.is.equal str, T.str
+ assert.is.equal (Primitive 'midi/evt'), T['midi/evt']
+
+for type in *{num, str, (Array 3, num)}
+ describe "#{type}", ->
+ describe ':mk_sig', ->
+ it 'can create value-less Streams', ->
+ stream = type\mk_sig!
+ assert.is.equal 'SigStream', stream.__class.__name
+ assert.is.equal type, stream.type
+ assert.is.nil stream!
+
+ it 'can take an initial value', ->
+ stream = type\mk_sig 4
+ assert.is.equal 'SigStream', stream.__class.__name
+ assert.is.equal type, stream.type
+ assert.is.equal 4, stream!
+
+ describe ':mk_const', ->
+ it 'takes a value', ->
+ stream = type\mk_const 4
+ assert.is.equal 'Constant', stream.__class.__name
+ assert.is.equal type, stream.type
+ assert.is.equal 4, stream!
+
+ describe ':mk_evt', ->
+ stream = type\mk_evt!
+ assert.is.equal 'EvtStream', stream.__class.__name
+ assert.is.equal type, stream.type