浏览代码

EAGLESIX-2721: test cases adjusted

Jake Delaney 11 年之前
父节点
当前提交
afedc10559
共有 2 个文件被更改,包括 6 次插入18 次删除
  1. 2 0
      lib/pipeline/expressions/ConcatExpression.js
  2. 4 18
      test/lib/pipeline/expressions/ConcatExpression_test.js

+ 2 - 0
lib/pipeline/expressions/ConcatExpression.js

@@ -29,6 +29,7 @@ proto.getOpName = function getOpName(){
  * @method evaluate
  **/
 proto.evaluateInternal = function evaluateInternal(vars) {
+	console.log("Here");
 	var n = this.operands.length,
 		result = "";
 
@@ -37,6 +38,7 @@ proto.evaluateInternal = function evaluateInternal(vars) {
 		var value = this.operands[i].evaluateInternal(vars);
 
 		if (value === null || value === undefined){
+			console.log("... and nullish");
 			return null;
 		}
 

+ 4 - 18
test/lib/pipeline/expressions/ConcatExpression_test.js

@@ -48,24 +48,10 @@ module.exports = {
 			"should return mystring if operands are my and $a; {$concat:[my,$a]}": function testFieldPath(){
 				assert.equal(Expression.parseOperand({$concat:["my","$a"]}, this.vps).evaluate({a:"string"}), "mystring");
 			},
-
-			//NOTE: DEVIATION FROM MONGO: I can't find the test cases for $concat.  The following test
-			// causes an exception as will any other non-string operand. I don't know the authority for
-			// defining the behavior.
-//			"should return null if an operand evaluates to null; {$concat:[my,$a]}": function testNull(){
-//				var a = Expression.parseOperand({$concat:["my","$a"]}, this.vps);
-//				var b = a.evaluate({a:null});
-//				assert.equal(b, null);
-//			},
-			"should throw if an operand is a null": function testNull(){
-				assert.throws(function(){
-					Expression.parseOperand({$concat:["my","$a"]}, this.vps).evaluate({a:null});
-				});
-			},
-			"should throw if an operand is a null (2)": function testNull(){
-				assert.throws(function(){
-					Expression.parseOperand({$concat:[null,"$a"]}, this.vps).evaluate({a:"hello"});
-				});
+			"should return null if an operand evaluates to null; {$concat:[my,$a]}": function testNull(){
+				var a = Expression.parseOperand({$concat:["my","$a"]}, this.vps);
+				var b = a.evaluate({a:null});
+				assert.equal(b, null);
 			},
 			"should throw if an operand is a number": function testNull(){
 				assert.throws(function(){