diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 850b23b2c8d136da37d5f362f27ae857eede2715..042a9f633c537f509bf51e7a9c4fe06d546d5b17 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,6 +117,9 @@ This tag is for boolean properties associated with the test. - **`noStrict`** - only run the test in "sloppy" mode - **`module`** - interpret the source text as [module code](http://www.ecma-international.org/ecma-262/6.0/#sec-modules) +- **`raw`** - execute the test without any modification (no helpers will be + available); necessary to test the behavior of directive prologue; implies + `noStrict` #### features **features**: [list] diff --git a/test/language/directive-prologue/10.1.1-2gs.js b/test/language/directive-prologue/10.1.1-2gs.js index da0a123e97b6efbda59efd1dd722d513afb12cd0..a0edb25a18639e9e01f921279cef0a43f32dcbd8 100644 --- a/test/language/directive-prologue/10.1.1-2gs.js +++ b/test/language/directive-prologue/10.1.1-2gs.js @@ -9,10 +9,10 @@ es5id: 10.1.1-2gs description: > Strict Mode - Use Strict Directive Prologue is ''use strict'' which lost the last character ';' -negative: NotEarlyError -flags: [noStrict] +negative: SyntaxError +flags: [raw] ---*/ "use strict" -throw NotEarlyError; +throw new Error("This code should not execute"); var public = 1; diff --git a/test/language/directive-prologue/10.1.1-5gs.js b/test/language/directive-prologue/10.1.1-5gs.js index 5b31cfe11a27995f546fa0446730181a8aa275f3..b396268ca9b2f448ffcb4cf38ee398a97f68caa3 100644 --- a/test/language/directive-prologue/10.1.1-5gs.js +++ b/test/language/directive-prologue/10.1.1-5gs.js @@ -9,10 +9,10 @@ es5id: 10.1.1-5gs description: > Strict Mode - Use Strict Directive Prologue is ''use strict';' which appears at the start of the code -negative: NotEarlyError -flags: [noStrict] +negative: SyntaxError +flags: [raw] ---*/ "use strict"; -throw NotEarlyError; +throw new Error("This code should not execute"); var public = 1; diff --git a/test/language/directive-prologue/10.1.1-8gs.js b/test/language/directive-prologue/10.1.1-8gs.js index 5d141ad06a046bedbc3a13754a8eae1d4ff2d7a5..a45d7832ab7aab3c013f4e417902000ffbd2906f 100644 --- a/test/language/directive-prologue/10.1.1-8gs.js +++ b/test/language/directive-prologue/10.1.1-8gs.js @@ -9,8 +9,8 @@ es5id: 10.1.1-8gs description: > Strict Mode - Use Strict Directive Prologue is ''use strict';' which appears twice in the code -negative: NotEarlyError -flags: [noStrict] +negative: SyntaxError +flags: [raw] ---*/ "use strict"; diff --git a/test/language/directive-prologue/14.1-4gs.js b/test/language/directive-prologue/14.1-4gs.js index e9a439bbe611a306261aa7c543d16890d8c718ba..4abecb876851df35dae5a2e31b30eb4d7dcd0cbc 100644 --- a/test/language/directive-prologue/14.1-4gs.js +++ b/test/language/directive-prologue/14.1-4gs.js @@ -10,9 +10,9 @@ description: > StrictMode - a Use Strict Directive followed by a strict mode violation negative: SyntaxError -flags: [onlyStrict] +flags: [raw] ---*/ "use strict"; -throw NotEarlyError; +throw new Error("This code should not execute"); eval = 42; diff --git a/test/language/directive-prologue/14.1-5gs.js b/test/language/directive-prologue/14.1-5gs.js index 92ce007eedc583cd4ca4368b08e37df7a9129d4a..71b27087a6e756b8a8e5726c774e5f9c67054379 100644 --- a/test/language/directive-prologue/14.1-5gs.js +++ b/test/language/directive-prologue/14.1-5gs.js @@ -10,11 +10,11 @@ description: > StrictMode - a Use Strict Directive embedded in a directive prologue followed by a strict mode violation negative: SyntaxError -flags: [onlyStrict] +flags: [raw] ---*/ "a"; "use strict"; "c"; -throw NotEarlyError; +throw new Error("This code should not execute"); eval = 42; diff --git a/tools/packaging/test262.py b/tools/packaging/test262.py index 5a606bb1874dc84683d1fe8227eaebb1181f926b..921360a05eabf5e4104a1ec705fab2acaad8fc97 100755 --- a/tools/packaging/test262.py +++ b/tools/packaging/test262.py @@ -243,6 +243,8 @@ class TestCase(object): testRecord.pop("commentary", None) # do not throw if missing self.testRecord = testRecord; + self.validate() + def NegativeMatch(self, stderr): neg = re.compile(self.GetNegative()) return re.search(neg, stderr) @@ -269,7 +271,10 @@ class TestCase(object): return 'onlyStrict' in self.testRecord def IsNoStrict(self): - return 'noStrict' in self.testRecord + return 'noStrict' in self.testRecord or self.IsRaw() + + def IsRaw(self): + return 'raw' in self.testRecord def IsAsyncTest(self): return '$DONE' in self.test @@ -282,20 +287,10 @@ class TestCase(object): def GetAdditionalIncludes(self): return '\n'.join([self.suite.GetInclude(include) for include in self.GetIncludeList()]) - def WrapTest(self, command): - if "cscript" not in command: - return self.test + def GetSource(self): + if self.IsRaw(): + return self.test - return """ -try { -""" + self.test + """ -} catch(e) { - $ERROR(e.message); -} -""" - - def GetSource(self, command_template): - # "var testDescrip = " + str(self.testRecord) + ';\n\n' + \ source = self.suite.GetInclude("sta.js") + \ self.suite.GetInclude("cth.js") + \ self.suite.GetInclude("assert.js") @@ -307,7 +302,7 @@ try { source = source + \ self.GetAdditionalIncludes() + \ - self.WrapTest(command_template) + '\n' + self.test + '\n' if self.strict_mode: source = '"use strict";\nvar strict_mode = true;\n' + source @@ -347,7 +342,7 @@ try { return (code, out, err) def RunTestIn(self, command_template, tmp): - tmp.Write(self.GetSource(command_template)) + tmp.Write(self.GetSource()) tmp.Close() command = self.InstantiateTemplate(command_template, { 'path': tmp.name @@ -364,8 +359,23 @@ try { return result def Print(self): - print self.GetSource("") - + print self.GetSource() + + def validate(self): + flags = self.testRecord.get("flags") + + if not flags: + return + + if 'raw' in flags: + if 'noStrict' in flags: + raise TypeError("The `raw` flag implies the `noStrict` flag") + elif 'onlyStrict' in flags: + raise TypeError( + "The `raw` flag is incompatible with the `onlyStrict` flag") + elif len(self.GetIncludeList()) > 0: + raise TypeError( + "The `raw` flag is incompatible with the `includes` tag") class ProgressIndicator(object): diff --git a/website/scripts/sth.js b/website/scripts/sth.js index f55f437fa2a4c9427ed00934efd1c371ace397de..26b440795b3ef2883f8d1992060b7d6dcc94b52c 100644 --- a/website/scripts/sth.js +++ b/website/scripts/sth.js @@ -272,7 +272,8 @@ function BrowserRunner() { BrowserRunner.prototype.compileSource = function(test, code) { var flags = test.flags; - if (flags && flags.indexOf("onlyStrict") > -1) { + if (flags && flags.indexOf("raw") === -1 && + flags.indexOf("onlyStrict") > -1) { code = "'use strict';\n" + code; }