it ('should map a ConstantNode', function () { var a = new ConstantNode(2); var b = a.map(function () { assert.ok(false, 'should not execute, constant has no childs') }); assert.notStrictEqual(b, a); assert.deepEqual(b, a); });
parallel('config', () => { it('should set conifg', () => { const execute = Aigle.prototype._execute; Aigle.config({ cancellation: true }); assert.notStrictEqual(Aigle.prototype._execute, execute); Aigle.config({ cancellation: false }); assert.strictEqual(Aigle.prototype._execute, execute); }); it('should not throw any errors even if config is empty', () => { Aigle.config(); }); });
it ('should transform an AccessorNode itself', function () { var a = new SymbolNode('a'); var b = new ConstantNode(2); var c = new ConstantNode(1); var n = new AccessorNode(a, new IndexNode([b, c])); var e = new ConstantNode(5); var f = n.transform(function (node) { return node instanceof AccessorNode ? e : node; }); assert.notStrictEqual(f, n); assert.deepEqual(f, e); });
it('should work setTimeout the same functionality as util.promisify', () => { const setTimeoutPromise = Aigle.promisify(setTimeout); const str = 'foobar'; assert.notStrictEqual(setTimeoutPromise, setTimeout[custom]); const promise = setTimeoutPromise(DELAY, str).then((value) => assert.strictEqual(value, str)); assert.ok(promise instanceof Aigle); return promise; });
it('should work with setImmediate even if util promisify does not exist', () => { util.promisify = null; const Aigle = require(aiglepath); const setTimeoutPromise = Aigle.promisify(setTimeout); assert.notStrictEqual(setTimeoutPromise, setTimeout[custom]); const str = 'foobar'; return setTimeoutPromise(DELAY, str).then((value) => assert.strictEqual(value, str)); });
it('should create ActionQueueEntry with an action type and unique id', () => { const entry1 = ActionQueueEntry.create('sendPigeon'); const entry2 = ActionQueueEntry.create('sendPigeon'); assert.strictEqual(entry1.getActionType(), 'sendPigeon'); assert.notStrictEqual(entry1.getActionId(), entry2.getActionId()); });
it ('should transform a RangeNodes without step', function () { var start = new ConstantNode(0); var end = new ConstantNode(10); var n = new RangeNode(start, end); var e = new ConstantNode(3); var f = n.transform(function (node) { return node instanceof ConstantNode && node.value == '10' ? e : node; }); assert.notStrictEqual(f, n); assert.deepEqual(f.start, start); assert.deepEqual(f.end, e); });
it ('should clone a SymbolNode', function () { var a = new SymbolNode('x'); var b = a.clone(); assert(b instanceof SymbolNode); assert.deepEqual(a, b); assert.notStrictEqual(a, b); assert.equal(a.name, b.name); });
it ('should clone a ParenthesisNode', function () { var a = new ConstantNode(1); var n = new ParenthesisNode(a); var clone = n.clone(); assert(clone instanceof ParenthesisNode); assert.deepEqual(n, clone); assert.notStrictEqual(n, clone); assert.equal(n.content, clone.content); });
it('should resize a scalar into a scalar', function() { var x = math.complex(2, 3); var y = math.resize(x, []); assert.deepEqual(x, y); assert.notStrictEqual(x, y); });
it ('should transform an IndexNodes (nested) parameters', function () { var b = new ConstantNode(2); var c = new ConstantNode(1); var n = new IndexNode([b, c]); var e = new SymbolNode('c'); var f = n.transform(function (node) { return node.isConstantNode && node.value === '1' ? e : node; }); assert.notStrictEqual(f, n); assert.deepEqual(f.dimensions[0], b); assert.deepEqual(f.dimensions[1], e); });
it('should work with an empty Map', () => { const tasks = new Map(); return Aigle.props(tasks).then((res) => { assert.ok(res instanceof Map); assert.notStrictEqual(res, tasks); }); });
it ('should transform an ArrayNode itself', function () { // [x, 2] var a = new SymbolNode('x'); var b = new ConstantNode(2); var c = new ArrayNode([a, b]); var d = new ConstantNode(3); var e = c.transform(function (node) { return (node instanceof ArrayNode) ? d : node; }); assert.notStrictEqual(e, c); assert.deepEqual(e, d); });
it('should clone a NumberFormatter', function () { var a = new NumberFormatter(2.3); var clone = a.clone(); assert.deepEqual(clone, a); assert.notStrictEqual(clone, a); });
it ('should transform an OperatorNode itself', function () { // x^2-x var a = new SymbolNode('x'); var b = new ConstantNode(2); var c = new OperatorNode('+', 'add', [a, b]); var f = new ConstantNode(3); var g = c.transform(function (node) { return node instanceof OperatorNode ? f : node; }); assert.notStrictEqual(g, c); assert.deepEqual(g, f); });