Explorar o código

ref #3359: NotMatchExpression tests passing.

Brennan Chesley %!s(int64=12) %!d(string=hai) anos
pai
achega
7d28094fd7

+ 3 - 3
lib/pipeline/matcher/MatchDetails.js

@@ -38,7 +38,7 @@ proto.elemMatchKey = function elemMatchKey(){
  */
 proto.hasElemMatchKey = function hasElemMatchKey(){
 	// File: match_details.cpp lines: 37-38
-	return this._elemMatchKey.get();
+	return this._elemMatchKey;
 };
 
 /**
@@ -87,7 +87,7 @@ proto.requestElemMatchKey = function requestElemMatchKey(){
 proto.resetOutput = function resetOutput(){
 	// File: match_details.cpp lines: 32-34
 	this._loadedRecord = false;
-	this._elemMatchKey.reset();
+	this._elemMatchKey = undefined;
 };
 
 /**
@@ -100,7 +100,7 @@ proto.resetOutput = function resetOutput(){
 proto.setElemMatchKey = function setElemMatchKey(elemMatchKey){
 	// File: match_details.cpp lines: 46-49
 	if ( this._elemMatchKeyRequested ) {
-		this._elemMatchKey.reset(elemMatchKey);
+		this._elemMatchKey = elemMatchKey;
 	}
 };
 

+ 18 - 2
test/lib/pipeline/matcher/NotMatchExpression.js

@@ -2,7 +2,8 @@
 var assert = require("assert"),
 	NotMatchExpression = require("../../../../lib/pipeline/matcher/NotMatchExpression"),
 	LTMatchExpression = require("../../../../lib/pipeline/matcher/LTMatchExpression"), 
-	GTMatchExpression = require("../../../../lib/pipeline/matcher/GTMatchExpression");	
+	GTMatchExpression = require("../../../../lib/pipeline/matcher/GTMatchExpression"),
+	MatchDetails = require("../../../../lib/pipeline/matcher/MatchDetails");
 
 module.exports = {
 	"NotMatchExpression": {
@@ -22,8 +23,23 @@ module.exports = {
 			assert.ok( op.matches({'a': [6]}) , '{$not: {$lt: 5}}, {a: [6]}');	
 			assert.ok( !op.matches({'a': [4]}) , '{$not: {$lt: 5}}, {a: [4]}');	
 			assert.ok( !op.matches({'a': [4,5,6]}) , '{$not: {$lt: 5}}, {a: [4,5,6]}');
-			}
+		},
+		"Should not have an ElemMatchKey": function() {
+			var lt = new LTMatchExpression();
+			assert.strictEqual(lt.init('a',5)['code'],'OK');
+			var op = new NotMatchExpression();
+			assert.strictEqual( op.init( lt )['code'],'OK');
+			var details = new MatchDetails();
+			details.requestElemMatchKey();
+			assert.ok( ! op.matches({'a':[1]}, details), '{$not: {a: {$lt : 5}}}, {a: [1]}' );
+			assert.ok( ! details.hasElemMatchKey() , 'ElemMatchKey Check');
+			assert.ok( op.matches({'a': 6 }, details), '{$not: {a: {$lt : 5}}},{a: 6}');
+			assert.ok( ! details.hasElemMatchKey(), 'ElemMatchKey Check');
+			assert.ok( op.matches({'a':[6]}, details), '{$not: {a: {$lt : 5}}}, {a:[6]}');
+			assert.ok( ! details.hasElemMatchKey() );
 		}
+	}
+		
 };
 
 if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);