mirror of
https://github.com/josdejong/mathjs.git
synced 2026-02-01 16:07:46 +00:00
Merge pull request #747 from josdejong/fix-operatornode-clone
OperatorNode: fix: implicit multiplication was not cloned
This commit is contained in:
commit
e19fedcd42
@ -101,7 +101,7 @@ function factory (type, config, load, typed, math) {
|
||||
* @return {OperatorNode}
|
||||
*/
|
||||
OperatorNode.prototype.clone = function () {
|
||||
return new OperatorNode(this.op, this.fn, this.args.slice(0));
|
||||
return new OperatorNode(this.op, this.fn, this.args.slice(0), this.implicit);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -176,6 +176,16 @@ describe('OperatorNode', function() {
|
||||
assert.strictEqual(d.args[1], c.args[1]);
|
||||
});
|
||||
|
||||
it ('should clone implicit multiplications', function () {
|
||||
var two = new ConstantNode(2);
|
||||
var x = new SymbolNode('x');
|
||||
var node = new OperatorNode('*', 'multiply', [two, x], true);
|
||||
|
||||
assert.equal('2 x', node.toString());
|
||||
assert.strictEqual(true, node.clone().implicit);
|
||||
assert.equal(node.toString(), node.clone().toString());
|
||||
});
|
||||
|
||||
it ('test equality another Node', function () {
|
||||
var a = new OperatorNode('+', 'add', [new SymbolNode('x'), new ConstantNode(2)]);
|
||||
var b = new OperatorNode('+', 'add', [new SymbolNode('x'), new ConstantNode(2)]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user