-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests twice to ensure full testing
- Loading branch information
1 parent
57c9c99
commit 8fd429f
Showing
3 changed files
with
44 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,43 @@ | ||
"use strict"; | ||
|
||
testSetUsage(function setUsage(api) { | ||
it(api.setTestDescription("Parsimmon.seq"), function() { | ||
var parser = Parsimmon.seq( | ||
Parsimmon.string("("), | ||
Parsimmon.regexp(/[^)]/) | ||
.many() | ||
.map(function(xs) { | ||
return xs.join(""); | ||
}), | ||
Parsimmon.string(")") | ||
); | ||
it("Parsimmon.seq", function() { | ||
var parser = Parsimmon.seq( | ||
Parsimmon.string("("), | ||
Parsimmon.regexp(/[^)]/) | ||
.many() | ||
.map(function(xs) { | ||
return xs.join(""); | ||
}), | ||
Parsimmon.string(")") | ||
); | ||
|
||
assert.deepEqual( | ||
api.scopeSet(function scopeSet() { | ||
return parser.parse("(string between parens)"); | ||
}).value, | ||
["(", "string between parens", ")"] | ||
); | ||
assert.deepEqual(parser.parse("(string between parens)").value, [ | ||
"(", | ||
"string between parens", | ||
")" | ||
]); | ||
|
||
assert.deepEqual( | ||
api.scopeSet(function scopeSet() { | ||
return parser.parse("(string"); | ||
}), | ||
{ | ||
status: false, | ||
index: { | ||
offset: 7, | ||
line: 1, | ||
column: 8 | ||
}, | ||
expected: ["')'", "/[^)]/"] | ||
} | ||
); | ||
assert.deepEqual(parser.parse("(string"), { | ||
status: false, | ||
index: { | ||
offset: 7, | ||
line: 1, | ||
column: 8 | ||
}, | ||
expected: ["')'", "/[^)]/"] | ||
}); | ||
|
||
assert.deepEqual( | ||
api.scopeSet(function scopeSet() { | ||
return parser.parse("starts wrong (string between parens)"); | ||
}), | ||
{ | ||
status: false, | ||
index: { | ||
offset: 0, | ||
line: 1, | ||
column: 1 | ||
}, | ||
expected: ["'('"] | ||
} | ||
); | ||
assert.deepEqual(parser.parse("starts wrong (string between parens)"), { | ||
status: false, | ||
index: { | ||
offset: 0, | ||
line: 1, | ||
column: 1 | ||
}, | ||
expected: ["'('"] | ||
}); | ||
|
||
assert.throws(function() { | ||
Parsimmon.seq("not a parser"); | ||
}); | ||
assert.throws(function() { | ||
Parsimmon.seq("not a parser"); | ||
}); | ||
}); |
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