nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: josdejong/mathjs
Pull request #375 (2015-05-18 15:13:17)

Adding Utility isPositiveInteger function + test


Patch:
diff --git a/lib/util/bignumber.js b/lib/util/bignumber.js
index a4ef68b23..7a92a0473 100644
--- a/lib/util/bignumber.js
+++ b/lib/util/bignumber.js
@@ -1406,3 +1406,21 @@ exports.toFixed = function(value, precision) {
   // Note: the (precision || 0) is needed as the toFixed of BigNumber has an
   // undefined default precision instead of 0.
 };
+
+/**
+* Determines if n is a positive integer
+* @param {Number} n   Value to determine if it is a positive integer
+* @return {Boolean}   Whether the number is positive
+*/
+exports.isPositiveInteger = function(n) {
+  if (n instanceof BigNumber && n.isInteger() && n.gt(0)) {
+    return true;
+  }
+
+  if (isNumber(n) && n.isInteger() && n > 0) {
+    return true;
+  }
+
+  return false;
+}
+
diff --git a/lib/util/number.js b/lib/util/number.js
index 9d82ebf5d..3ff7c7ecb 100644
--- a/lib/util/number.js
+++ b/lib/util/number.js
@@ -257,3 +257,4 @@ exports.nearlyEqual = function(x, y, epsilon) {
   // Infinite and Number or negative Infinite and positive Infinite cases
   return false;
 };
+


Test patch:
diff --git a/test/util/bignumber.test.js b/test/util/bignumber.test.js
index 359b2586d..319f34e2d 100644
--- a/test/util/bignumber.test.js
+++ b/test/util/bignumber.test.js
@@ -278,4 +278,27 @@ describe('bignumber', function() {
 
   });
 
+    it('should determine if input is a integer', function() {
+        assert.equal(bignumber.isPositiveInteger([new BigNumber(1)]), false);
+        assert.equal(bignumber.isPositiveInteger(false), false);
+        assert.equal(bignumber.isPositiveInteger('test'), false);
+        assert.equal(bignumber.isPositiveInteger({a:new BigNumber(1)}), false);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(0.1)), false);
+    });
+
+    it('should determine if integer is positive', function() {
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(1)), true);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(0)), false);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(0)), false);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(-0)), false);
+    });
+
+    it('should determine if BigNumber is positive', function() {
+        BigNumber = require('decimal.js');
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(10)), true);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(-10)), false);
+        assert.equal(bignumber.isPositiveInteger(new BigNumber(100000)), true);
+    });
+
 });
+
Repository: josdejong/mathjs
Pull request #532 (2016-01-05 09:59:13)

ConditionalNode: simplify LaTeX by using the 'cases' environment
While discussing how the LaTeX output of ObjectNodes should look like, I thought that the `cases` environment should be used for ConditionalNodes, not the `array` environment.

This pull request doesn't change what the ConditionalNode looks like (except for one space character after the "if").


Patch:
diff --git a/lib/expression/node/ConditionalNode.js b/lib/expression/node/ConditionalNode.js
index ab2f68a9b..fe84efbde 100644
--- a/lib/expression/node/ConditionalNode.js
+++ b/lib/expression/node/ConditionalNode.js
@@ -165,11 +165,11 @@ function factory (type, config, load, typed) {
    * @return {string} str
    */
   ConditionalNode.prototype._toTex = function (options) {
-    return '\\left\\{\\begin{array}{l l}{'
-        + this.trueExpr.toTex(options) + '}, &\\quad{\\text{if}\\;'
+    return '\\begin{cases} {'
+        + this.trueExpr.toTex(options) + '}, &\\quad{\\text{if }\\;'
         + this.condition.toTex(options)
         + '}\\\\{' + this.falseExpr.toTex(options)
-        + '}, &\\quad{\\text{otherwise}}\\end{array}\\right.';
+        + '}, &\\quad{\\text{otherwise}}\\end{cases}';
   };
 
   return ConditionalNode;


Test patch:
diff --git a/test/expression/node/ConditionalNode.test.js b/test/expression/node/ConditionalNode.test.js
index 9b857090b..ef7f7e672 100644
--- a/test/expression/node/ConditionalNode.test.js
+++ b/test/expression/node/ConditionalNode.test.js
@@ -289,7 +289,7 @@ describe('ConditionalNode', function() {
   it ('should LaTeX a ConditionalNode', function () {
     var n = new ConditionalNode(condition, a, b);
 
-    assert.equal(n.toTex(), '\\left\\{\\begin{array}{l l}{a:=2}, &\\quad{\\text{if}\\;true}\\\\{b:=3}, &\\quad{\\text{otherwise}}\\end{array}\\right.');
+    assert.equal(n.toTex(), '\\begin{cases} {a:=2}, &\\quad{\\text{if }\\;true}\\\\{b:=3}, &\\quad{\\text{otherwise}}\\end{cases}');
   });
 
   it ('should LaTeX a ConditionalNode with custom toTex', function () {
diff --git a/test/expression/node/OperatorNode.test.js b/test/expression/node/OperatorNode.test.js
index 89e441f2e..68cbcfdcc 100644
--- a/test/expression/node/OperatorNode.test.js
+++ b/test/expression/node/OperatorNode.test.js
@@ -497,7 +497,7 @@ describe('OperatorNode', function() {
     var cond = new ConditionalNode(a, a, a);
     var pow = new OperatorNode('^', 'pow', [cond, a]);
 
-    assert.equal(pow.toTex(), '\\left({\\left\\{\\begin{array}{l l}{1}, &\\quad{\\text{if}\\;1}\\\\{1}, &\\quad{\\text{otherwise}}\\end{array}\\right.}\\right)^{1}');
+    assert.equal(pow.toTex(), '\\left({\\begin{cases} {1}, &\\quad{\\text{if }\\;1}\\\\{1}, &\\quad{\\text{otherwise}}\\end{cases}}\\right)^{1}');
   });
 
   it ('should LaTeX simple expressions in \'auto\' mode', function () {
Repository: josdejong/mathjs
Pull request #747 (2016-11-11 04:59:34)

OperatorNode: fix: implicit multiplication was not cloned
- [x] Add test


Patch:
diff --git a/lib/expression/node/OperatorNode.js b/lib/expression/node/OperatorNode.js
index 73c183188..89dc2a24e 100644
--- a/lib/expression/node/OperatorNode.js
+++ b/lib/expression/node/OperatorNode.js
@@ -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);
   };
 
   /**


Test patch:
diff --git a/test/expression/node/OperatorNode.test.js b/test/expression/node/OperatorNode.test.js
index 39dad580b..912019b0c 100644
--- a/test/expression/node/OperatorNode.test.js
+++ b/test/expression/node/OperatorNode.test.js
@@ -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)]);
Repository: josdejong/mathjs
Pull request #805 (2017-03-06 15:33:08)

Fix xgcd for negative values


Patch:
diff --git a/lib/function/arithmetic/xgcd.js b/lib/function/arithmetic/xgcd.js
index 53da658fc..f28372ba3 100644
--- a/lib/function/arithmetic/xgcd.js
+++ b/lib/function/arithmetic/xgcd.js
@@ -59,7 +59,7 @@ function factory (type, config, load, typed) {
 
     while (b) {
       q = Math.floor(a / b);
-      r = a % b;
+      r = a - q*b;
 
       t = x;
       x = lastx - q * x;


Test patch:
diff --git a/test/function/arithmetic/xgcd.test.js b/test/function/arithmetic/xgcd.test.js
index 2b4897de3..d490b3485 100644
--- a/test/function/arithmetic/xgcd.test.js
+++ b/test/function/arithmetic/xgcd.test.js
@@ -60,8 +60,7 @@ describe('xgcd', function() {
     assert.deepEqual(xgcd(65, math.bignumber(40)), [math.bignumber(5), math.bignumber(-3), math.bignumber(5)]);
   });
 
-  // FIXME: xgcd for negative values
-  it.skip('should calculate xgcd for edge cases with negative values', function () {
+  it('should calculate xgcd for edge cases with negative values', function () {
     assert.deepEqual([1, -2, 1], xgcd(2, 5));
     assert.deepEqual([1, -2, -1], xgcd(2, -5));
     assert.deepEqual([1, 2, 1], xgcd(-2, 5));
Repository: josdejong/mathjs
Pull request #827 (2017-04-13 09:39:19)

simplify - rule to remove addition of zero


Patch:
diff --git a/lib/function/algebra/simplify.js b/lib/function/algebra/simplify.js
index cc3d5797c..1df6adc73 100644
--- a/lib/function/algebra/simplify.js
+++ b/lib/function/algebra/simplify.js
@@ -124,6 +124,7 @@ function factory (type, config, load, typed) {
   // To evaluate lhs constants for rhs constants, use: { l: 'c1+c2', r: 'c3', evaluate: 'c3 = c1 + c2' }. Multiple assignments are separated by ';' in block format.
   // It is possible to get into an infinite loop with conflicting rules
   simplify.rules = [
+    { l: 'n+0', r: 'n' },
     { l: 'n^0', r: '1' },
     { l: '0*n', r: '0' },
     { l: 'n/n', r: '1'},


Test patch:
diff --git a/test/function/algebra/simplify.test.js b/test/function/algebra/simplify.test.js
index d2fe7088f..94ea9d4a4 100644
--- a/test/function/algebra/simplify.test.js
+++ b/test/function/algebra/simplify.test.js
@@ -54,6 +54,11 @@ describe('simplify', function() {
     simplifyAndCompare('foo(x)', 'foo(x)');
   });
 
+  it('should remove addition of 0', function() {
+    simplifyAndCompare('x+0', 'x');
+    simplifyAndCompare('x-0', 'x');
+  });
+
   describe('expression parser' ,function () {
 
     it('should evaluate simplify containing string value', function() {
Repository: josdejong/mathjs
Pull request #850 (2017-05-10 07:55:49)

Added derivative of abs


Patch:
diff --git a/lib/function/algebra/derivative.js b/lib/function/algebra/derivative.js
index f859909d9..52e8293f6 100644
--- a/lib/function/algebra/derivative.js
+++ b/lib/function/algebra/derivative.js
@@ -528,6 +528,13 @@ function factory (type, config, load, typed) {
             ])
           ]);
           break;
+        case 'abs':
+          // d/dx(abs(x)) = abs(x)/x
+          funcDerivative = new OperatorNode('/', 'divide', [
+            new FunctionNode(new SymbolNode('abs'), [arg1.clone()]),
+            arg1.clone()
+          ]);
+          break;
         case 'gamma':  // Needs digamma function, d/dx(gamma(x)) = gamma(x)digamma(x)
         default: throw new Error('Function "' + node.name + '" not supported by derivative');
       }


Test patch:
diff --git a/test/function/algebra/derivative.test.js b/test/function/algebra/derivative.test.js
index 4305c037f..7e8f9402e 100644
--- a/test/function/algebra/derivative.test.js
+++ b/test/function/algebra/derivative.test.js
@@ -143,6 +143,7 @@ describe('derivative', function() {
     compareString(derivativeWithoutSimplify('asech((2x))', 'x'), '-(2 * 1) / ((2 x) * sqrt(1 - (2 x) ^ 2))');
     compareString(derivativeWithoutSimplify('acsch((2x))', 'x'), '-(2 * 1) / (abs((2 x)) * sqrt((2 x) ^ 2 + 1))');
     compareString(derivativeWithoutSimplify('acoth((2x))', 'x'), '-(2 * 1) / (1 - (2 x) ^ 2)');
+    compareString(derivativeWithoutSimplify('abs(2x)', 'x'), '2 * 1 * abs(2 x) / (2 x)');
     
     compareString(derivativeWithoutSimplify('exp(2x)', 'x'), '2 * 1 * exp(2 x)');
   });
Repository: josdejong/mathjs
Pull request #899 (2017-07-12 15:39:51)

Update isSafeProperty ghosting
Change condition for property ghosting to match desired behaviour as discussed in #888 :

- Ghosting custom properties are allowed
- Only ghosting properties on Function.prototype or Object.prototype are restricted


Patch:
diff --git a/lib/utils/customs.js b/lib/utils/customs.js
index af482f359..9cc1a57a6 100644
--- a/lib/utils/customs.js
+++ b/lib/utils/customs.js
@@ -54,7 +54,8 @@ function isSafeProperty (object, prop) {
   }
   // UNSAFE: ghosted
   // e.g length
-  if (hasOwnProperty(object, prop) && (prop in object.__proto__)) {
+  if (hasOwnProperty(object, prop) &&
+      (prop in Object.prototype || prop in Function.prototype)) {
     return false;
   }
   // SAFE: whitelisted


Test patch:
diff --git a/test/expression/security.test.js b/test/expression/security.test.js
index d5e382f8d..2aff9bd6c 100644
--- a/test/expression/security.test.js
+++ b/test/expression/security.test.js
@@ -194,7 +194,7 @@ describe('security', function () {
           'k(x)={map:j};' +
           'i={isIndex:true,isScalar:f,size:g,min:h,max:h,dimension:k};' +
           'subset(subset([[[0]]],i),index(1,1,1))("console.log(\'hacked...\')")()')
-    }, /TypeError: Index must be an integer \(value: constructor\)/);
+    }, /Error: No access to property "length"/);
   })
 
   it ('should not allow using restricted properties via subset (2)', function () {
diff --git a/test/utils/customs.test.js b/test/utils/customs.test.js
index 6a1602c68..096460292 100644
--- a/test/utils/customs.test.js
+++ b/test/utils/customs.test.js
@@ -123,6 +123,12 @@ describe ('customs', function () {
       array.length = Infinity;
       assert.equal(customs.isSafeProperty(array, 'length'), false);
 
+      // ghosted custom property
+      var object = {foo: true};
+      object = Object.create(object);
+      object.foo = false;
+      assert.equal(customs.isSafeProperty(object, 'foo'), true);
+
     });
 
   });
Repository: josdejong/mathjs
Pull request #900 (2017-07-14 12:19:10)

Remove ghosting from isSafeProperty
From discussion in #888 diallowing ghosting causes problems with natives such as `length` which is both an own property and on the prototype chain and on the root Function.prototype/Array.prototype etc.

There don't appear to be any security concerns for ghosting properties, only for methods.


Patch:
diff --git a/lib/utils/customs.js b/lib/utils/customs.js
index 9cc1a57a6..00ffb2b56 100644
--- a/lib/utils/customs.js
+++ b/lib/utils/customs.js
@@ -52,12 +52,6 @@ function isSafeProperty (object, prop) {
   if (!object || typeof object !== 'object') {
     return false;
   }
-  // UNSAFE: ghosted
-  // e.g length
-  if (hasOwnProperty(object, prop) &&
-      (prop in Object.prototype || prop in Function.prototype)) {
-    return false;
-  }
   // SAFE: whitelisted
   // e.g length
   if (hasOwnProperty(safeNativeProperties, prop)) {


Test patch:
diff --git a/test/expression/security.test.js b/test/expression/security.test.js
index 2aff9bd6c..d5e382f8d 100644
--- a/test/expression/security.test.js
+++ b/test/expression/security.test.js
@@ -194,7 +194,7 @@ describe('security', function () {
           'k(x)={map:j};' +
           'i={isIndex:true,isScalar:f,size:g,min:h,max:h,dimension:k};' +
           'subset(subset([[[0]]],i),index(1,1,1))("console.log(\'hacked...\')")()')
-    }, /Error: No access to property "length"/);
+    }, /TypeError: Index must be an integer \(value: constructor\)/);
   })
 
   it ('should not allow using restricted properties via subset (2)', function () {
diff --git a/test/utils/customs.test.js b/test/utils/customs.test.js
index 096460292..0da0ad16c 100644
--- a/test/utils/customs.test.js
+++ b/test/utils/customs.test.js
@@ -111,24 +111,6 @@ describe ('customs', function () {
       // non existing property
       assert.equal(customs.isSafeProperty(object, 'bar'), true);
 
-      // custom inherited property
-      var object = {};
-      object.foo = true;
-      object = Object.create(object);
-      assert.equal(customs.isSafeProperty(object, 'foo'), true);
-
-      // ghosted native property
-      var array = [];
-      array = Object.create(array);
-      array.length = Infinity;
-      assert.equal(customs.isSafeProperty(array, 'length'), false);
-
-      // ghosted custom property
-      var object = {foo: true};
-      object = Object.create(object);
-      object.foo = false;
-      assert.equal(customs.isSafeProperty(object, 'foo'), true);
-
     });
 
   });
Repository: josdejong/mathjs
Pull request #958 (2017-10-17 15:18:20)

Simplify nested exponentiations
I randomly stumbled upon this by noticing that the last expression I've added in the unit test (`8 * x ^ 9 + 2 * (x ^ 3) ^ 3`) doesn't simplify to `10 * x ^ 9` as expected.


Patch:
diff --git a/lib/function/algebra/simplify.js b/lib/function/algebra/simplify.js
index 86f60cc00..928ca8959 100644
--- a/lib/function/algebra/simplify.js
+++ b/lib/function/algebra/simplify.js
@@ -196,6 +196,9 @@ function factory (type, config, load, typed, math) {
     { l: 'n/n1^n2', r:'n*n1^-n2' }, // temporarily replace 'divide' so we can further flatten the 'multiply' operator
     { l: 'n/n1', r:'n*n1^-1' },
 
+    // expand nested exponentiation
+    { l: '(n ^ n1) ^ n2', r: 'n ^ (n1 * n2)'},
+
     // collect like factors
     { l: 'n*n', r: 'n^2' },
     { l: 'n * n^n1', r: 'n^(n1+1)' },
@@ -350,19 +353,27 @@ function factory (type, config, load, typed, math) {
 
         // Create a new node by cloning the rhs of the matched rule
         res = repl.clone();
-     
-        // Replace placeholders with their respective nodes without traversing deeper into the replaced nodes
-        var _transform = function(node) {
-          if(node.isSymbolNode && matches.placeholders.hasOwnProperty(node.name)) {
-            return matches.placeholders[node.name].clone();
+
+        // Replace placeholders with their respective nodes
+        // TODO: find a solution that doesn't rely on `.transformThisNode` to prevent an infinite recursive loop, 
+        //       maybe traverse the tree bottom up instead of top down?
+        //       See discussion: https://github.com/josdejong/mathjs/issues/948#issuecomment-333351446 
+        res.traverse(function(n, path, parent) {
+          if(n.isSymbolNode) {
+            n.transformThisNode = true;
           }
-          else {
-            return node.map(_transform);
+        });
+
+        res = res.transform(function(n, path, parent) {
+          if(n.transformThisNode) {
+            if(matches.placeholders.hasOwnProperty(n.name)) {
+              var replace = matches.placeholders[n.name].clone();
+              return replace;
+            }
           }
-        }
-        
-        res = _transform(res);
-        
+          return n;
+        });
+
         // var after = res.toString({parenthesis: 'all'});
         // console.log('Simplified ' + before + ' to ' + after);
       }


Test patch:
diff --git a/test/function/algebra/simplify.test.js b/test/function/algebra/simplify.test.js
index b1e913615..c79fd7b1e 100644
--- a/test/function/algebra/simplify.test.js
+++ b/test/function/algebra/simplify.test.js
@@ -149,6 +149,12 @@ describe('simplify', function() {
     simplifyAndCompare('x*2*x', '2*x^2');
   });
 
+  it('should handle nested exponentiation', function() {
+    simplifyAndCompare('(x^2)^3', 'x^6');
+    simplifyAndCompare('(x^y)^z', 'x^(y*z)');
+    simplifyAndCompare('8 * x ^ 9 + 2 * (x ^ 3) ^ 3', '10 * x ^ 9');
+  });
+
   it('should not run into an infinite recursive loop', function () {
     simplifyAndCompare('2n - 1', '2 * n - 1');
     simplifyAndCompare('16n - 1', '16 * n - 1');
Repository: josdejong/mathjs
Pull request #1026 (2018-01-25 19:15:27)

ConstantNode: Add Fraction specific latex output.


Patch:
diff --git a/lib/expression/node/ConstantNode.js b/lib/expression/node/ConstantNode.js
index f4a6dbae2..a4c6e2920 100644
--- a/lib/expression/node/ConstantNode.js
+++ b/lib/expression/node/ConstantNode.js
@@ -134,7 +134,6 @@ function factory (type, config, load, typed) {
 
       case 'number':
       case 'BigNumber':
-      case 'Fraction':
         var index = value.toLowerCase().indexOf('e');
         if (index !== -1) {
           return value.substring(0, index) + '\\cdot10^{' +
@@ -142,6 +141,9 @@ function factory (type, config, load, typed) {
         }
         return value;
 
+      case 'Fraction':
+        return this.value.toLatex();
+
       default:
         return value;
     }


Test patch:
diff --git a/test/expression/node/ConstantNode.test.js b/test/expression/node/ConstantNode.test.js
index 8bca81aed..53b812d8c 100644
--- a/test/expression/node/ConstantNode.test.js
+++ b/test/expression/node/ConstantNode.test.js
@@ -6,6 +6,7 @@ var bigmath = require('../../../index').create({number: 'BigNumber'});
 var Node = math.expression.node.Node;
 var ConstantNode = math.expression.node.ConstantNode;
 var SymbolNode = math.expression.node.SymbolNode;
+var Fraction = require('../../../lib/type/fraction/Fraction');
 
 describe('ConstantNode', function() {
 
@@ -184,4 +185,12 @@ describe('ConstantNode', function() {
     assert.equal(n.toTex({handler: customFunction}), 'const\\left(1\\right)');
   });
 
+  it ('should LaTeX a ConstantNode with a fraction', function () {
+    var positive = new ConstantNode(new math.type.Fraction(1.5));
+    var negative = new ConstantNode(new math.type.Fraction(-1.5));
+
+    assert.equal(positive.toTex(), '\\frac{3}{2}');
+    assert.equal(negative.toTex(), '-\\frac{3}{2}');
+  });
+
 });
Repository: josdejong/mathjs
Pull request #1029 (2018-01-27 14:59:48)

Bug: When mapping an OperatorNode implicit status is lost
I confused travis with #1028 so here I am trying again.

When calling `map` on an `OperatorNode` with `implicit === true` and `OperatorNode` with `implicit === false` is created.


Patch:
diff --git a/lib/expression/node/OperatorNode.js b/lib/expression/node/OperatorNode.js
index 88ce9b7fc..c7f5c58c0 100644
--- a/lib/expression/node/OperatorNode.js
+++ b/lib/expression/node/OperatorNode.js
@@ -113,7 +113,7 @@ function factory (type, config, load, typed) {
     for (var i = 0; i < this.args.length; i++) {
       args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this));
     }
-    return new OperatorNode(this.op, this.fn, args);
+    return new OperatorNode(this.op, this.fn, args, this.implicit);
   };
 
   /**


Test patch:
diff --git a/test/expression/node/OperatorNode.test.js b/test/expression/node/OperatorNode.test.js
index 91a4678c4..67d2b7b65 100644
--- a/test/expression/node/OperatorNode.test.js
+++ b/test/expression/node/OperatorNode.test.js
@@ -120,6 +120,14 @@ describe('OperatorNode', function() {
     assert.deepEqual(g.args[1],  f);
   });
 
+  it('should map an implicit OperatorNode', function () {
+    var x = new SymbolNode('x');
+    var y = new SymbolNode('y');
+    var product = new OperatorNode('*', 'multiply', [x, y], true /* implicit */);
+
+    assert.deepEqual(product.map(function(x) { return x; }), product);
+  });
+
   it ('should throw an error when the map callback does not return a node', function () {
     var a = new SymbolNode('x');
     var b = new ConstantNode(2);