Skip to content

Commit

Permalink
adding and updating test cases for "lexer ES6 arrow functions in acti…
Browse files Browse the repository at this point in the history
…on code" issue: zaach/jison-lex#23
  • Loading branch information
GerHobbelt committed Dec 13, 2017
1 parent 8758ceb commit dbbce60
Show file tree
Hide file tree
Showing 8 changed files with 992 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
moduleType: "commonjs",
debug: false,
enableDebugLogs: false,
json: false,
json: true,
dumpSourceCodeOnFailure: true,
throwErrorOnCompileFailure: true,
defaultModuleName: "lexer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
moduleType: "commonjs",
debug: false,
enableDebugLogs: false,
json: false,
json: true,
dumpSourceCodeOnFailure: true,
throwErrorOnCompileFailure: true,
defaultModuleName: "lexer",
Expand Down
27 changes: 27 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-alt-good.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// title: Parse error when using arrow function in rules
// test_input: A a B C 1 + 2 + 3
// ...
//
// This is the SUCCESSFUL lexer spec
//

let grammar = {
rules: [
['\\s+', ''],
['\\d+', 'return "NUMBER"'],
['\\w+', `
if (yytext === 'a') {
return 'TOK_A';
} else {
return 'WORD';
}
`
],
['\\+', 'return "+"'],
['$', 'return "EOF"'],
]
};

module.exports = grammar;
// export default grammar;

303 changes: 303 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-alt-good.js-ref.json5

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-good.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// title: Parse error when using arrow function in rules
// test_input: A a B C 1 + 2 + 3
// ...
//
// This is the SUCCESSFUL lexer spec
//

let grammar = {
rules: [
['\\s+', ''],
['\\d+', function () { return 'NUMBER'}],
['\\w+', function () {
if (yytext === 'a') {
return 'TOK_A';
} else {
return 'WORD';
}
}
],
['\\+', function () { return '+' }],
['$', function () { return 'EOF' }],
]
};

module.exports = grammar;
// export default grammar;

303 changes: 303 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-good.js-ref.json5

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-trouble.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// title: Parse error when using arrow function in rules
// test_input: A a B C 1 + 2 + 3
// ...
//
// This is the FAILING lexer spec
//

let grammar = {
rules: [
['\\s+', ''],
['\\d+', () => 'NUMBER'],
['\\w+', () => {
if (yytext === 'a') {
return 'TOK_A';
} else {
return 'WORD';
}
}
],
['\\+', () => '+'],
['$', () => 'EOF'],
]
};

module.exports = grammar;
// export default grammar;

303 changes: 303 additions & 0 deletions packages/jison-lex/tests/specs/003-issue-23-trouble.js-ref.json5

Large diffs are not rendered by default.

0 comments on commit dbbce60

Please sign in to comment.