1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Flags: --allow-natives-syntax
9 function push_wrapper(array, value) {
12 function pop_wrapper(array) {
16 // Test that Object.observe() notification events are properly sent from
17 // Array.push() and Array.pop() both from optimized and un-optimized code.
20 function somethingChanged(changes) {
24 Object.observe(array, somethingChanged);
25 push_wrapper(array, 1);
27 assertEquals(1, array.length);
29 push_wrapper(array, 1);
31 assertEquals(2, array.length);
33 %OptimizeFunctionOnNextCall(push_wrapper);
34 push_wrapper(array, 1);
36 assertEquals(3, array.length);
38 push_wrapper(array, 1);
40 assertEquals(4, array.length);
45 assertEquals(3, array.length);
49 assertEquals(2, array.length);
51 %OptimizeFunctionOnNextCall(pop_wrapper);
54 assertEquals(1, array.length);
58 assertEquals(0, array.length);