Browse Source

ref #3359: And tests added, need to be filled out.

Brennan Chesley 12 years ago
parent
commit
4b77ff5b0d
1 changed files with 28 additions and 7 deletions
  1. 28 7
      test/lib/pipeline/matcher/AndMatchExpression.js

+ 28 - 7
test/lib/pipeline/matcher/AndMatchExpression.js

@@ -4,8 +4,8 @@ var assert = require("assert"),
 	LTMatchExpression = require("../../../../lib/pipeline/matcher/LTMatchExpression"),
 	GTMatchExpression = require("../../../../lib/pipeline/matcher/GTMatchExpression"),
 	RegexMatchExpression = require("../../../../lib/pipeline/matcher/RegexMatchExpression"),
-	EqualityMatchExpression = require("../../../../lib/pipeline/matcher/EqualityMatchExpression");
-
+	EqualityMatchExpression = require("../../../../lib/pipeline/matcher/EqualityMatchExpression"),
+	NotMatchExpression = require("../../../../lib/pipeline/matcher/EqualityMatchExpression");
 
 
 module.exports = {
@@ -19,23 +19,44 @@ module.exports = {
 			var gt = new GTMatchExpression();
 			var rgx = new RegexMatchExpression();
 			var op = new AndMatchExpression();
-
 			assert.strictEqual( lt.init('a','z1')['code'],'OK');
 			assert.strictEqual( gt.init('a','a1')['code'],'OK');
 			assert.strictEqual( rgx.init('a','1','')['code'],'OK');
-			
 			op.add(lt);
 			op.add(gt);
 			op.add(rgx);
-
 			assert.ok( op.matches({'a':'r1'}) );
 			assert.ok( ! op.matches({'a': 'z1'}) );
-			debugger;
 			assert.ok( ! op.matches({'a': 'a1'}) );
 			assert.ok( ! op.matches({'a':'r'}) );
-			}
+		},
+		"Should match a single clause": function() {
+			var nop = new NotMatchExpression();
+			var eq = new EqualityMatchExpression();
+			var op = new AndMatchExpression();
 
+			assert.strictEqual( eq.init('a', 5)['code'],'OK');	
+			assert.strictEqual( nop.init(eq)['code'],'OK');
+			op.add(nop);
+			assert.ok( op.matches({'a':4}) );
+			assert.ok( op.matches({'a':[4,6]}) );
+			assert.ok( !op.matches({'a':5}) );
+			assert.ok( !op.matches({'a'[4,5]}) );
+		},
+		"Should match three clauses": function(){
+		// File expression_tree_test.cpp lines 144-168
+		
+			assert.ok(false, 'Fill out test');
+
+		},
+		"Should have an elemMatchKey": function(){
+		// File expression_tree_test.cpp lines 170 - 195
+		
+			assert.ok(false, 'Fill out test');
 		}
+
+
+	}
 }
 
 if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);