Browse Source

testcase for 'inheriting' strictness from containing function

pull/1/head
Sami Vaarala 12 years ago
parent
commit
a94c4e2420
  1. 48
      testcases/test-dev-strict-inherit.js

48
testcases/test-dev-strict-inherit.js

@ -0,0 +1,48 @@
/*===
true
SyntaxError
true
===*/
/* An inner function or an eval call of a strict function is automatically
* strict, even without an explicit use strict declaration.
*
* A strict function 'this' binding is undefined; a non-strict function has
* the global object as its 'this' binding (when called as a plain function).
* Thus, '!this' is true for strict code, and false for non-strict code.
*
* Also, 'delete' for an unresolvable identifier is a SyntaxError in strict
* code but returns false in non-strict code.
*/
//print=console.log;
function outer_strict() {
'use strict';
var foo = 1;
try {
print(!this);
} catch (e) {
print(e.name);
}
try {
print(eval("delete foo"));
} catch (e) {
print(e.name);
}
function inner() {
try {
print(!this);
} catch (e) {
print(e.name);
}
}
inner();
}
outer_strict();
Loading…
Cancel
Save