Skip to content

Commit

Permalink
_js: make the interactive test a bit more complete
Browse files Browse the repository at this point in the history
In particular, include a line where there's a complete and incomplete
statement.
  • Loading branch information
mvdan committed Feb 25, 2019
1 parent 170fa2e commit 9fc0272
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions _js/testmain.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,31 @@ const printer = syntax.NewPrinter()

{
// using the parser interactively
const inputs = [
const lines = [
"foo\n",
"bar; baz\n",
"\n",
"'incom\n",
"foo; 'incom\n",
"plete'\n",
]
const wantCallbacks = [
{"count": 1, "incomplete": false},
{"count": 2, "incomplete": false},
{"count": 0, "incomplete": false},
{"count": 0, "incomplete": true},
{"count": 1, "incomplete": false},
{"count": 1, "incomplete": true},
{"count": 2, "incomplete": false},
]
var gotCallbacks = []

const src = {"read": function(size) {
if (inputs.length == 0) {
if (lines.length == 0) {
if (gotCallbacks.length == 0) {
throw "did not see any callbacks before EOF"
}
return null // EOF
}
s = inputs[0]
inputs.shift()
s = lines[0]
lines.shift()
return s
}}

Expand Down

0 comments on commit 9fc0272

Please sign in to comment.