Chromium Code Reviews| Index: test/mjsunit/elements-transition.js |
| diff --git a/test/mjsunit/elements-transition.js b/test/mjsunit/elements-transition.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..77c2aa2c8873f14332dc7641f0d97fd7d4b31c7b |
| --- /dev/null |
| +++ b/test/mjsunit/elements-transition.js |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2011 the V8 project authors. All rights reserved. |
| +// Redistribution and use in source and binary forms, with or without |
| +// modification, are permitted provided that the following conditions are |
| +// met: |
| +// |
| +// * Redistributions of source code must retain the above copyright |
| +// notice, this list of conditions and the following disclaimer. |
| +// * Redistributions in binary form must reproduce the above |
| +// copyright notice, this list of conditions and the following |
| +// disclaimer in the documentation and/or other materials provided |
| +// with the distribution. |
| +// * Neither the name of Google Inc. nor the names of its |
| +// contributors may be used to endorse or promote products derived |
| +// from this software without specific prior written permission. |
| +// |
| +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + |
| +// Flags: --allow-natives-syntax --smi-only-arrays |
| + |
| +function test(test_double, test_object, set) { |
| + var length = 10000; |
| + var you = new Array(length); |
| + var me = new Array(length); |
|
Jakob Kummerow
2011/10/13 09:15:59
As discussed, please add a comment explaining why
|
| + |
| + assertTrue(%HasFastSmiOnlyElements(you)); |
| + assertTrue(%HasFastSmiOnlyElements(me)); |
| + for (var i = 0; i < length; i++) { |
| + if (i == (length*0.7 | 0) && test_double) { |
| + set(you, i, 0.5); |
| + set(me, i, 0.5); |
| + assertTrue(%HasFastDoubleElements(you)); |
| + assertTrue(%HasFastDoubleElements(me)); |
| + } else if (i == (length*0.8 | 0) && test_object) { |
| + set(you, i, 'object'); |
| + set(me, i, 'object'); |
| + assertTrue(%HasFastElements(you)); |
| + assertTrue(%HasFastElements(me)); |
| + } else { |
| + set(you, i, 2*i); |
| + set(me, i, 2*i); |
| + } |
| + } |
| + |
| + for (var i = 0; i < length; i++) { |
| + if (i == (length*0.7 | 0) && test_double) { |
| + assertEquals(0.5, you[i]); |
| + assertEquals(0.5, me[i]); |
| + } else if (i == (length*0.8 | 0) && test_object) { |
| + assertEquals('object', you[i]); |
| + assertEquals('object', me[i]); |
| + } else { |
| + assertEquals(2*i, me[i]); |
| + assertEquals(2*i, you[i]); |
| + } |
| + } |
| +} |
| + |
| +test(false, false, function(a,i,v){ a[i] = v; }); |
| +test(true, false, function(a,i,v){ a[i] = v; }); |
| +test(false, true, function(a,i,v){ a[i] = v; }); |
| +test(true, true, function(a,i,v){ a[i] = v; }); |