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

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

Issue 15837006: Make (Object.)observed Arrays use SafeRemoveArrayHoles during sort (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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/objects.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
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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 Object.observe(array, observer.callback); 1135 Object.observe(array, observer.callback);
1136 array.splice(1, 1, 4, 5); 1136 array.splice(1, 1, 4, 5);
1137 Object.deliverChangeRecords(observer.callback); 1137 Object.deliverChangeRecords(observer.callback);
1138 observer.assertCallbackRecords([ 1138 observer.assertCallbackRecords([
1139 { object: array, name: '3', type: 'new' }, 1139 { object: array, name: '3', type: 'new' },
1140 { object: array, name: 'length', type: 'updated', oldValue: 3 }, 1140 { object: array, name: 'length', type: 'updated', oldValue: 3 },
1141 { object: array, name: '1', type: 'updated', oldValue: 2 }, 1141 { object: array, name: '1', type: 'updated', oldValue: 2 },
1142 { object: array, name: '2', type: 'updated', oldValue: 3 }, 1142 { object: array, name: '2', type: 'updated', oldValue: 3 },
1143 ]); 1143 ]);
1144 1144
1145 // Sort
1146 reset();
1147 var array = [3, 2, 1];
1148 Object.observe(array, observer.callback);
1149 array.sort();
1150 assertEquals(1, array[0]);
1151 assertEquals(2, array[1]);
1152 assertEquals(3, array[2]);
1153 Object.deliverChangeRecords(observer.callback);
1154 observer.assertCallbackRecords([
1155 { object: array, name: '1', type: 'updated', oldValue: 2 },
1156 { object: array, name: '0', type: 'updated', oldValue: 3 },
1157 { object: array, name: '2', type: 'updated', oldValue: 1 },
1158 { object: array, name: '1', type: 'updated', oldValue: 3 },
1159 { object: array, name: '0', type: 'updated', oldValue: 2 },
1160 ]);
1145 1161
1146 // 1162 //
1147 // === PLAIN OBJECTS === 1163 // === PLAIN OBJECTS ===
1148 // 1164 //
1149 // Push 1165 // Push
1150 reset() 1166 reset()
1151 var array = {0: 1, 1: 2, length: 2} 1167 var array = {0: 1, 1: 2, length: 2}
1152 Object.observe(array, observer.callback); 1168 Object.observe(array, observer.callback);
1153 Array.prototype.push.call(array, 3, 4); 1169 Array.prototype.push.call(array, 3, 4);
1154 Object.deliverChangeRecords(observer.callback); 1170 Object.deliverChangeRecords(observer.callback);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 for (var n1 = 0; n1 < 3; ++n1) 1403 for (var n1 = 0; n1 < 3; ++n1)
1388 for (var n2 = 0; n2 < 3; ++n2) 1404 for (var n2 = 0; n2 < 3; ++n2)
1389 for (var i in mutation) 1405 for (var i in mutation)
1390 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); 1406 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2);
1391 1407
1392 for (var b1 = 0; b1 < 2; ++b1) 1408 for (var b1 = 0; b1 < 2; ++b1)
1393 for (var b2 = 0; b2 < 2; ++b2) 1409 for (var b2 = 0; b2 < 2; ++b2)
1394 for (var n = 0; n < 3; ++n) 1410 for (var n = 0; n < 3; ++n)
1395 for (var i in mutationByIncr) 1411 for (var i in mutationByIncr)
1396 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/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698