Skip to content

Commit

Permalink
test/language/literals/regexp/*: early error test fixups (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron authored and leobalter committed Oct 16, 2017
1 parent e6df792 commit 5d4c667
Show file tree
Hide file tree
Showing 46 changed files with 698 additions and 185 deletions.
26 changes: 20 additions & 6 deletions test/language/literals/regexp/7.8.5-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 7.8.5-1
description: >
Literal RegExp Objects - SyntaxError exception is thrown if the
RegularExpressionNonTerminator position of a
esid: prod-RegularExpressionBackslashSequence
info: |
RegularExpressionBackslashSequence ::
\ RegularExpressionNonTerminator
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
SyntaxError exception is thrown if the RegularExpressionNonTerminator position of a
RegularExpressionBackslashSequence is a LineTerminator.
description: >
A RegularExpressionBackslashSequence may not contain a LineTerminator.
---*/


assert.throws(SyntaxError, function() {
eval("var regExp = /\\\rn/;");
eval("/\\\rn/;");
/*
The result of this string is:
"/\
n/;"
*/
});
35 changes: 28 additions & 7 deletions test/language/literals/regexp/7.8.5-1gs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 7.8.5-1gs
description: Empty literal RegExp should result in a SyntaxError
negative:
phase: early
type: SyntaxError
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionLiteral ::
/ RegularExpressionBody / RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
SourceCharacter ::
any Unicode code point
RegularExpressionNonTerminator::
SourceCharacter but not LineTerminator
description: >
RegularExpressionBody will never be empty, because RegularExpressionFirstChar must always be _something_. // is a comment.
---*/

throw "Test262: This statement should not be evaluated.";
var y = 42;
var x = //.source;
y;

assert.sameValue(x, y);

var re = //;
4 changes: 2 additions & 2 deletions test/language/literals/regexp/S7.8.5_A1.1_T1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: >
info: |
RegularExpressionFirstChar :: NonTerminator but not * or \ or /,
RegularExpressionChars :: [empty], RegularExpressionFlags :: [empty]
es5id: 7.8.5_A1.1_T1
Expand All @@ -12,7 +12,7 @@ description: Without eval
//CHECK#1
if (/1/.source !== "1") {
$ERROR('#1: /1/');
}
}

//CHECK#2
if (/a/.source !== "a") {
Expand Down
15 changes: 11 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.2_T1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: * or \\ or / or [empty] is incorrect"
es5id: 7.8.5_A1.2_T1
description: "*"
esid: prod-RegularExpressionFirstChar
info: |
RegularExpressionChars ::
[empty]
RegularExpressionCharsRegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
description: >
The first character of a regular expression may not be "*"
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
/*/
18 changes: 14 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.2_T2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: * or \\ or / or [empty] is incorrect"
es5id: 7.8.5_A1.2_T2
description: \
esid: sec-literals-regular-expression-literals
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
description: >
The first character of a regular expression may not be "\"
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
/\/
18 changes: 14 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.2_T3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: * or \\ or / or [empty] is incorrect"
es5id: 7.8.5_A1.2_T3
description: /
esid: sec-literals-regular-expression-literals
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
description: >
The first character of a regular expression may not be "/"
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
///
.source;
18 changes: 14 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.2_T4.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: * or \\ or / or [empty] is incorrect"
es5id: 7.8.5_A1.2_T4
description: "[empty]"
esid: sec-literals-regular-expression-literals
info: |
RegularExpressionLiteral::
/ RegularExpressionBody / RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars::
[empty]
MemberExpression . IdentifierName
description: A regular expression may not be empty.
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
//
.source;
21 changes: 17 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.3_T1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: LineTerminator is incorrect"
es5id: 7.8.5_A1.3_T1
description: Line Feed, without eval
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
description: >
The first character of a regular expression may not be a <LF> (\u000A)
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
/
/
22 changes: 18 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.3_T2.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: LineTerminator is incorrect"
es5id: 7.8.5_A1.3_T2
description: Line Feed, with eval
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
description: >
The first character of a regular expression may not be a <LF> (\u000A), evaluated
---*/

//CHECK#1
try {
eval("/\u000A/").source;
$ERROR('#1.1: RegularExpressionFirstChar :: Line Feed is incorrect. Actual: ' + (eval("/\u000A/").source));
$ERROR('#1.1: RegularExpressionFirstChar :: Line Feed is incorrect. Actual: ' + (eval("/\u000A/").source));
}
catch (e) {
if ((e instanceof SyntaxError) !== true) {
Expand Down
21 changes: 17 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.3_T3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: LineTerminator is incorrect"
es5id: 7.8.5_A1.3_T3
description: Carriage Return, without eval
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
description: >
The first character of a regular expression may not be a <CR>, (\u000D)
negative:
phase: early
type: SyntaxError
---*/

throw "Test262: This statement should not be evaluated.";

//CHECK#1
/
/
22 changes: 18 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.3_T4.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: LineTerminator is incorrect"
es5id: 7.8.5_A1.3_T4
description: Carriage Return, with eval
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
description: >
The first character of a regular expression may not be a <CR>, (\u000D), evaluated
---*/

//CHECK#1
try {
eval("/\u000D/").source;
$ERROR('#1.1: RegularExpressionFirstChar :: Carriage Return is incorrect. Actual: ' + (eval("/\u000D/").source));
$ERROR('#1.1: RegularExpressionFirstChar :: Carriage Return is incorrect. Actual: ' + (eval("/\u000D/").source));
}
catch (e) {
if ((e instanceof SyntaxError) !== true) {
Expand Down
23 changes: 19 additions & 4 deletions test/language/literals/regexp/S7.8.5_A1.3_T5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: "RegularExpressionFirstChar :: LineTerminator is incorrect"
es5id: 7.8.5_A1.3_T5
description: Line separator, with eval
esid: prod-RegularExpressionNonTerminator
info: |
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of * or \ or / or [
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
description: >
The first character of a regular expression may not be a <LS>, (\u2028), evaluated
---*/

//CHECK#1
try {
eval("/\u2028/").source;
$ERROR('#1.1: RegularExpressionFirstChar :: Line separator is incorrect. Actual: ' + (eval("/\u2028/").source));
$ERROR('#1.1: RegularExpressionFirstChar :: Line separator is incorrect. Actual: ' + (eval("/\u2028/").source));
}
catch (e) {
if ((e instanceof SyntaxError) !== true) {
Expand Down
Loading

0 comments on commit 5d4c667

Please sign in to comment.