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

Side by Side Diff: test/mjsunit/keyed-ic.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/keyed-call-ic.js ('k') | test/mjsunit/leakcheck.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (i == change_index) P = H; 48 if (i == change_index) P = H;
49 } 49 }
50 P = initial_P; 50 P = initial_P;
51 } 51 }
52 52
53 for (var i = 0; i < 10; i++) prototypeTest(i); 53 for (var i = 0; i < 10; i++) prototypeTest(i);
54 54
55 f.prototype = 43; 55 f.prototype = 43;
56 56
57 for (var i = 0; i < 10; i++) prototypeTest(i); 57 for (var i = 0; i < 10; i++) prototypeTest(i);
58 } 58 };
59 59
60 runTest(); 60 runTest();
61 61
62 // ---------------------------------------------------------------------- 62 // ----------------------------------------------------------------------
63 // Array length accessor. 63 // Array length accessor.
64 // ---------------------------------------------------------------------- 64 // ----------------------------------------------------------------------
65 runTest = function() { 65 runTest = function() {
66 var initial_L = 'length'; 66 var initial_L = 'length';
67 var L = initial_L; 67 var L = initial_L;
68 var zero = '0'; 68 var zero = '0';
69 69
70 var a = new Array(10); 70 var a = new Array(10);
71 71
72 function arrayLengthTest(change_index) { 72 function arrayLengthTest(change_index) {
73 for (var i = 0; i < 10; i++) { 73 for (var i = 0; i < 10; i++) {
74 var l = a[L]; 74 var l = a[L];
75 if (i <= change_index) { 75 if (i <= change_index) {
76 assertEquals(10, l); 76 assertEquals(10, l);
77 } else { 77 } else {
78 assertEquals(undefined, l); 78 assertEquals(undefined, l);
79 } 79 }
80 if (i == change_index) L = zero; 80 if (i == change_index) L = zero;
81 } 81 }
82 L = initial_L; 82 L = initial_L;
83 } 83 }
84 84
85 for (var i = 0; i < 10; i++) arrayLengthTest(i); 85 for (var i = 0; i < 10; i++) arrayLengthTest(i);
86 } 86 };
87 87
88 runTest(); 88 runTest();
89 89
90 // ---------------------------------------------------------------------- 90 // ----------------------------------------------------------------------
91 // String length accessor. 91 // String length accessor.
92 // ---------------------------------------------------------------------- 92 // ----------------------------------------------------------------------
93 runTest = function() { 93 runTest = function() {
94 var initial_L = 'length'; 94 var initial_L = 'length';
95 var L = initial_L; 95 var L = initial_L;
96 var zero = '0'; 96 var zero = '0';
97 97
98 var s = "asdf" 98 var s = "asdf";
99 99
100 function stringLengthTest(change_index) { 100 function stringLengthTest(change_index) {
101 for (var i = 0; i < 10; i++) { 101 for (var i = 0; i < 10; i++) {
102 var l = s[L]; 102 var l = s[L];
103 if (i <= change_index) { 103 if (i <= change_index) {
104 assertEquals(4, l); 104 assertEquals(4, l);
105 } else { 105 } else {
106 assertEquals('a', l); 106 assertEquals('a', l);
107 } 107 }
108 if (i == change_index) L = zero; 108 if (i == change_index) L = zero;
109 } 109 }
110 L = initial_L; 110 L = initial_L;
111 } 111 }
112 112
113 for (var i = 0; i < 10; i++) stringLengthTest(i); 113 for (var i = 0; i < 10; i++) stringLengthTest(i);
114 } 114 };
115 115
116 runTest(); 116 runTest();
117 117
118 // ---------------------------------------------------------------------- 118 // ----------------------------------------------------------------------
119 // Field access. 119 // Field access.
120 // ---------------------------------------------------------------------- 120 // ----------------------------------------------------------------------
121 runTest = function() { 121 runTest = function() {
122 var o = { x: 42, y: 43 } 122 var o = { x: 42, y: 43 };
123 123
124 var initial_X = 'x'; 124 var initial_X = 'x';
125 var X = initial_X; 125 var X = initial_X;
126 var Y = 'y'; 126 var Y = 'y';
127 127
128 function fieldTest(change_index) { 128 function fieldTest(change_index) {
129 for (var i = 0; i < 10; i++) { 129 for (var i = 0; i < 10; i++) {
130 var property = o[X]; 130 var property = o[X];
131 if (i <= change_index) { 131 if (i <= change_index) {
132 assertEquals(42, property); 132 assertEquals(42, property);
133 } else { 133 } else {
134 assertEquals(43, property); 134 assertEquals(43, property);
135 } 135 }
136 if (i == change_index) X = Y; 136 if (i == change_index) X = Y;
137 } 137 }
138 X = initial_X; 138 X = initial_X;
139 }; 139 }
140 140
141 for (var i = 0; i < 10; i++) fieldTest(i); 141 for (var i = 0; i < 10; i++) fieldTest(i);
142 } 142 };
143 143
144 runTest(); 144 runTest();
145 145
146 146
147 // ---------------------------------------------------------------------- 147 // ----------------------------------------------------------------------
148 // Indexed access. 148 // Indexed access.
149 // ---------------------------------------------------------------------- 149 // ----------------------------------------------------------------------
150 runTest = function() { 150 runTest = function() {
151 var o = [ 42, 43 ]; 151 var o = [ 42, 43 ];
152 152
153 var initial_X = 0; 153 var initial_X = 0;
154 var X = initial_X; 154 var X = initial_X;
155 var Y = 1; 155 var Y = 1;
156 156
157 function fieldTest(change_index) { 157 function fieldTest(change_index) {
158 for (var i = 0; i < 10; i++) { 158 for (var i = 0; i < 10; i++) {
159 var property = o[X]; 159 var property = o[X];
160 if (i <= change_index) { 160 if (i <= change_index) {
161 assertEquals(42, property); 161 assertEquals(42, property);
162 } else { 162 } else {
163 assertEquals(43, property); 163 assertEquals(43, property);
164 } 164 }
165 if (i == change_index) X = Y; 165 if (i == change_index) X = Y;
166 } 166 }
167 X = initial_X; 167 X = initial_X;
168 }; 168 }
169 169
170 for (var i = 0; i < 10; i++) fieldTest(i); 170 for (var i = 0; i < 10; i++) fieldTest(i);
171 } 171 };
172 172
173 runTest(); 173 runTest();
174 174
175 175
176 // ---------------------------------------------------------------------- 176 // ----------------------------------------------------------------------
177 // Constant function access. 177 // Constant function access.
178 // ---------------------------------------------------------------------- 178 // ----------------------------------------------------------------------
179 runTest = function() { 179 runTest = function() {
180 function fun() { }; 180 function fun() { }
181 181
182 var o = new Object(); 182 var o = new Object();
183 o.f = fun; 183 o.f = fun;
184 o.x = 42; 184 o.x = 42;
185 185
186 var initial_F = 'f'; 186 var initial_F = 'f';
187 var F = initial_F; 187 var F = initial_F;
188 var X = 'x' 188 var X = 'x';
189 189
190 function constantFunctionTest(change_index) { 190 function constantFunctionTest(change_index) {
191 for (var i = 0; i < 10; i++) { 191 for (var i = 0; i < 10; i++) {
192 var property = o[F]; 192 var property = o[F];
193 if (i <= change_index) { 193 if (i <= change_index) {
194 assertEquals(fun, property); 194 assertEquals(fun, property);
195 } else { 195 } else {
196 assertEquals(42, property); 196 assertEquals(42, property);
197 } 197 }
198 if (i == change_index) F = X; 198 if (i == change_index) F = X;
199 } 199 }
200 F = initial_F; 200 F = initial_F;
201 }; 201 }
202 202
203 for (var i = 0; i < 10; i++) constantFunctionTest(i); 203 for (var i = 0; i < 10; i++) constantFunctionTest(i);
204 } 204 };
205 205
206 runTest(); 206 runTest();
207 207
208 // ---------------------------------------------------------------------- 208 // ----------------------------------------------------------------------
209 // Keyed store field. 209 // Keyed store field.
210 // ---------------------------------------------------------------------- 210 // ----------------------------------------------------------------------
211 211
212 runTest = function() { 212 runTest = function() {
213 var o = { x: 42, y: 43 } 213 var o = { x: 42, y: 43 };
214 214
215 var initial_X = 'x'; 215 var initial_X = 'x';
216 var X = initial_X; 216 var X = initial_X;
217 var Y = 'y'; 217 var Y = 'y';
218 218
219 function fieldTest(change_index) { 219 function fieldTest(change_index) {
220 for (var i = 0; i < 10; i++) { 220 for (var i = 0; i < 10; i++) {
221 o[X] = X; 221 o[X] = X;
222 var property = o[X]; 222 var property = o[X];
223 if (i <= change_index) { 223 if (i <= change_index) {
224 assertEquals('x', property); 224 assertEquals('x', property);
225 } else { 225 } else {
226 assertEquals('y', property); 226 assertEquals('y', property);
227 } 227 }
228 if (i == change_index) X = Y; 228 if (i == change_index) X = Y;
229 } 229 }
230 X = initial_X; 230 X = initial_X;
231 }; 231 }
232 232
233 for (var i = 0; i < 10; i++) fieldTest(i); 233 for (var i = 0; i < 10; i++) fieldTest(i);
234 } 234 };
235 235
236 runTest(); 236 runTest();
OLDNEW
« no previous file with comments | « test/mjsunit/keyed-call-ic.js ('k') | test/mjsunit/leakcheck.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698