Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor directive prologue tests for parsers #1592

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-21-s
description: >
Strict Mode - Function code of a FunctionDeclaration contains Use
Strict Directive which appears at the end of the block
flags: [noStrict]
---*/
function fun() {
eval("var public = 1;");
assert.sameValue(public, 1);
test262unresolvable = null;
assert.sameValue(test262unresolvable, null);
"use strict";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we have some coverage for the pragma only preceded by an empty statement. I did not find anything from a quick grep.

function fun() {
  ;'use strict';
  unr = null;
  assert.sameValue(unr, null);
}
fun();

}
fun();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-15-s
description: >
Strict Mode - Function code that is part of a FunctionDeclaration
is strict function code if FunctionDeclaration is contained in use
strict
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

function testcase() {
"use strict";
function fun() {
var static;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-15-s
description: >
Strict Mode - Function code that is part of a FunctionDeclaration
Expand All @@ -13,10 +14,10 @@ flags: [noStrict]
function testcase() {
"use strict";
function fun() {
eval("var public = 1;");
test262unresolvable = null;
}

assert.throws(SyntaxError, function() {
assert.throws(ReferenceError, function() {
fun();
});
}
Expand Down
19 changes: 19 additions & 0 deletions test/language/directive-prologue/func-decl-no-semi-parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-2-s
description: >
Strict Mode - Use Strict Directive Prologue is ''use strict''
which lost the last character ';'
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

function fun() {
"use strict"
var static;
}
20 changes: 20 additions & 0 deletions test/language/directive-prologue/func-decl-no-semi-runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-2-s
description: >
Strict Mode - Use Strict Directive Prologue is ''use strict''
which lost the last character ';'
flags: [noStrict]
---*/

function fun() {
"use strict"
test262unresolvable = null;
}

assert.throws(ReferenceError, function() {
fun();
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-20-s
description: >
Strict Mode - Function code of a FunctionDeclaration contains Use
Expand All @@ -10,8 +11,8 @@ flags: [noStrict]
---*/

function fun() {
eval("var public = 1;");
test262unresolvable = null;
"use strict";
assert.sameValue(public, 1);
assert.sameValue(test262unresolvable, null);
}
fun();
19 changes: 19 additions & 0 deletions test/language/directive-prologue/func-decl-parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-19-s
description: >
Strict Mode - Function code of a FunctionDeclaration contains Use
Strict Directive which appears at the start of the block
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

function fun() {
"use strict";
var static;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-19-s
description: >
Strict Mode - Function code of a FunctionDeclaration contains Use
Expand All @@ -12,9 +13,9 @@ flags: [noStrict]
function fun() {
"use strict";

eval("var public = 1;");
test262unresolvable = null;
}

assert.throws(SyntaxError, function() {
assert.throws(ReferenceError, function() {
fun();
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-24-s
description: >
Strict Mode - Function code of a FunctionExpression contains Use
Expand All @@ -10,8 +11,8 @@ flags: [noStrict]
---*/

(function () {
eval("var public = 1;");
test262unresolvable = null;
"use strict";

assert.sameValue(public, 1);
assert.sameValue(test262unresolvable, null);
}) ();
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-16-s
description: >
Strict Mode - Function code that is part of a FunctionExpression
is strict function code if FunctionExpression is contained in use
strict
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

function testcase() {
"use strict";
var static;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-16-s
description: >
Strict Mode - Function code that is part of a FunctionExpression
Expand All @@ -13,8 +14,8 @@ flags: [noStrict]
function testcase() {
"use strict";

assert.throws(SyntaxError, function() {
eval("var public = 1;");
assert.throws(ReferenceError, function() {
test262unresolvable = null;
});
}
testcase();
20 changes: 20 additions & 0 deletions test/language/directive-prologue/func-expr-no-semi-parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-2-s
description: >
Strict Mode - Use Strict Directive Prologue is ''use strict''
which lost the last character ';'
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

(function() {
"use strict"

var static;
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-2-s
description: >
Strict Mode - Use Strict Directive Prologue is ''use strict''
which lost the last character ';'
flags: [noStrict]
---*/

assert.throws(SyntaxError, function() {
assert.throws(ReferenceError, function() {
"use strict"

eval("var public = 1;");
test262unresolvable = null;
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-23-s
description: >
Strict Mode - Function code of a FunctionExpression contains Use
Expand All @@ -10,7 +11,7 @@ flags: [noStrict]
---*/

(function () {
eval("var public = 1;");
assert.sameValue(public, 1);
test262unresolvable = null;
assert.sameValue(test262unresolvable, null);
"use strict";
}) ();
20 changes: 20 additions & 0 deletions test/language/directive-prologue/func-expr-parse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2018 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-22-s
description: >
Strict Mode - Function code of a FunctionExpression contains Use
Strict Directive which appears at the start of the block
negative:
phase: early
type: SyntaxError
flags: [noStrict]
---*/

(function() {
"use strict";

var static;
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-22-s
description: >
Strict Mode - Function code of a FunctionExpression contains Use
Strict Directive which appears at the start of the block
flags: [noStrict]
---*/

assert.throws(SyntaxError, function () {
assert.throws(ReferenceError, function () {
"use strict";

eval("var public = 1;");
test262unresolvable = null;
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-17-s
description: >
Strict Mode - Function code that is part of a Accessor
Expand All @@ -10,12 +11,12 @@ description: >
flags: [noStrict]
---*/

assert.throws(SyntaxError, function() {
assert.throws(ReferenceError, function() {
"use strict";
var obj = {};
Object.defineProperty(obj, "accProperty", {
get: function () {
eval("public = 1;");
test262unresolvable = null;
return 11;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-27-s
description: >
Strict Mode - Function code of Accessor PropertyAssignment
Expand All @@ -13,11 +14,11 @@ flags: [noStrict]
var obj = {};
Object.defineProperty(obj, "accProperty", {
get: function () {
eval("public = 1;");
test262unresolvable = null;
"use strict";
return 11;
}
});

assert.sameValue(obj.accProperty, 11, 'obj.accProperty');
assert.sameValue(public, 1, 'public');
assert.sameValue(test262unresolvable, null);
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: use-strict-directive
es5id: 10.1.1-25-s
description: >
Strict Mode - Function code of Accessor PropertyAssignment
Expand All @@ -11,12 +12,12 @@ flags: [noStrict]
---*/


assert.throws(SyntaxError, function() {
assert.throws(ReferenceError, function() {
var obj = {};
Object.defineProperty(obj, "accProperty", {
get: function () {
"use strict";
eval("var public = 1;");
test262unresolvable = null;
return 11;
}
});
Expand Down
Loading