OLD | NEW |
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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 | 1061 |
1062 | 1062 |
1063 // Tests for array methods, first on arrays and then on plain objects | 1063 // Tests for array methods, first on arrays and then on plain objects |
1064 // | 1064 // |
1065 // === ARRAYS === | 1065 // === ARRAYS === |
1066 // | 1066 // |
1067 // Push | 1067 // Push |
1068 reset(); | 1068 reset(); |
1069 var array = [1, 2]; | 1069 var array = [1, 2]; |
1070 Object.observe(array, observer.callback); | 1070 Object.observe(array, observer.callback); |
| 1071 Array.observe(array, observer2.callback); |
1071 array.push(3, 4); | 1072 array.push(3, 4); |
| 1073 array.push(5); |
1072 Object.deliverChangeRecords(observer.callback); | 1074 Object.deliverChangeRecords(observer.callback); |
1073 observer.assertCallbackRecords([ | 1075 observer.assertCallbackRecords([ |
1074 { object: array, name: '2', type: 'new' }, | 1076 { object: array, name: '2', type: 'new' }, |
1075 { object: array, name: 'length', type: 'updated', oldValue: 2 }, | 1077 { object: array, name: 'length', type: 'updated', oldValue: 2 }, |
1076 { object: array, name: '3', type: 'new' }, | 1078 { object: array, name: '3', type: 'new' }, |
1077 { object: array, name: 'length', type: 'updated', oldValue: 3 }, | 1079 { object: array, name: 'length', type: 'updated', oldValue: 3 }, |
| 1080 { object: array, name: '4', type: 'new' }, |
| 1081 { object: array, name: 'length', type: 'updated', oldValue: 4 }, |
| 1082 ]); |
| 1083 Object.deliverChangeRecords(observer2.callback); |
| 1084 observer2.assertCallbackRecords([ |
| 1085 { object: array, type: 'splice', index: 2, removed: [], addedCount: 2 }, |
| 1086 { object: array, type: 'splice', index: 4, removed: [], addedCount: 1 } |
1078 ]); | 1087 ]); |
1079 | 1088 |
1080 // Pop | 1089 // Pop |
1081 reset(); | 1090 reset(); |
1082 var array = [1, 2]; | 1091 var array = [1, 2]; |
1083 Object.observe(array, observer.callback); | 1092 Object.observe(array, observer.callback); |
1084 array.pop(); | 1093 array.pop(); |
1085 array.pop(); | 1094 array.pop(); |
1086 Object.deliverChangeRecords(observer.callback); | 1095 Object.deliverChangeRecords(observer.callback); |
1087 observer.assertCallbackRecords([ | 1096 observer.assertCallbackRecords([ |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 for (var n1 = 0; n1 < 3; ++n1) | 1387 for (var n1 = 0; n1 < 3; ++n1) |
1379 for (var n2 = 0; n2 < 3; ++n2) | 1388 for (var n2 = 0; n2 < 3; ++n2) |
1380 for (var i in mutation) | 1389 for (var i in mutation) |
1381 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); | 1390 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); |
1382 | 1391 |
1383 for (var b1 = 0; b1 < 2; ++b1) | 1392 for (var b1 = 0; b1 < 2; ++b1) |
1384 for (var b2 = 0; b2 < 2; ++b2) | 1393 for (var b2 = 0; b2 < 2; ++b2) |
1385 for (var n = 0; n < 3; ++n) | 1394 for (var n = 0; n < 3; ++n) |
1386 for (var i in mutationByIncr) | 1395 for (var i in mutationByIncr) |
1387 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); | 1396 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); |
OLD | NEW |