-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from raymondfeng/feature/enable-session-halt
Allow session.halt even for `match()`
- Loading branch information
Showing
9 changed files
with
183 additions
and
46 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
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
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,2 @@ | ||
"use strict"; | ||
require('./flow/index'); |
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,36 @@ | ||
"use strict"; | ||
var it = require("it"), | ||
nools = require("../../"), | ||
assert = require("assert"); | ||
|
||
it.describe("#matchHalt", function (it) { | ||
|
||
function Count(c) { | ||
this.count = c; | ||
} | ||
|
||
var session, flow = nools.flow("Match with halt Flow", function (flow) { | ||
|
||
flow.rule("Stop", [Count, "c", "c.count == 6"], function () { | ||
this.halt(); | ||
}); | ||
|
||
flow.rule("Inc", [Count, "c"], function (facts) { | ||
facts.c.count++; | ||
this.modify(facts.c); | ||
}); | ||
|
||
}); | ||
|
||
it.beforeEach(function () { | ||
session = flow.getSession(new Count(0)); | ||
}); | ||
|
||
it.should("stop match with halt", function () { | ||
return session.match().then(function (err) { | ||
assert.isUndefinedOrNull(err); | ||
assert.equal(session.getFacts(Count)[0].count, 6); | ||
}); | ||
|
||
}); | ||
}); |
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