Skip to content

Commit

Permalink
Remove m postfix from all_ws() (#108)
Browse files Browse the repository at this point in the history
* remove m postfix

* add test

normalize \r\n to \n on the test runner + make line-comment absorb \r\n correctly.
  • Loading branch information
saschanaz committed Nov 3, 2017
1 parent 8f7c37e commit 407aaef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/webidl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
let w = t.value;
const re = {
"ws": /^([\t\n\r ]+)/,
"line-comment": /^\/\/(.*)\n?/m,
"line-comment": /^\/\/(.*)\r?\n?/,
"multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\//
};
const wsTypes = [];
Expand Down
2 changes: 1 addition & 1 deletion test/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("Parses all of the IDLs to produce the correct ASTs", () => {
if (fs.existsSync(optFile))
opt = JSON.parse(fs.readFileSync(optFile, "utf8"));
const diff = jdp.diff(JSON.parse(fs.readFileSync(json, "utf8")),
wp.parse(fs.readFileSync(idl, "utf8"), opt));
wp.parse(fs.readFileSync(idl, "utf8").replace(/\r\n/g, "\n"), opt));
if (diff && debug) console.log(JSON.stringify(diff, null, 4));
expect(diff).toBe(undefined);
}
Expand Down
2 changes: 2 additions & 0 deletions test/syntax/idl/linecomment.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* first */
// second
14 changes: 14 additions & 0 deletions test/syntax/json/linecomment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"type": "multiline-comment",
"value": " first "
},
{
"type": "ws",
"value": "\n"
},
{
"type": "line-comment",
"value": " second"
}
]
3 changes: 3 additions & 0 deletions test/syntax/opt/linecomment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ws": true
}

0 comments on commit 407aaef

Please sign in to comment.