From 7a7db7e0b2f3782a90528f6dbdf84ecd0ce47291 Mon Sep 17 00:00:00 2001 From: s-ol Date: Fri, 14 Aug 2020 10:56:18 +0200 Subject: document and spec Type member fields --- spec/type_spec.moon | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'spec') diff --git a/spec/type_spec.moon b/spec/type_spec.moon index 2ffdb49..0293385 100644 --- a/spec/type_spec.moon +++ b/spec/type_spec.moon @@ -10,6 +10,11 @@ describe 'Primitive', -> it 'inherits from Type', -> assert.is.equal Type, ancestor Primitive.__class + it 'exposes name', -> + assert.is.equal 'bool', bool.name + assert.is.equal 'num', num.name + assert.is.equal 'str', str.name + it 'stringifies well', -> assert.is.equal 'bool', tostring bool assert.is.equal 'num', tostring num @@ -48,6 +53,14 @@ describe 'Array', -> it 'inherits from Type', -> assert.is.equal Type, ancestor Array.__class + it 'exposes size', -> + assert.is.equal 3, vec3.size + assert.is.equal 2, str32.size + + it 'exposes inner type', -> + assert.is.equal num, vec3.type + assert.is.equal (Array 3, str), str32.type + it 'stringifies well', -> assert.is.equal 'num[3]', tostring vec3 assert.is.equal 'my-type[3][24]', tostring Array 24, Array 3, 'my-type' @@ -93,6 +106,10 @@ describe 'Struct', -> it 'inherits from Type', -> assert.is.equal Type, ancestor Struct.__class + it 'exposes inner types', -> + assert.is.same { note: str, dur: num }, play.types + assert.is.same { c: num, b: num, a: num }, abc.types + 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