Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1590)

Unified Diff: test/mjsunit/harmony/object-values.js

Issue 1767113004: [esnext] handle elements in FastObjectValuesOrEntries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make ElementsAccessor::GetCapacity() public, and use it Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/harmony/object-entries.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/object-values.js
diff --git a/test/mjsunit/harmony/object-values.js b/test/mjsunit/harmony/object-values.js
index f56fe8a7b3a6d8d9c45ac6e7b355871a78d058bd..cb4655106ea1175fd516ce5cb73bfb2f5aff16de 100644
--- a/test/mjsunit/harmony/object-values.js
+++ b/test/mjsunit/harmony/object-values.js
@@ -227,3 +227,66 @@ function TestMutateDuringEnumeration() {
assertEquals([1, 2], Object.values(aMakesBEnumerable));
}
TestMutateDuringEnumeration();
+
+
+(function TestElementKinds() {
+ var O1 = { name: "1" }, O2 = { name: "2" }, O3 = { name: "3" };
+ var PI = 3.141592653589793;
+ var E = 2.718281828459045;
+ function fastSloppyArguments(a, b, c) {
+ delete arguments[0];
+ arguments[0] = a;
+ return arguments;
+ }
+
+ function slowSloppyArguments(a, b, c) {
+ delete arguments[0];
+ arguments[0] = a;
+ Object.defineProperties(arguments, {
+ 0: {
+ enumerable: true,
+ value: a
+ },
+ 9999: {
+ enumerable: false,
+ value: "Y"
+ }
+ });
+ arguments[10000] = "X";
+ return arguments;
+ }
+
+ var element_kinds = {
+ FAST_SMI_ELEMENTS: [ [1, 2, 3], [1, 2, 3] ],
+ FAST_HOLEY_SMI_ELEMENTS: [ [, , 3], [ 3 ] ],
+ FAST_ELEMENTS: [ [O1, O2, O3], [O1, O2, O3] ],
+ FAST_HOLEY_ELEMENTS: [ [, , O3], [O3] ],
+ FAST_DOUBLE_ELEMENTS: [ [E, NaN, PI], [E, NaN, PI] ],
+ FAST_HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [NaN] ],
+
+ DICTIONARY_ELEMENTS: [ Object.defineProperties({ 10000: "world" }, {
+ 100: { enumerable: true, value: "hello" },
+ 99: { enumerable: false, value: "nope" }
+ }), [ "hello", "world" ] ],
+ FAST_SLOPPY_ARGUMENTS_ELEMENTS: [
+ fastSloppyArguments("a", "b", "c"), ["a", "b", "c"] ],
+ SLOW_SLOPPY_ARGUMENTS_ELEMENTS: [
+ slowSloppyArguments("a", "b", "c"), [ "a", "b", "c", "X"]],
+
+ FAST_STRING_WRAPPER_ELEMENTS: [ new String("str"), ["s", "t", "r"] ],
+ SLOW_STRING_WRAPPER_ELEMENTS: [
+ Object.defineProperties(new String("str"), {
+ 10000: { enumerable: false, value: "X" },
+ 9999: { enumerable: true, value: "Y" }
+ }), ["s", "t", "r", "Y"] ],
+ };
+
+ for (let [kind, [object, expected]] of Object.entries(element_kinds)) {
+ let result1 = Object.values(object);
+ assertEquals(expected, result1, `fast Object.values() with ${kind}`);
+
+ let proxy = new Proxy(object, {});
+ let result2 = Object.values(proxy);
+ assertEquals(result1, result2, `slow Object.values() with ${kind}`);
+ }
+})();
« no previous file with comments | « test/mjsunit/harmony/object-entries.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698