Fixing character set ranges
Certain escape sequences are not considered in ranges, and lead to the hyphen to be part of the matched set of characters
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import javascript from 'src/js/parser/javascript/parser.js';
|
||||
import util from 'src/js/util.js';
|
||||
import Q from 'q';
|
||||
import _ from 'lodash';
|
||||
|
||||
describe('parser/javascript/charset_range.js', function() {
|
||||
|
||||
@@ -17,6 +18,20 @@ describe('parser/javascript/charset_range.js', function() {
|
||||
}));
|
||||
});
|
||||
|
||||
_.each([
|
||||
'\\d-a',
|
||||
'\\D-a',
|
||||
'\\s-a',
|
||||
'\\S-a',
|
||||
'\\w-a',
|
||||
'\\W-a'
|
||||
], str => {
|
||||
it(`does not parse "${str}" as a CharsetRange`, function() {
|
||||
var parser = new javascript.Parser(str);
|
||||
expect(parser.__consume__charset_range()).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an exception when the range is out of order', function() {
|
||||
var parser = new javascript.Parser('z-a');
|
||||
expect(() => {
|
||||
|
||||
Reference in New Issue
Block a user