AndMatchExpression.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var assert = require("assert"),
  3. AndMatchExpression = require("../../../../lib/pipeline/matcher/AndMatchExpression"),
  4. LTMatchExpression = require("../../../../lib/pipeline/matcher/LTMatchExpression"),
  5. GTMatchExpression = require("../../../../lib/pipeline/matcher/GTMatchExpression"),
  6. RegexMatchExpression = require("../../../../lib/pipeline/matcher/RegexMatchExpression"),
  7. EqualityMatchExpression = require("../../../../lib/pipeline/matcher/EqualityMatchExpression"),
  8. NotMatchExpression = require("../../../../lib/pipeline/matcher/EqualityMatchExpression");
  9. module.exports = {
  10. "AndMatchExpression": {
  11. "Should match nothing with no clauses": function (){
  12. var op = new AndMatchExpression();
  13. assert.ok( op.matches({}));
  14. },
  15. "Should match with a three element clause": function() {
  16. var lt = new LTMatchExpression();
  17. var gt = new GTMatchExpression();
  18. var rgx = new RegexMatchExpression();
  19. var op = new AndMatchExpression();
  20. assert.strictEqual( lt.init('a','z1')['code'],'OK');
  21. assert.strictEqual( gt.init('a','a1')['code'],'OK');
  22. assert.strictEqual( rgx.init('a','1','')['code'],'OK');
  23. op.add(lt);
  24. op.add(gt);
  25. op.add(rgx);
  26. assert.ok( op.matches({'a':'r1'}) );
  27. assert.ok( ! op.matches({'a': 'z1'}) );
  28. assert.ok( ! op.matches({'a': 'a1'}) );
  29. assert.ok( ! op.matches({'a':'r'}) );
  30. },
  31. "Should match a single clause": function() {
  32. var nop = new NotMatchExpression();
  33. var eq = new EqualityMatchExpression();
  34. var op = new AndMatchExpression();
  35. assert.strictEqual( eq.init('a', 5)['code'],'OK');
  36. assert.strictEqual( nop.init(eq)['code'],'OK');
  37. op.add(nop);
  38. assert.ok( op.matches({'a':4}) );
  39. assert.ok( op.matches({'a':[4,6]}) );
  40. assert.ok( !op.matches({'a':5}) );
  41. assert.ok( !op.matches({'a'[4,5]}) );
  42. },
  43. "Should match three clauses": function(){
  44. // File expression_tree_test.cpp lines 144-168
  45. assert.ok(false, 'Fill out test');
  46. },
  47. "Should have an elemMatchKey": function(){
  48. // File expression_tree_test.cpp lines 170 - 195
  49. assert.ok(false, 'Fill out test');
  50. }
  51. }
  52. }
  53. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);