-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9fb9b4
commit d53b140
Showing
5 changed files
with
75 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import stream from '../../lib/stream/index'; | ||
import {C,N} from '../../lib/parsec/index'; | ||
|
||
const eol = C.char('\n') | ||
|
||
export default { | ||
setUp: function (done) { | ||
done(); | ||
}, | ||
|
||
'expect line 1 is ok': function (test) { | ||
const string = '007'; | ||
// tests here | ||
const parser = N.integer(); | ||
const response = parser.parse(stream.ofString(string)); | ||
|
||
test.equal(1, response.line()); | ||
test.done(); | ||
}, | ||
'expect line 2 is ok': function (test) { | ||
const string = '007\n12'; | ||
// tests here | ||
const parser = N.integer().then(eol).then(N.integer()); | ||
const response = parser.parse(stream.ofString(string)); | ||
|
||
test.equal(2, response.line()); | ||
test.done(); | ||
}, | ||
'multiline is ok': function (test) { | ||
const string = '007\n\n12'; | ||
// tests here | ||
const parser = N.integer().then(eol).then(N.integer()); | ||
const response = parser.parse(stream.ofString(string)); | ||
|
||
test.equal(3, response.line()); | ||
test.done(); | ||
}, | ||
'not finished parser is ok': function (test) { | ||
const string = '007\nab\n12'; | ||
// tests here | ||
const parser = N.integer().then(eol).then(N.integer()); | ||
const response = parser.parse(stream.ofString(string)); | ||
|
||
test.equal(2, response.line()); | ||
test.equal(false, response.isAccepted()); | ||
test.done(); | ||
}, | ||
'first lines is ok and windows': function (test) { | ||
const string = '\n007\nab\n12'; | ||
// tests here | ||
const parser = eol.then(N.integer()).then(eol).then(N.integer()); | ||
const response = parser.parse(stream.ofString(string)); | ||
|
||
test.equal(3, response.line()); | ||
test.equal(false, response.isAccepted()); | ||
test.done(); | ||
} | ||
|
||
|
||
|
||
} |
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