Adding tests for RepeatSpec nodes

This commit is contained in:
Jeff Avallone 2014-12-19 21:00:38 -05:00
parent 8669d0c4bc
commit 8c8fbf648d

View File

@ -0,0 +1,34 @@
import javascript from 'src/js/parser/javascript/parser.js';
describe('parser/javascript/repeat_spec.js', function() {
it('parses "{n,m}" as a RepeatSpec (with minimum and maximum values)', function() {
var parser = new javascript.Parser('{24,42}');
expect(parser.__consume__repeat_spec()).toEqual(jasmine.objectContaining({
minimum: 24,
maximum: 42
}));
});
it('parses "{n,}" as a RepeatSpec (with only minimum value)', function() {
var parser = new javascript.Parser('{24,}');
expect(parser.__consume__repeat_spec()).toEqual(jasmine.objectContaining({
minimum: 24,
maximum: -1
}));
});
it('parses "{n}" as a RepeatSpec (with an exact count)', function() {
var parser = new javascript.Parser('{24}');
expect(parser.__consume__repeat_spec()).toEqual(jasmine.objectContaining({
minimum: 24,
maximum: 24
}));
});
it('does not parse "{,m}" as a RepeatSpec', function() {
var parser = new javascript.Parser('{,42}');
expect(parser.__consume__repeat_spec()).toEqual(null);
});
});