Add tests to handle revised template literals (#764)

This commit is contained in:
Tim Disney 2016-10-03 13:59:53 -07:00 committed by Tom Care
parent 19a4278eb0
commit 9d8d8b6920
12 changed files with 153 additions and 8 deletions

View File

@ -0,0 +1,70 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Invalid unicode escape sequence in tagged template literals are allowed
esid: sec-template-literal-lexical-components
---*/
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\01');
})`\01`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\1');
})`\1`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\1');
})`\xg`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\1');
})`\xAg`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u0');
})`\u0`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u0g');
})`\u0g`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u00g');
})`\u00g`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u000g');
})`\u000g`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u{g');
})`\u{g`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u{0');
})`\u{0`;
(strs => {
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u{10FFFFF}');
})`\u{10FFFFF}`;
((strs, val) => {
assert.sameValue(val, 'inner');
assert.sameValue(strs[0], undefined, 'Cooked template value should be undefined for illegal escape sequences');
assert.sameValue(strs.raw[0], '\\u{10FFFFF}');
assert.sameValue(strs[1], 'right');
assert.sameValue(strs.raw[1], 'right');
})`\u{10FFFFF}${'inner'}right`;

View File

@ -1,11 +1,8 @@
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 11.8.6.1
esid: sec-template-literal-lexical-components
description: Invalid hexidecimal character escape sequence
info: >
The TV of TemplateCharacter :: \ EscapeSequence is the SV of
EscapeSequence.
negative: SyntaxError
---*/

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid hexidecimal character escape sequence
negative: SyntaxError
---*/
`\x0G`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid hexidecimal character escape sequence
negative: SyntaxError
---*/
`\xG`;

View File

@ -1,11 +1,8 @@
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 11.8.6
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
info: >
The TV of TemplateCharacter :: \ EscapeSequence is the SV of
EscapeSequence.
negative: SyntaxError
---*/

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u0g`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u00g`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u000g`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u{g`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u{0`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u{10FFFFF}`;

View File

@ -0,0 +1,9 @@
// Copyright (C) 2016 Tim Disney. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-template-literal-lexical-components
description: Invalid unicode escape sequence
negative: SyntaxError
---*/
`\u{10FFFFF}${'inner'}right`;