From 3758f6a97c2af4b84af4ddeabd23c1c698eedad1 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 21 May 2018 12:19:48 -0400 Subject: [PATCH] Add tests for LineContinuation in StringLiteral --- .../string/line-continuation-double.js | 60 +++++++++++++++++++ .../string/line-continuation-single.js | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 test/language/literals/string/line-continuation-double.js create mode 100644 test/language/literals/string/line-continuation-single.js diff --git a/test/language/literals/string/line-continuation-double.js b/test/language/literals/string/line-continuation-double.js new file mode 100644 index 0000000000..d1795e1efc --- /dev/null +++ b/test/language/literals/string/line-continuation-double.js @@ -0,0 +1,60 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-string-literals +description: > + Line terminators may occur within string literals as part of a |LineContinuation| + to produce the empty code points sequence. +info: | + 11.8.4 String Literals + + StringLiteral :: + `"` DoubleStringCharacters? `"` + `'` SingleStringCharacters? `'` + + DoubleStringCharacters :: + DoubleStringCharacter DoubleStringCharacters? + + DoubleStringCharacter :: + SourceCharacter but not one of `"` or `\` or LineTerminator + + + `\` EscapeSequence + LineContinuation + + LineContinuation :: + `\` LineTerminatorSequence + + 11.3 Line Terminators + + LineTerminatorSequence :: + + [lookahead != ] + + + + + 11.8.4.2 Static Semantics: SV + + The SV of DoubleStringCharacter :: LineContinuation is the empty code unit sequence. +---*/ + +// LineTerminatorSequence :: +assert.sameValue("\ +", ""); + +// LineTerminatorSequence :: [lookahead ≠ ] +assert.sameValue("\ ", ""); + +// LineTerminatorSequence :: +// is U+2028 LINE SEPARATOR; UTF8(0x2028) = 0xE2 0x80 0xA8 +assert.sameValue("\
", ""); + +// LineTerminatorSequence :: +// is U+2029 PARAGRAPH SEPARATOR; UTF8(0x2029) = 0xE2 0x80 0xA9 +assert.sameValue("\
", ""); + +// LineTerminatorSequence :: +assert.sameValue("\ +", ""); diff --git a/test/language/literals/string/line-continuation-single.js b/test/language/literals/string/line-continuation-single.js new file mode 100644 index 0000000000..3e286b0f87 --- /dev/null +++ b/test/language/literals/string/line-continuation-single.js @@ -0,0 +1,60 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-literals-string-literals +description: > + Line terminators may occur within string literals as part of a |LineContinuation| + to produce the empty code points sequence. +info: | + 11.8.4 String Literals + + StringLiteral :: + `"` DoubleStringCharacters? `"` + `'` SingleStringCharacters? `'` + + SingleStringCharacters :: + SingleStringCharacter SingleStringCharacters? + + SingleStringCharacter :: + SourceCharacter but not one of `'` or `\` or LineTerminator + + + `\` EscapeSequence + LineContinuation + + LineContinuation :: + `\` LineTerminatorSequence + + 11.3 Line Terminators + + LineTerminatorSequence :: + + [lookahead != ] + + + + + 11.8.4.2 Static Semantics: SV + + The SV of SingleStringCharacter :: LineContinuation is the empty code unit sequence. +---*/ + +// LineTerminatorSequence :: +assert.sameValue('\ +', ''); + +// LineTerminatorSequence :: [lookahead ≠ ] +assert.sameValue('\ ', ''); + +// LineTerminatorSequence :: +// is U+2028 LINE SEPARATOR; UTF8(0x2028) = 0xE2 0x80 0xA8 +assert.sameValue('\
', ''); + +// LineTerminatorSequence :: +// is U+2029 PARAGRAPH SEPARATOR; UTF8(0x2029) = 0xE2 0x80 0xA9 +assert.sameValue('\
', ''); + +// LineTerminatorSequence :: +assert.sameValue('\ +', '');