Skip to content

Commit f4a1be4

Browse files
committed
glayzzle#78 reproduce error with tests
1 parent 737ded3 commit f4a1be4

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/exprTests.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Test expressions', function() {
8787
'$a > 5 ? true : false;',
8888
'$a ?: false;'
8989
].join('\n'));
90-
console.log(ast.children[1]);
90+
//console.log(ast.children[1]);
9191
ast.children[1].kind.should.be.exactly('retif');
9292

9393
});
@@ -209,6 +209,32 @@ describe('Test expressions', function() {
209209
ast.children[3].type.should.be.exactly('-');
210210
});
211211

212+
it('should fail to assign constants', function() {
213+
var ast = parser.parseEval('a = 1;', {
214+
parser: { debug: false, suppressErrors: true }
215+
});
216+
var msg = 'Parse Error : syntax error, unexpected \'=\' on line 1';
217+
ast.errors.length.should.be.exactly(1);
218+
ast.errors[0].message.should.be.exactly(msg);
219+
});
220+
221+
it('should fail to assign class constants', function() {
222+
var ast = parser.parseEval('foo::b = 1;', {
223+
parser: { debug: false, suppressErrors: true }
224+
});
225+
var msg = 'Parse Error : syntax error, unexpected \'=\' on line 1';
226+
ast.errors.length.should.be.exactly(1);
227+
ast.errors[0].message.should.be.exactly(msg);
228+
});
229+
230+
it('should assign class static', function() {
231+
var ast = parser.parseEval('a::$b = 1;', {
232+
parser: { debug: false, suppressErrors: true }
233+
});
234+
ast.errors.length.should.be.exactly(0);
235+
ast.children[0].kind.should.be.exactly('assign');
236+
});
237+
212238
it('test new', function() {
213239
var ast = parser.parseEval([
214240
'$a = new \\foo();',

0 commit comments

Comments
 (0)