+2015-04-12 Yusuke Suzuki <utatane.tea@gmail.com>
+
+ [ES6] Implement Array.prototype.values
+ https://bugs.webkit.org/show_bug.cgi?id=143633
+
+ Reviewed by Darin Adler.
+
+ * js/Object-getOwnPropertyNames-expected.txt:
+ * js/array-iterators-expected.txt:
+ * js/script-tests/Object-getOwnPropertyNames.js:
+ * js/script-tests/array-iterators.js:
+
2015-04-11 Alexey Proskuryakov <ap@apple.com>
editing/spelling/spelling-marker-description.html times out on Mac
PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']
PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
-PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']
+PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']
PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS 'values' in [] is false
+PASS 'values' in [] is true
+PASS value is testArray[i]
+PASS value is 1
+PASS value is testArray[i]
+PASS value is 2
+PASS value is testArray[i]
+PASS value is 3
+PASS value is testArray[i]
+PASS value is 4
+PASS value is testArray[i]
+PASS value is 5
+PASS value is testArray[i]
+PASS value is 6
+PASS testArray.length is 6
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS value is testArray[i]
+PASS testArray.length is 9
+PASS i is 0
+PASS value is o[i]
+PASS value is 1
+PASS value is o[i]
+PASS value is 2
+PASS value is o[i]
+PASS value is 3
+PASS value is o[i]
+PASS value is 4
+PASS value is o[i]
+PASS value is 5
+PASS value is o[i]
+PASS value is 6
+PASS o.length is 6
PASS key is 0
PASS key is 1
PASS key is 2
"Function": "['length', 'name', 'prototype']",
"Function.prototype": "['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']",
"Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
- "Array.prototype": "['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']",
+ "Array.prototype": "['concat', 'constructor', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
"String": "['fromCharCode', 'length', 'name', 'prototype']",
"String.prototype": "['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']",
"Boolean": "['length', 'name', 'prototype']",
"This test checks the behavior of the iterator methods on Array objects."
);
-shouldBeFalse("'values' in []");
+shouldBeTrue("'values' in []");
+
+var testArray = [1,2,3,4,5,6]
+var values = testArray.values();
+var i = 0;
+for (var value of values) {
+ shouldBe("value", "testArray[i]")
+ i++
+ shouldBe("value", String(i))
+}
+
+shouldBe("testArray.length", String(i))
+
+var testArray = [1,2,3,4,5,6]
+var values = testArray.values();
+var i = 0;
+for (var value of values) {
+ shouldBe("value", "testArray[i]")
+ i++
+ if (i % 2 == 0)
+ testArray[i] *= 2;
+ if (i < 4)
+ testArray.push(testArray.length)
+ if (i == 4)
+ delete testArray[4]
+ if (i == 5)
+ testArray[4] = 5
+}
+shouldBe("testArray.length", String(i))
+
+var o = {};
+for (var i =0; i < 6; i++)
+ o[i]=i+1
+
+
+var values = Array.prototype.values.call(o);
+var i = 0;
+for (var value of values) {
+ fail();
+}
+shouldBe("i", "0")
+
+o.length=6;
+
+var values = Array.prototype.values.call(o);
+var i = 0;
+for (var value of values) {
+ shouldBe("value", "o[i]")
+ i++
+ shouldBe("value", String(i))
+}
+shouldBe("o.length", String(i))
var testArray = [1,2,3,4,5,6]
var keys = testArray.keys();
+2015-04-12 Yusuke Suzuki <utatane.tea@gmail.com>
+
+ [ES6] Implement Array.prototype.values
+ https://bugs.webkit.org/show_bug.cgi?id=143633
+
+ Reviewed by Darin Adler.
+
+ Symbol.unscopables is implemented, so we can implement Array.prototype.values
+ without largely breaking the web. The following script passes.
+
+ var array = [];
+ var values = 42;
+ with (array) {
+ assert(values, 42);
+ }
+
+ * runtime/ArrayPrototype.cpp:
+ * tests/stress/array-iterators-next.js:
+ * tests/stress/map-iterators-next.js:
+ * tests/stress/set-iterators-next.js:
+ * tests/stress/values-unscopables.js: Added.
+ (test):
+
2015-04-11 Yusuke Suzuki <utatane.tea@gmail.com>
Run flaky conservative GC related test first before polluting stack and registers
reduce arrayProtoFuncReduce DontEnum|Function 1
reduceRight arrayProtoFuncReduceRight DontEnum|Function 1
map arrayProtoFuncMap DontEnum|Function 1
+ values arrayProtoFuncValues DontEnum|Function 0
entries arrayProtoFuncEntries DontEnum|Function 0
keys arrayProtoFuncKeys DontEnum|Function 0
find arrayProtoFuncFind DontEnum|Function 1
if (value !== undefined)
throw "Error: bad value: " + value;
+var values = testArray.values();
+var i = 0;
+while (true) {
+ var {done, value} = values.next();
+ if (done)
+ break;
+ i++;
+ if (value !== i)
+ throw "Error: bad value: " + value;
+}
+
+if (testArray.length !== i)
+ throw "Error: bad value: " + i;
+
+var value = values.next().value;
+if (value !== undefined)
+ throw "Error: bad value: " + value;
+
var entries = testArray.entries();
var i = 0;
do {
if (value !== undefined)
throw "Error: bad value: " + value;
-// TODO: Map.prototype.values() is not exposed.
-//
-// var values = testMap.values();
-// var i = 0;
-// while (true) {
-// var {done, value} = values.next();
-// if (done)
-// break;
-// i++;
-// if (testArray.indexOf(value) === -1)
-// throw "Error: bad value: " + value;
-// }
-//
-// if (testMap.size !== i)
-// throw "Error: bad value: " + i;
-//
-// var value = values.next().value;
-// if (value !== undefined)
-// throw "Error: bad value: " + value;
+var values = testMap.values();
+var i = 0;
+while (true) {
+ var {done, value} = values.next();
+ if (done)
+ break;
+ i++;
+ if (testArray.indexOf(value) === -1)
+ throw "Error: bad value: " + value;
+}
+
+if (testMap.size !== i)
+ throw "Error: bad value: " + i;
+
+var value = values.next().value;
+if (value !== undefined)
+ throw "Error: bad value: " + value;
var entries = testMap.entries();
var i = 0;
if (value !== undefined)
throw "Error: bad value: " + value;
-// TODO: Set.prototype.values() is not exposed.
-//
-// var values = testSet.values();
-// var i = 0;
-// while (true) {
-// var {done, value} = values.next();
-// if (done)
-// break;
-// i++;
-// if (testArray.indexOf(value) === -1)
-// throw "Error: bad value: " + value;
-// }
-//
-// if (testSet.size !== i)
-// throw "Error: bad value: " + i;
-//
-// var value = values.next().value;
-// if (value !== undefined)
-// throw "Error: bad value: " + value;
+var values = testSet.values();
+var i = 0;
+while (true) {
+ var {done, value} = values.next();
+ if (done)
+ break;
+ i++;
+ if (testArray.indexOf(value) === -1)
+ throw "Error: bad value: " + value;
+}
+
+if (testSet.size !== i)
+ throw "Error: bad value: " + i;
+
+var value = values.next().value;
+if (value !== undefined)
+ throw "Error: bad value: " + value;
var entries = testSet.entries();
var i = 0;
--- /dev/null
+function test(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+(function () {
+ var array = [];
+ var values = 42;
+
+ with (array) {
+ test(values, 42);
+ }
+
+ array[Symbol.unscopables].values = false;
+
+ with (array) {
+ test(values, Array.prototype.values);
+ }
+}());
+
+(function () {
+ var map = new Map();
+ var values = 42;
+
+ with (map) {
+ test(values, Map.prototype.values);
+ }
+
+ map[Symbol.unscopables] = {
+ values: true
+ };
+
+ with (map) {
+ test(values, 42);
+ }
+}());
+
+(function () {
+ var set = new Set();
+ var values = 42;
+
+ with (set) {
+ test(values, Set.prototype.values);
+ }
+
+ set[Symbol.unscopables] = {
+ values: true
+ };
+
+ with (set) {
+ test(values, 42);
+ }
+}());