AndMatchExpression.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. module.exports = {
  9. "AndMatchExpression": {
  10. "Should match nothing with no clauses": function (){
  11. var op = new AndMatchExpression();
  12. assert.ok( op.matches({}));
  13. },
  14. "Should match with a three element clause": function() {
  15. var lt = new LTMatchExpression();
  16. var gt = new GTMatchExpression();
  17. var rgx = new RegexMatchExpression();
  18. var op = new AndMatchExpression();
  19. assert.strictEqual( lt.init('a','z1')['code'],'OK');
  20. assert.strictEqual( gt.init('a','a1')['code'],'OK');
  21. assert.strictEqual( rgx.init('a','1','')['code'],'OK');
  22. op.add(lt);
  23. op.add(gt);
  24. op.add(rgx);
  25. assert.ok( op.matches({'a':'r1'}) );
  26. assert.ok( ! op.matches({'a': 'z1'}) );
  27. debugger;
  28. assert.ok( ! op.matches({'a': 'a1'}) );
  29. assert.ok( ! op.matches({'a':'r'}) );
  30. }
  31. }
  32. }
  33. if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);