OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2011 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | |
28 // Flags: --allow-natives-syntax --smi-only-arrays | |
29 | |
30 function test(test_double, test_object, set) { | |
31 var length = 10000; | |
32 var you = new Array(length); | |
33 var me = new Array(length); | |
Jakob Kummerow
2011/10/13 09:15:59
As discussed, please add a comment explaining why
| |
34 | |
35 assertTrue(%HasFastSmiOnlyElements(you)); | |
36 assertTrue(%HasFastSmiOnlyElements(me)); | |
37 for (var i = 0; i < length; i++) { | |
38 if (i == (length*0.7 | 0) && test_double) { | |
39 set(you, i, 0.5); | |
40 set(me, i, 0.5); | |
41 assertTrue(%HasFastDoubleElements(you)); | |
42 assertTrue(%HasFastDoubleElements(me)); | |
43 } else if (i == (length*0.8 | 0) && test_object) { | |
44 set(you, i, 'object'); | |
45 set(me, i, 'object'); | |
46 assertTrue(%HasFastElements(you)); | |
47 assertTrue(%HasFastElements(me)); | |
48 } else { | |
49 set(you, i, 2*i); | |
50 set(me, i, 2*i); | |
51 } | |
52 } | |
53 | |
54 for (var i = 0; i < length; i++) { | |
55 if (i == (length*0.7 | 0) && test_double) { | |
56 assertEquals(0.5, you[i]); | |
57 assertEquals(0.5, me[i]); | |
58 } else if (i == (length*0.8 | 0) && test_object) { | |
59 assertEquals('object', you[i]); | |
60 assertEquals('object', me[i]); | |
61 } else { | |
62 assertEquals(2*i, me[i]); | |
63 assertEquals(2*i, you[i]); | |
64 } | |
65 } | |
66 } | |
67 | |
68 test(false, false, function(a,i,v){ a[i] = v; }); | |
69 test(true, false, function(a,i,v){ a[i] = v; }); | |
70 test(false, true, function(a,i,v){ a[i] = v; }); | |
71 test(true, true, function(a,i,v){ a[i] = v; }); | |
OLD | NEW |