summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/block-scope/syntax/for-in
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/block-scope/syntax/for-in')
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-array.js43
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-object.js43
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/browser.js0
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/disallow-initialization-assignment.js16
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-and-without-initializer.js16
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-initializer.js16
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-without-and-with-initializer.js16
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings.js16
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/mixed-values-in-iteration.js22
-rw-r--r--js/src/tests/test262/language/block-scope/syntax/for-in/shell.js0
10 files changed, 188 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-array.js b/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-array.js
new file mode 100644
index 0000000000..66a0be39dd
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-array.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for-in to acquire properties from array
+---*/
+function props(x) {
+ var array = [];
+ for (let p in x) array.push(p);
+ return array;
+}
+var subject;
+
+subject = props([]);
+assert.sameValue(subject.length, 0, "[]: length");
+assert.sameValue(subject[0], undefined, "[]: first property");
+assert.sameValue(subject[1], undefined, "[]: second property");
+assert.sameValue(subject[2], undefined, "[]: third property");
+assert.sameValue(subject[3], undefined, "[]: fourth property");
+
+subject = props([1]);
+assert.sameValue(subject.length, 1, "[1]: length");
+assert.sameValue(subject[0], "0", "[1]: first property");
+assert.sameValue(subject[1], undefined, "[1]: second property");
+assert.sameValue(subject[2], undefined, "[1]: third property");
+assert.sameValue(subject[3], undefined, "[1]: fourth property");
+
+subject = props([1, 2]);
+assert.sameValue(subject.length, 2, "[1, 2]: length");
+assert.sameValue(subject[0], "0", "[1, 2]: first property");
+assert.sameValue(subject[1], "1", "[1, 2]: second property");
+assert.sameValue(subject[2], undefined, "[1, 2]: third property");
+assert.sameValue(subject[3], undefined, "[1, 2]: fourth property");
+
+subject = props([1, 2, 3]);
+assert.sameValue(subject.length, 3, "[1, 2, 3]: length");
+assert.sameValue(subject[0], "0", "[1, 2, 3]: first property");
+assert.sameValue(subject[1], "1", "[1, 2, 3]: second property");
+assert.sameValue(subject[2], "2", "[1, 2, 3]: third property");
+assert.sameValue(subject[3], undefined, "[1, 2, 3]: fourth property");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-object.js b/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-object.js
new file mode 100644
index 0000000000..9016fb3b1d
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/acquire-properties-from-object.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for-in to acquire properties from object
+---*/
+function props(x) {
+ var array = [];
+ for (let p in x) array.push(p);
+ return array;
+}
+var subject;
+
+subject = props({});
+assert.sameValue(subject.length, 0, "{}: length");
+assert.sameValue(subject[0], undefined, "{}: first property");
+assert.sameValue(subject[1], undefined, "{}: second property");
+assert.sameValue(subject[2], undefined, "{}: third property");
+assert.sameValue(subject[3], undefined, "{}: fourth property");
+
+subject = props({x:1});
+assert.sameValue(subject.length, 1, "{x:1}: length");
+assert.sameValue(subject[0], "x", "{x:1}: first property");
+assert.sameValue(subject[1], undefined, "{x:1}: second property");
+assert.sameValue(subject[2], undefined, "{x:1}: third property");
+assert.sameValue(subject[3], undefined, "{x:1}: fourth property");
+
+subject = props({x:1, y:2});
+assert.sameValue(subject.length, 2, "{x:1, y:2}: length");
+assert.sameValue(subject[0], "x", "{x:1, y:2}: first property");
+assert.sameValue(subject[1], "y", "{x:1, y:2}: second property");
+assert.sameValue(subject[2], undefined, "{x:1, y:2}: third property");
+assert.sameValue(subject[3], undefined, "{x:1, y:2}: fourth property");
+
+subject = props({x:1, y:2, zoom:3});
+assert.sameValue(subject.length, 3, "{x:1, y:2, zoom:3}: length");
+assert.sameValue(subject[0], "x", "{x:1, y:2, zoom:3}: first property");
+assert.sameValue(subject[1], "y", "{x:1, y:2, zoom:3}: second property");
+assert.sameValue(subject[2], "zoom", "{x:1, y:2, zoom:3}: third property");
+assert.sameValue(subject[3], undefined, "{x:1, y:2, zoom:3}: fourth property");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/browser.js b/js/src/tests/test262/language/block-scope/syntax/for-in/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/browser.js
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-initialization-assignment.js b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-initialization-assignment.js
new file mode 100644
index 0000000000..6eb679df1e
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-initialization-assignment.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for declaration:
+ disallow initialization assignment
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+for (let x = 3 in {}) { }
+
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-and-without-initializer.js b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-and-without-initializer.js
new file mode 100644
index 0000000000..67383a0210
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-and-without-initializer.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for declaration:
+ disallow multiple lexical bindings, with and without initializer
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+for (let x = 3, y in {}) { }
+
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-initializer.js b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-initializer.js
new file mode 100644
index 0000000000..36c2e9c22a
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-with-initializer.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for declaration:
+ disallow multiple lexical bindings, with initializer
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+for (let x = 3, y = 4 in {}) { }
+
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-without-and-with-initializer.js b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-without-and-with-initializer.js
new file mode 100644
index 0000000000..84f9c83688
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings-without-and-with-initializer.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for declaration:
+ disallow multiple lexical bindings, without and with initializer
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+for (let x, y = 4 in {}) { }
+
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings.js b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings.js
new file mode 100644
index 0000000000..550974ced8
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/disallow-multiple-lexical-bindings.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ for declaration:
+ disallow multiple lexical bindings
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+for (let x, y in {}) { }
+
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/mixed-values-in-iteration.js b/js/src/tests/test262/language/block-scope/syntax/for-in/mixed-values-in-iteration.js
new file mode 100644
index 0000000000..85f2c0bf4e
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/mixed-values-in-iteration.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2011 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 13.1
+description: >
+ Mixed values in iteration
+---*/
+function fn(x) {
+ let a = [];
+ for (let p in x) {
+ a.push(function () { return p; });
+ }
+ let k = 0;
+ for (let q in x) {
+ assert.sameValue(q, a[k]());
+ ++k;
+ }
+}
+fn({a : [0], b : 1, c : {v : 1}, get d() {}, set e(x) {}});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/block-scope/syntax/for-in/shell.js b/js/src/tests/test262/language/block-scope/syntax/for-in/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/block-scope/syntax/for-in/shell.js