OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Test operations that involve one or more constants. | 28 // Test operations that involve one or more constants. |
29 // The code generator now handles compile-time constants specially. | 29 // The code generator now handles compile-time constants specially. |
30 // Test the code generated when operands are known at compile time | 30 // Test the code generated when operands are known at compile time |
31 | 31 |
32 // Flags: --legacy-const | |
33 | |
34 // Test count operations involving constants | 32 // Test count operations involving constants |
35 function test_count() { | 33 function test_count() { |
36 var x = "foo"; | 34 var x = "foo"; |
37 var y = "3"; | 35 var y = "3"; |
38 | 36 |
39 x += x++; // ++ and -- apply ToNumber to their operand, even for postfix. | 37 x += x++; // ++ and -- apply ToNumber to their operand, even for postfix. |
40 assertEquals(x, "fooNaN", "fooNaN test"); | 38 assertEquals(x, "fooNaN", "fooNaN test"); |
41 x = "luft"; | 39 x = "luft"; |
42 x += ++x; | 40 x += ++x; |
43 assertEquals(x, "luftNaN", "luftNaN test"); | 41 assertEquals(x, "luftNaN", "luftNaN test"); |
(...skipping 18 matching lines...) Expand all Loading... |
62 y++; | 60 y++; |
63 assertEquals(z, -4.5); | 61 assertEquals(z, -4.5); |
64 | 62 |
65 y = 20; | 63 y = 20; |
66 z = y; | 64 z = y; |
67 z++; | 65 z++; |
68 assertEquals(y, 20); | 66 assertEquals(y, 20); |
69 z = y; | 67 z = y; |
70 y++; | 68 y++; |
71 assertEquals(z, 20); | 69 assertEquals(z, 20); |
72 | |
73 const w = 30; | |
74 assertEquals(w++, 30); | |
75 assertEquals(++w, 31); | |
76 assertEquals(++w, 31); | |
77 } | 70 } |
78 | 71 |
79 test_count(); | 72 test_count(); |
80 | 73 |
81 // Test comparison operations that involve one or two constant smis. | 74 // Test comparison operations that involve one or two constant smis. |
82 | 75 |
83 function test() { | 76 function test() { |
84 var i = 5; | 77 var i = 5; |
85 var j = 3; | 78 var j = 3; |
86 | 79 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 x = 123; | 218 x = 123; |
226 // Answer is non-smi and lhs of << is a temporary heap number that we think | 219 // Answer is non-smi and lhs of << is a temporary heap number that we think |
227 // we can overwrite (but we can't because it's a Smi). | 220 // we can overwrite (but we can't because it's a Smi). |
228 assertEquals(1073741824, (x * x) << 30); | 221 assertEquals(1073741824, (x * x) << 30); |
229 } | 222 } |
230 | 223 |
231 | 224 |
232 test(); | 225 test(); |
233 BoolTest(); | 226 BoolTest(); |
234 ShiftTest(); | 227 ShiftTest(); |
OLD | NEW |