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

Side by Side Diff: test/mjsunit/harmony/object-observe.js

Issue 16150003: Revert "Implement ObservedArrayPop, ObservedArrayShift, ObservedArrayUnshift & ObservedArraySplice" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/array.js ('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
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 Object.observe(array, observer.callback); 1168 Object.observe(array, observer.callback);
1169 Array.prototype.push.call(array, 3, 4); 1169 Array.prototype.push.call(array, 3, 4);
1170 Object.deliverChangeRecords(observer.callback); 1170 Object.deliverChangeRecords(observer.callback);
1171 observer.assertCallbackRecords([ 1171 observer.assertCallbackRecords([
1172 { object: array, name: '2', type: 'new' }, 1172 { object: array, name: '2', type: 'new' },
1173 { object: array, name: '3', type: 'new' }, 1173 { object: array, name: '3', type: 'new' },
1174 { object: array, name: 'length', type: 'updated', oldValue: 2 }, 1174 { object: array, name: 'length', type: 'updated', oldValue: 2 },
1175 ]); 1175 ]);
1176 1176
1177 // Pop 1177 // Pop
1178 reset(); 1178 reset()
1179 var array = [1, 2]; 1179 var array = {0: 1, 1: 2, length: 2};
1180 Object.observe(array, observer.callback); 1180 Object.observe(array, observer.callback);
1181 Array.observe(array, observer2.callback); 1181 Array.prototype.pop.call(array);
1182 array.pop(); 1182 Array.prototype.pop.call(array);
1183 array.pop();
1184 array.pop();
1185 Object.deliverChangeRecords(observer.callback); 1183 Object.deliverChangeRecords(observer.callback);
1186 observer.assertCallbackRecords([ 1184 observer.assertCallbackRecords([
1187 { object: array, name: '1', type: 'deleted', oldValue: 2 }, 1185 { object: array, name: '1', type: 'deleted', oldValue: 2 },
1188 { object: array, name: 'length', type: 'updated', oldValue: 2 }, 1186 { object: array, name: 'length', type: 'updated', oldValue: 2 },
1189 { object: array, name: '0', type: 'deleted', oldValue: 1 }, 1187 { object: array, name: '0', type: 'deleted', oldValue: 1 },
1190 { object: array, name: 'length', type: 'updated', oldValue: 1 }, 1188 { object: array, name: 'length', type: 'updated', oldValue: 1 },
1191 ]); 1189 ]);
1192 Object.deliverChangeRecords(observer2.callback);
1193 observer2.assertCallbackRecords([
1194 { object: array, type: 'splice', index: 1, removed: [2], addedCount: 0 },
1195 { object: array, type: 'splice', index: 0, removed: [1], addedCount: 0 }
1196 ]);
1197 1190
1198 // Shift 1191 // Shift
1199 reset(); 1192 reset()
1200 var array = [1, 2]; 1193 var array = {0: 1, 1: 2, length: 2};
1201 Object.observe(array, observer.callback); 1194 Object.observe(array, observer.callback);
1202 Array.observe(array, observer2.callback); 1195 Array.prototype.shift.call(array);
1203 array.shift(); 1196 Array.prototype.shift.call(array);
1204 array.shift();
1205 array.shift();
1206 Object.deliverChangeRecords(observer.callback); 1197 Object.deliverChangeRecords(observer.callback);
1207 observer.assertCallbackRecords([ 1198 observer.assertCallbackRecords([
1208 { object: array, name: '0', type: 'updated', oldValue: 1 }, 1199 { object: array, name: '0', type: 'updated', oldValue: 1 },
1209 { object: array, name: '1', type: 'deleted', oldValue: 2 }, 1200 { object: array, name: '1', type: 'deleted', oldValue: 2 },
1210 { object: array, name: 'length', type: 'updated', oldValue: 2 }, 1201 { object: array, name: 'length', type: 'updated', oldValue: 2 },
1211 { object: array, name: '0', type: 'deleted', oldValue: 2 }, 1202 { object: array, name: '0', type: 'deleted', oldValue: 2 },
1212 { object: array, name: 'length', type: 'updated', oldValue: 1 }, 1203 { object: array, name: 'length', type: 'updated', oldValue: 1 },
1213 ]); 1204 ]);
1214 Object.deliverChangeRecords(observer2.callback);
1215 observer2.assertCallbackRecords([
1216 { object: array, type: 'splice', index: 0, removed: [1], addedCount: 0 },
1217 { object: array, type: 'splice', index: 0, removed: [2], addedCount: 0 }
1218 ]);
1219 1205
1220 // Unshift 1206 // Unshift
1221 reset(); 1207 reset()
1222 var array = [1, 2]; 1208 var array = {0: 1, 1: 2, length: 2};
1223 Object.observe(array, observer.callback); 1209 Object.observe(array, observer.callback);
1224 Array.observe(array, observer2.callback); 1210 Array.prototype.unshift.call(array, 3, 4);
1225 array.unshift(3, 4);
1226 array.unshift(5);
1227 Object.deliverChangeRecords(observer.callback); 1211 Object.deliverChangeRecords(observer.callback);
1228 observer.assertCallbackRecords([ 1212 observer.assertCallbackRecords([
1229 { object: array, name: '3', type: 'new' }, 1213 { object: array, name: '3', type: 'new' },
1230 { object: array, name: 'length', type: 'updated', oldValue: 2 },
1231 { object: array, name: '2', type: 'new' }, 1214 { object: array, name: '2', type: 'new' },
1232 { object: array, name: '0', type: 'updated', oldValue: 1 }, 1215 { object: array, name: '0', type: 'updated', oldValue: 1 },
1233 { object: array, name: '1', type: 'updated', oldValue: 2 }, 1216 { object: array, name: '1', type: 'updated', oldValue: 2 },
1234 { object: array, name: '4', type: 'new' }, 1217 { object: array, name: 'length', type: 'updated', oldValue: 2 },
1235 { object: array, name: 'length', type: 'updated', oldValue: 4 },
1236 { object: array, name: '3', type: 'updated', oldValue: 2 },
1237 { object: array, name: '2', type: 'updated', oldValue: 1 },
1238 { object: array, name: '1', type: 'updated', oldValue: 4 },
1239 { object: array, name: '0', type: 'updated', oldValue: 3 },
1240 ]);
1241 Object.deliverChangeRecords(observer2.callback);
1242 observer2.assertCallbackRecords([
1243 { object: array, type: 'splice', index: 0, removed: [], addedCount: 2 },
1244 { object: array, type: 'splice', index: 0, removed: [], addedCount: 1 }
1245 ]); 1218 ]);
1246 1219
1247 // Splice 1220 // Splice
1248 reset(); 1221 reset()
1249 var array = [1, 2, 3]; 1222 var array = {0: 1, 1: 2, 2: 3, length: 3};
1250 Object.observe(array, observer.callback); 1223 Object.observe(array, observer.callback);
1251 Array.observe(array, observer2.callback); 1224 Array.prototype.splice.call(array, 1, 1, 4, 5);
1252 array.splice(1, 0, 4, 5); // 1 4 5 2 3
1253 array.splice(0, 2); // 5 2 3
1254 array.splice(1, 2, 6, 7); // 5 6 7
1255 array.splice(2, 0);
1256 Object.deliverChangeRecords(observer.callback); 1225 Object.deliverChangeRecords(observer.callback);
1257 observer.assertCallbackRecords([ 1226 observer.assertCallbackRecords([
1258 { object: array, name: '4', type: 'new' },
1259 { object: array, name: 'length', type: 'updated', oldValue: 3 },
1260 { object: array, name: '3', type: 'new' }, 1227 { object: array, name: '3', type: 'new' },
1261 { object: array, name: '1', type: 'updated', oldValue: 2 }, 1228 { object: array, name: '1', type: 'updated', oldValue: 2 },
1262 { object: array, name: '2', type: 'updated', oldValue: 3 }, 1229 { object: array, name: '2', type: 'updated', oldValue: 3 },
1263 1230 { object: array, name: 'length', type: 'updated', oldValue: 3 },
1264 { object: array, name: '0', type: 'updated', oldValue: 1 },
1265 { object: array, name: '1', type: 'updated', oldValue: 4 },
1266 { object: array, name: '2', type: 'updated', oldValue: 5 },
1267 { object: array, name: '4', type: 'deleted', oldValue: 3 },
1268 { object: array, name: '3', type: 'deleted', oldValue: 2 },
1269 { object: array, name: 'length', type: 'updated', oldValue: 5 },
1270
1271 { object: array, name: '1', type: 'updated', oldValue: 2 },
1272 { object: array, name: '2', type: 'updated', oldValue: 3 },
1273 ]);
1274 Object.deliverChangeRecords(observer2.callback);
1275 observer2.assertCallbackRecords([
1276 { object: array, type: 'splice', index: 1, removed: [], addedCount: 2 },
1277 { object: array, type: 'splice', index: 0, removed: [1, 4], addedCount: 0 },
1278 { object: array, type: 'splice', index: 1, removed: [2, 3], addedCount: 2 },
1279 ]); 1231 ]);
1280 1232
1281 // Exercise StoreIC_ArrayLength 1233 // Exercise StoreIC_ArrayLength
1282 reset(); 1234 reset();
1283 var dummy = {}; 1235 var dummy = {};
1284 Object.observe(dummy, observer.callback); 1236 Object.observe(dummy, observer.callback);
1285 Object.unobserve(dummy, observer.callback); 1237 Object.unobserve(dummy, observer.callback);
1286 var array = [0]; 1238 var array = [0];
1287 Object.observe(array, observer.callback); 1239 Object.observe(array, observer.callback);
1288 array.splice(0, 1); 1240 array.splice(0, 1);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 for (var n1 = 0; n1 < 3; ++n1) 1403 for (var n1 = 0; n1 < 3; ++n1)
1452 for (var n2 = 0; n2 < 3; ++n2) 1404 for (var n2 = 0; n2 < 3; ++n2)
1453 for (var i in mutation) 1405 for (var i in mutation)
1454 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); 1406 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2);
1455 1407
1456 for (var b1 = 0; b1 < 2; ++b1) 1408 for (var b1 = 0; b1 < 2; ++b1)
1457 for (var b2 = 0; b2 < 2; ++b2) 1409 for (var b2 = 0; b2 < 2; ++b2)
1458 for (var n = 0; n < 3; ++n) 1410 for (var n = 0; n < 3; ++n)
1459 for (var i in mutationByIncr) 1411 for (var i in mutationByIncr)
1460 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); 1412 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1);
OLDNEW
« no previous file with comments | « src/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698