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

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

Issue 68343016: [Object.observe] Don't force normalization of elements for observed objects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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/x64/stub-cache-x64.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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 { object: thingy, type: Thingy.MULTIPLY, multiplied: 2 }, 607 { object: thingy, type: Thingy.MULTIPLY, multiplied: 2 },
608 { object: thingy, type: 'update', name: 'a', oldValue: 10 }, 608 { object: thingy, type: 'update', name: 'a', oldValue: 10 },
609 { 609 {
610 object: thingy, 610 object: thingy,
611 type: Thingy.INCREMENT_AND_MULTIPLY, 611 type: Thingy.INCREMENT_AND_MULTIPLY,
612 incremented: 2, 612 incremented: 2,
613 multiplied: 2 613 multiplied: 2
614 } 614 }
615 ]); 615 ]);
616 616
617 // ArrayPush cached stub
618 reset();
619
620 function pushMultiple(arr) {
621 arr.push('a');
622 arr.push('b');
623 arr.push('c');
624 }
625
626 for (var i = 0; i < 5; i++) {
627 var arr = [];
628 pushMultiple(arr);
629 }
630
631 for (var i = 0; i < 5; i++) {
632 reset();
633 var arr = [];
634 Object.observe(arr, observer.callback);
635 pushMultiple(arr);
636 Object.unobserve(arr, observer.callback);
637 Object.deliverChangeRecords(observer.callback);
638 observer.assertCallbackRecords([
639 { object: arr, type: 'add', name: '0' },
640 { object: arr, type: 'update', name: 'length', oldValue: 0 },
641 { object: arr, type: 'add', name: '1' },
642 { object: arr, type: 'update', name: 'length', oldValue: 1 },
643 { object: arr, type: 'add', name: '2' },
644 { object: arr, type: 'update', name: 'length', oldValue: 2 },
645 ]);
646 }
647
648
649 // ArrayPop cached stub
650 reset();
651
652 function popMultiple(arr) {
653 arr.pop();
654 arr.pop();
655 arr.pop();
656 }
657
658 for (var i = 0; i < 5; i++) {
659 var arr = ['a', 'b', 'c'];
660 popMultiple(arr);
661 }
662
663 for (var i = 0; i < 5; i++) {
664 reset();
665 var arr = ['a', 'b', 'c'];
666 Object.observe(arr, observer.callback);
667 popMultiple(arr);
668 Object.unobserve(arr, observer.callback);
669 Object.deliverChangeRecords(observer.callback);
670 observer.assertCallbackRecords([
671 { object: arr, type: 'delete', name: '2', oldValue: 'c' },
672 { object: arr, type: 'update', name: 'length', oldValue: 3 },
673 { object: arr, type: 'delete', name: '1', oldValue: 'b' },
674 { object: arr, type: 'update', name: 'length', oldValue: 2 },
675 { object: arr, type: 'delete', name: '0', oldValue: 'a' },
676 { object: arr, type: 'update', name: 'length', oldValue: 1 },
677 ]);
678 }
679
617 680
618 reset(); 681 reset();
619 function RecursiveThingy() {} 682 function RecursiveThingy() {}
620 683
621 RecursiveThingy.MULTIPLY_FIRST_N = 'multiplyFirstN'; 684 RecursiveThingy.MULTIPLY_FIRST_N = 'multiplyFirstN';
622 685
623 RecursiveThingy.prototype = { 686 RecursiveThingy.prototype = {
624 __proto__: Array.prototype, 687 __proto__: Array.prototype,
625 688
626 multiplyFirstN: function(amount, n) { 689 multiplyFirstN: function(amount, n) {
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 for (var n1 = 0; n1 < 3; ++n1) 1779 for (var n1 = 0; n1 < 3; ++n1)
1717 for (var n2 = 0; n2 < 3; ++n2) 1780 for (var n2 = 0; n2 < 3; ++n2)
1718 for (var i in mutation) 1781 for (var i in mutation)
1719 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); 1782 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2);
1720 1783
1721 for (var b1 = 0; b1 < 2; ++b1) 1784 for (var b1 = 0; b1 < 2; ++b1)
1722 for (var b2 = 0; b2 < 2; ++b2) 1785 for (var b2 = 0; b2 < 2; ++b2)
1723 for (var n = 0; n < 3; ++n) 1786 for (var n = 0; n < 3; ++n)
1724 for (var i in mutationByIncr) 1787 for (var i in mutationByIncr)
1725 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); 1788 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1);
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698