summaryrefslogtreecommitdiff
path: root/test/language/expressions/arrow-function
diff options
context:
space:
mode:
authorMike Pennisi <mike@mikepennisi.com>2016-04-27 13:16:49 -0400
committerMike Pennisi <mike@mikepennisi.com>2016-04-28 09:47:08 -0400
commitc9a93c1d1c6e5d17e010da5b9dc51ee7dc79f22d (patch)
treeb37f250e25a4fc0eec0df41c50691264debcaf28 /test/language/expressions/arrow-function
parent9c3ff83c009a45a4f14142bdd0efb4e4b3ded1a0 (diff)
downloadqtdeclarative-testsuites-c9a93c1d1c6e5d17e010da5b9dc51ee7dc79f22d.tar.gz
Add equivalent tests for non-strict fn parameters
These tests are based on the files introduced in the commit titled, "Add tests for Lexical Environment management."
Diffstat (limited to 'test/language/expressions/arrow-function')
-rw-r--r--test/language/expressions/arrow-function/scope-param-elem-var-close.js32
-rw-r--r--test/language/expressions/arrow-function/scope-param-elem-var-open.js31
-rw-r--r--test/language/expressions/arrow-function/scope-param-rest-elem-var-close.js36
-rw-r--r--test/language/expressions/arrow-function/scope-param-rest-elem-var-open.js36
4 files changed, 135 insertions, 0 deletions
diff --git a/test/language/expressions/arrow-function/scope-param-elem-var-close.js b/test/language/expressions/arrow-function/scope-param-elem-var-close.js
new file mode 100644
index 000000000..bcb987ebb
--- /dev/null
+++ b/test/language/expressions/arrow-function/scope-param-elem-var-close.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-function-definitions-runtime-semantics-iteratorbindinginitialization
+description: >
+ Removal of variable environment for each BindingElement formal parameter
+info: |
+ [...]
+ 6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv).
+ 7. Set the VariableEnvironment of currentContext to paramVarEnv.
+ 8. Set the LexicalEnvironment of currentContext to paramVarEnv.
+ 9. Let result be the result of performing IteratorBindingInitialization for
+ BindingElement using iteratorRecord and environment as the arguments.
+ 10. Set the VariableEnvironment of currentContext to originalEnv.
+ 11. Set the LexicalEnvironment of currentContext to originalEnv.
+ [...]
+flags: [noStrict]
+---*/
+
+var x = 'outside';
+var probe1, probe2, probeBody;
+
+((
+ _ = (eval('var x = "inside";'), probe1 = function() { return x; }),
+ __ = probe2 = function() { return x; }
+ ) => {
+ probeBody = function() { return x; };
+})();
+
+assert.sameValue(probe1(), 'inside');
+assert.sameValue(probe2(), 'outside');
+assert.sameValue(probeBody(), 'outside');
diff --git a/test/language/expressions/arrow-function/scope-param-elem-var-open.js b/test/language/expressions/arrow-function/scope-param-elem-var-open.js
new file mode 100644
index 000000000..7f60a0610
--- /dev/null
+++ b/test/language/expressions/arrow-function/scope-param-elem-var-open.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-function-definitions-runtime-semantics-iteratorbindinginitialization
+description: >
+ Creation of new variable environment for each BindingElement formal
+ parameter
+info: |
+ [...]
+ 6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv).
+ 7. Set the VariableEnvironment of currentContext to paramVarEnv.
+ 8. Set the LexicalEnvironment of currentContext to paramVarEnv.
+ 9. Let result be the result of performing IteratorBindingInitialization for
+ BindingElement using iteratorRecord and environment as the arguments.
+ 10. Set the VariableEnvironment of currentContext to originalEnv.
+ 11. Set the LexicalEnvironment of currentContext to originalEnv.
+ [...]
+flags: [noStrict]
+---*/
+
+var x = 'outside';
+var probe1, probe2;
+
+((
+ _ = probe1 = function() { return x; },
+ __ = (eval('var x = "inside";'), probe2 = function() { return x; })
+ ) => {
+})();
+
+assert.sameValue(probe1(), 'outside');
+assert.sameValue(probe2(), 'inside');
diff --git a/test/language/expressions/arrow-function/scope-param-rest-elem-var-close.js b/test/language/expressions/arrow-function/scope-param-rest-elem-var-close.js
new file mode 100644
index 000000000..976565a98
--- /dev/null
+++ b/test/language/expressions/arrow-function/scope-param-rest-elem-var-close.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-function-definitions-runtime-semantics-iteratorbindinginitialization
+description: >
+ Removal of variable environment for the BindingRestElement formal parameter
+info: |
+ [...]
+ 2. Let currentContext be the running execution context.
+ 3. Let originalEnv be the VariableEnvironment of currentContext.
+ 4. Assert: The VariableEnvironment and LexicalEnvironment of currentContext
+ are the same.
+ 5. Assert: environment and originalEnv are the same.
+ 6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv).
+ 7. Set the VariableEnvironment of currentContext to paramVarEnv.
+ 8. Set the LexicalEnvironment of currentContext to paramVarEnv.
+ 9. Let result be the result of performing IteratorBindingInitialization for
+ BindingRestElement using iteratorRecord and environment as the
+ arguments.
+ 10. Set the VariableEnvironment of currentContext to originalEnv.
+ 11. Set the LexicalEnvironment of currentContext to originalEnv.
+ [...]
+flags: [noStrict]
+---*/
+
+var x = 'outside';
+var probeParam, probeBody;
+
+((
+ ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })]
+ ) => {
+ probeBody = function() { return x; }
+})();
+
+assert.sameValue(probeParam(), 'inside');
+assert.sameValue(probeBody(), 'outside');
diff --git a/test/language/expressions/arrow-function/scope-param-rest-elem-var-open.js b/test/language/expressions/arrow-function/scope-param-rest-elem-var-open.js
new file mode 100644
index 000000000..b7a88bc05
--- /dev/null
+++ b/test/language/expressions/arrow-function/scope-param-rest-elem-var-open.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-function-definitions-runtime-semantics-iteratorbindinginitialization
+description: >
+ Creation of new variable environment for the BindingRestElement formal
+ parameter
+info: |
+ [...]
+ 2. Let currentContext be the running execution context.
+ 3. Let originalEnv be the VariableEnvironment of currentContext.
+ 4. Assert: The VariableEnvironment and LexicalEnvironment of currentContext
+ are the same.
+ 5. Assert: environment and originalEnv are the same.
+ 6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv).
+ 7. Set the VariableEnvironment of currentContext to paramVarEnv.
+ 8. Set the LexicalEnvironment of currentContext to paramVarEnv.
+ 9. Let result be the result of performing IteratorBindingInitialization for
+ BindingRestElement using iteratorRecord and environment as the arguments.
+ 10. Set the VariableEnvironment of currentContext to originalEnv.
+ 11. Set the LexicalEnvironment of currentContext to originalEnv.
+ [...]
+flags: [noStrict]
+---*/
+
+var x = 'outside';
+var probe1, probe2;
+
+((
+ _ = probe1 = function() { return x; },
+ ...[__ = (eval('var x = "inside";'), probe2 = function() { return x; })]
+ ) => {
+})();
+
+assert.sameValue(probe1(), 'outside');
+assert.sameValue(probe2(), 'inside');