Skip to content

Commit 8f7162f

Browse files
0.0.50, fix Production test
1 parent 4e3c158 commit 8f7162f

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/dist
22
node_modules/
3-
.npm-debug.log
3+
.npm-debug.log
4+
npm-debug.log

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "syntax-cli",
3-
"version": "0.0.49",
3+
"version": "0.0.50",
44
"description": "Syntactic analysis toolkit, language agnostic parsers generator.",
55
"repository": {
66
"type": "git",

src/grammar/__tests__/production-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const mockGrammar = {
1515
'+': {assoc: "left", precedence: 1},
1616
};
1717
},
18+
19+
usesDefaultSematicActions() {
20+
return false;
21+
},
1822
};
1923

2024
const productionData = {
@@ -100,6 +104,23 @@ describe('production', () => {
100104
expect(production.runSemanticAction(args)).toBe(undefined);
101105
});
102106

107+
it('default action', () => {
108+
let production = new Production({
109+
...productionData,
110+
RHS: `'foo'`,
111+
semanticAction: null,
112+
grammar: {
113+
...mockGrammar,
114+
usesDefaultSematicActions() {
115+
return true;
116+
},
117+
}
118+
});
119+
120+
const defaultAction = '$$ = $1';
121+
expect(production.getRawSemanticAction()).toBe(defaultAction);
122+
});
123+
103124
it('epsilon', () => {
104125
let production = new Production({...productionData, RHS: EPSILON});
105126
expect(production.isEpsilon()).toBe(true);

0 commit comments

Comments
 (0)