From 1069a033e51efb7fa61cebf8348b86afe4e541e5 Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 12 Aug 2017 19:54:21 +0200 Subject: [PATCH] Added some unit tests --- test/core/typed.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/core/typed.test.js b/test/core/typed.test.js index 386f54c38..99504898c 100644 --- a/test/core/typed.test.js +++ b/test/core/typed.test.js @@ -236,6 +236,17 @@ describe ('typed', function () { assert.strictEqual(math.type.isAssignmentNode(), false); }); + it('should test whether a value is an AccessorNode', function () { + var a = new math.expression.node.SymbolNode('a'); + var index = new math.expression.node.IndexNode([new math.expression.node.ConstantNode('b')]); + + assert.strictEqual(math.type.isAccessorNode(new math.expression.node.AccessorNode(a, index)), true); + assert.strictEqual(math.type.isAccessorNode(new math2.expression.node.AccessorNode(a, index)), true); + assert.strictEqual(math.type.isAccessorNode({isAccessorNode: true}), false); + assert.strictEqual(math.type.isAccessorNode(2), false); + assert.strictEqual(math.type.isAccessorNode(), false); + }); + it('should test whether a value is a BlockNode', function () { assert.strictEqual(math.type.isBlockNode(new math.expression.node.BlockNode([])), true); assert.strictEqual(math.type.isBlockNode(new math2.expression.node.BlockNode([])), true); @@ -244,6 +255,14 @@ describe ('typed', function () { assert.strictEqual(math.type.isBlockNode(), false); }); + it('should test whether a value is a ObjectNode', function () { + assert.strictEqual(math.type.isObjectNode(new math.expression.node.ObjectNode({})), true); + assert.strictEqual(math.type.isObjectNode(new math2.expression.node.ObjectNode({})), true); + assert.strictEqual(math.type.isObjectNode({isObjectNode: true}), false); + assert.strictEqual(math.type.isObjectNode(2), false); + assert.strictEqual(math.type.isObjectNode(), false); + }); + it('should test whether a value is a ConditionalNode', function () { var c = new math.expression.node.SymbolNode(''); var t = new math.expression.node.ConstantNode(1);