@ -103,6 +103,11 @@ export function main() {
|
||||
|
||||
it('should parse grouped expressions', () => { checkAction("(1 + 2) * 3", "1 + 2 * 3"); });
|
||||
|
||||
it('should ignore comments in expressions', () => { checkAction('a //comment', 'a'); });
|
||||
|
||||
it('should retain // in string literals',
|
||||
() => { checkAction(`"http://www.google.com"`, `"http://www.google.com"`); });
|
||||
|
||||
it('should parse an empty string', () => { checkAction(''); });
|
||||
|
||||
describe("literals", () => {
|
||||
@ -269,6 +274,14 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should parse conditional expression', () => { checkBinding('a < b ? a : b'); });
|
||||
|
||||
it('should ignore comments in bindings', () => { checkBinding('a //comment', 'a'); });
|
||||
|
||||
it('should retain // in string literals',
|
||||
() => { checkBinding(`"http://www.google.com"`, `"http://www.google.com"`); });
|
||||
|
||||
it('should retain // in : microsyntax', () => { checkBinding('one:a//b', 'one:a//b'); });
|
||||
|
||||
});
|
||||
|
||||
describe('parseTemplateBindings', () => {
|
||||
@ -424,6 +437,31 @@ export function main() {
|
||||
it('should parse expression with newline characters', () => {
|
||||
checkInterpolation(`{{ 'foo' +\n 'bar' +\r 'baz' }}`, `{{ "foo" + "bar" + "baz" }}`);
|
||||
});
|
||||
|
||||
describe("comments", () => {
|
||||
it('should ignore comments in interpolation expressions',
|
||||
() => { checkInterpolation('{{a //comment}}', '{{ a }}'); });
|
||||
|
||||
it('should retain // in single quote strings', () => {
|
||||
checkInterpolation(`{{ 'http://www.google.com' }}`, `{{ "http://www.google.com" }}`);
|
||||
});
|
||||
|
||||
it('should retain // in double quote strings', () => {
|
||||
checkInterpolation(`{{ "http://www.google.com" }}`, `{{ "http://www.google.com" }}`);
|
||||
});
|
||||
|
||||
it('should ignore comments after string literals',
|
||||
() => { checkInterpolation(`{{ "a//b" //comment }}`, `{{ "a//b" }}`); });
|
||||
|
||||
it('should retain // in complex strings', () => {
|
||||
checkInterpolation(`{{"//a\'//b\`//c\`//d\'//e" //comment}}`, `{{ "//a\'//b\`//c\`//d\'//e" }}`);
|
||||
});
|
||||
|
||||
it('should retain // in nested, unterminated strings', () => {
|
||||
checkInterpolation(`{{ "a\'b\`" //comment}}`, `{{ "a\'b\`" }}`);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("parseSimpleBinding", () => {
|
||||
|
Reference in New Issue
Block a user