From 966eef2d6557eeffc5b5c7b379efc1f2e7d0de0b Mon Sep 17 00:00:00 2001 From: s-ol Date: Sun, 10 May 2020 16:25:09 +0200 Subject: make == --- spec/result/sig_spec.moon | 11 ++++++++++- spec/type_spec.moon | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/result/sig_spec.moon b/spec/result/sig_spec.moon index 4d04b9c..6e9a11c 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, T from require 'alv' +import SigStream, Constant, RTNode, Scope, SimpleRegistry, T from require 'alv' import Op, Builtin from require 'alv.base' class TestOp extends Op @@ -51,6 +51,15 @@ describe 'SigStream', -> assert.is.equal (SigStream T.num, 3), val assert.not.equal (SigStream T.num, 4), val + it 'can be compared to a Constant', -> + val = SigStream T.num, 3 + assert.is.equal (Constant.num 3), val + assert.not.equal (Constant.num 4), val + + val = SigStream T.str, 'hello' + assert.is.equal (Constant.str 'hello'), val + assert.not.equal (Constant.sym 'hello'), val + describe ':set', -> it 'sets the value', -> val = SigStream T.num, 3 diff --git a/spec/type_spec.moon b/spec/type_spec.moon index a435067..b6315f1 100644 --- a/spec/type_spec.moon +++ b/spec/type_spec.moon @@ -1,11 +1,15 @@ require 'spec.test_setup' -import T, Primitive, Array, Struct from require 'alv' +import T, Type, Primitive, Array, Struct from require 'alv.type' +import ancestor from require 'alv.util' bool = Primitive 'bool' num = Primitive 'num' str = Primitive 'str' describe 'Primitive', -> + it 'inherits from Type', -> + assert.is.equal Type, ancestor Primitive.__class + it 'stringifies well', -> assert.is.equal 'bool', tostring bool assert.is.equal 'num', tostring num @@ -35,6 +39,10 @@ describe 'Primitive', -> describe 'Array', -> vec3 = Array 3, num str32 = Array 2, Array 3, str + + it 'inherits from Type', -> + assert.is.equal Type, ancestor Array.__class + it 'stringifies well', -> assert.is.equal 'num[3]', tostring vec3 assert.is.equal 'my-type[3][24]', tostring Array 24, Array 3, 'my-type' @@ -65,6 +73,9 @@ describe 'Struct', -> play = Struct { note: str, dur: num } abc = Struct { c: num, b: num, a: num } + it 'inherits from Type', -> + assert.is.equal Type, ancestor Struct.__class + it 'stringifies well', -> assert.is.equal '{dur: num note: str}', tostring play assert.is.equal '{a: num b: num c: num}', tostring abc -- cgit v1.2.3