aboutsummaryrefslogtreecommitdiffstats
path: root/spec/type_spec.moon
diff options
context:
space:
mode:
Diffstat (limited to 'spec/type_spec.moon')
-rw-r--r--spec/type_spec.moon35
1 files changed, 34 insertions, 1 deletions
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