Переглянути джерело

EAGLESIX-2353 - Moving code to check that there is a valid range of operands from NaryExpression to
a new extended version that will live in mungedb-aggregate-common.

Tony Ennis 11 роки тому
батько
коміт
a9e8032ffe

+ 0 - 12
lib/pipeline/expressions/NaryExpression.js

@@ -135,16 +135,4 @@ proto.checkArgLimit = function checkArgLimit(maxArgs) {
  **/
 proto.checkArgCount = function checkArgCount(reqArgs) {
 	if (this.operands.length !== reqArgs) throw new Error(this.getOpName() + ":  insufficient operands; " + reqArgs + " required, only got " + this.operands.length + "; code 15997");
-};
-
-/**
- * Checks the current size of vpOperand; if the size does not fall within the min and max values (inclusive), fires a user assertion indicating that this must have exactly reqArgs arguments.
- * This is meant to be used in evaluate(), *before* the evaluation takes place.
- *
- * @method checkArgCountRange
- * @param min the minimum number of valid arguments
- * @param max the maximum number of valid arguments
- **/
-proto.checkArgCountRange = function checkArgCountRange(min, max) {
-	if (this.operands.length < min || this.operands.length > max) throw new Error(this.getOpName() + ":  insufficient operands; between " + min + " and " + max + " required, only got " + this.operands.length + "; code 15996");
 };

+ 0 - 55
test/lib/pipeline/expressions/NaryExpression.js

@@ -124,61 +124,6 @@ module.exports = {
 			});
 		},
 
-		"#checkArgCountRange() sans operands": {
-			"should fail with Error if there are no arguments": function(){
-				var testableExpr = new TestableExpression();
-				assert.throws(function() {
-					testableExpr.checkArgCountRange(2, 4);
-				});
-			},
-			"should accept if there are no operands but the lower range is 0": function(){
-				var testableExpr = new TestableExpression();
-				assert.doesNotThrow(function() {
-					testableExpr.checkArgCountRange(0, 4);
-				});
-			}
-		},
-
-		"#checkArgCountRange()": {
-			before: function() {
-				this.testableExpr = new TestableExpression();
-				this.testableExpr.addOperand(new ConstantExpression("uno"));
-				this.testableExpr.addOperand(new ConstantExpression("dos"));
-				this.testableExpr.addOperand(new ConstantExpression("tres"));
-			},
-
-			"should throw Error if the number of arguments is too low": function () {
-				var t = this.testableExpr;
-				assert.throws(function() {
-					t.checkArgCountRange(4, 6);
-				});
-			},
-			"should throw Error if the number of arguments is too high": function () {
-				var t = this.testableExpr;
-				assert.throws(function() {
-					t.checkArgCountRange(1, 2);
-				});
-			},
-			"should accept if the number of arguments equals the minimum": function () {
-				var t = this.testableExpr;
-				assert.doesNotThrow(function() {
-					t.checkArgCountRange(3, 5);
-				});
-			},
-			"should accept if the number of arguments equals the maximum": function () {
-				var t = this.testableExpr;
-				assert.doesNotThrow(function() {
-					t.checkArgCountRange(1, 3);
-				});
-			},
-			"should accept if the number of arguments falls within the range": function () {
-				var t = this.testableExpr;
-				assert.doesNotThrow(function() {
-					t.checkArgCountRange(2, 4);
-				});
-			}
-		},
-		
 		//the following test case is eagerly awaiting ObjectExpression
 		"#addDependencies()": function testDependencies(){
 			var testableExpr = new TestableExpression();