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

Side by Side Diff: test/mjsunit/regress/regress-4825.js

Issue 1778023004: [runtime] fix getting element keys from SLOW_SLOPPY_ARGUMENTS_ELEMENTS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix another issue with FastSloppyArgumentsElements 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 unified diff | Download patch
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function enumerate(o) {
6 var keys = [];
7 for (var key in o) keys.push(key);
8 return keys;
9 }
10
11 (function testSlowSloppyArgumentsElements() {
12 function slowSloppyArguments(a, b, c) {
13 arguments[10000] = "last";
14 arguments[4000] = "first";
15 arguments[6000] = "second";
16 arguments[5999] = "x";
17 arguments[3999] = "y";
18 return arguments;
19 }
20 assertEquals(["0", "1", "2", "3999", "4000", "5999", "6000", "10000"],
21 Object.keys(slowSloppyArguments(1, 2, 3)));
22
23 assertEquals(["0", "1", "2", "3999", "4000", "5999", "6000", "10000"],
24 enumerate(slowSloppyArguments(1,2,3)));
25 })();
26
27 (function testSlowSloppyArgumentsElementsNotEnumerable() {
28 function slowSloppyArguments(a, b, c) {
29 Object.defineProperty(arguments, 10000, {
30 enumerable: false, configurable: false, value: "NOPE"
31 });
32 arguments[4000] = "first";
33 arguments[6000] = "second";
34 arguments[5999] = "x";
35 arguments[3999] = "y";
36 return arguments;
37 }
38
39 assertEquals(["0", "1", "2", "3999", "4000", "5999", "6000"],
40 Object.keys(slowSloppyArguments(1, 2, 3)));
41
42 assertEquals(["0", "1", "2", "3999", "4000", "5999", "6000"],
43 enumerate(slowSloppyArguments(1,2,3)));
44 })();
45
46 (function testFastSloppyArgumentsElements() {
47 function fastSloppyArguments(a, b, c) {
48 arguments[5] = 1;
49 arguments[7] = 0;
50 arguments[3] = 2;
51 return arguments;
52 }
53 assertEquals(["0", "1", "2", "3", "5", "7"],
54 Object.keys(fastSloppyArguments(1, 2, 3)));
55
56 assertEquals(
57 ["0", "1", "2", "3", "5", "7"], enumerate(fastSloppyArguments(1, 2, 3)));
58
59 function fastSloppyArguments2(a, b, c) {
60 delete arguments[0];
61 arguments[0] = "test";
62 return arguments;
63 }
64
65 assertEquals(["0", "1", "2"], Object.keys(fastSloppyArguments2(1, 2, 3)));
66 assertEquals(["0", "1", "2"], enumerate(fastSloppyArguments2(1, 2, 3)));
67 })();
68
69 (function testFastSloppyArgumentsElementsNotEnumerable() {
70 function fastSloppyArguments(a, b, c) {
71 Object.defineProperty(arguments, 5, {
72 enumerable: false, configurable: false, value: "NOPE"
73 });
74 arguments[7] = 0;
75 arguments[3] = 2;
76 return arguments;
77 }
78 assertEquals(
79 ["0", "1", "2", "3", "7"], Object.keys(fastSloppyArguments(1, 2, 3)));
80
81 assertEquals(
82 ["0", "1", "2", "3", "7"], enumerate(fastSloppyArguments(1,2,3)));
83
84 function fastSloppyArguments2(a, b, c) {
85 delete arguments[0];
86 Object.defineProperty(arguments, 1, {
87 enumerable: false, configurable: false, value: "NOPE"
88 });
89 arguments[0] = "test";
90 return arguments;
91 }
92
93 assertEquals(["0", "2"], Object.keys(fastSloppyArguments2(1, 2, 3)));
94 assertEquals(["0", "2"], enumerate(fastSloppyArguments2(1, 2, 3)));
95 })();
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698