Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed issue with `CustomConstraint` not binding `this.assert` to `this`. #146 - @raymondfeng * Added more tests for custom constraints * Updated readme to include docs about custom constraints.
- Loading branch information
1 parent
2c6d31b
commit 51fbe1e
Showing
12 changed files
with
143 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
nools.iml | ||
.idea | ||
atlassian-ide-plugin.xml | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
var it = require("it"), | ||
assert = require("assert"), | ||
declare = require("declare.js"), | ||
nools = require("../../"); | ||
it.describe("custom contraint rule", function (it) { | ||
|
||
var called = 0; | ||
var HelloFact = declare({ | ||
instance: { | ||
value: true, | ||
constructor: function (value) { | ||
this.value = value; | ||
} | ||
} | ||
}); | ||
|
||
var flow = nools.flow("custom contraint", function (flow) { | ||
flow.rule("hello rule", [HelloFact, "h", function (facts) { | ||
return !!facts.h.value; | ||
}], function () { | ||
called++; | ||
}); | ||
}); | ||
|
||
it.should("call hello world rule", function () { | ||
var session = flow.getSession(); | ||
session.assert(new HelloFact(false)); | ||
session.assert(new HelloFact(true)); | ||
return session.match().then(function () { | ||
assert.equal(called, 1); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters