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

Side by Side Diff: test/mjsunit/smi-ops.js

Issue 3833004: Patch 2.4 branch with revisions 5643 and 5636. This fixes a problem with com... (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.4/
Patch Set: '' Created 10 years, 2 months 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 | « test/mjsunit/int32-ops.js ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 const SMI_MAX = (1 << 30) - 1; 28 const SMI_MAX = (1 << 29) - 1 + (1 << 29); // Create without overflowing.
29 const SMI_MIN = -(1 << 30); 29 const SMI_MIN = -SMI_MAX - 1; // Create without overflowing.
30 const ONE = 1; 30 const ONE = 1;
31 const ONE_HUNDRED = 100; 31 const ONE_HUNDRED = 100;
32 32
33 const OBJ_42 = new (function() { 33 const OBJ_42 = new (function() {
34 this.valueOf = function() { return 42; }; 34 this.valueOf = function() { return 42; };
35 })(); 35 })();
36 36
37 assertEquals(42, OBJ_42.valueOf()); 37 assertEquals(42, OBJ_42.valueOf());
38 38
39 39
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 assertEquals(-0x40000000, ~v, "~smimax"); 206 assertEquals(-0x40000000, ~v, "~smimax");
207 207
208 // Overflowing ++ and --. 208 // Overflowing ++ and --.
209 v = SMI_MAX; 209 v = SMI_MAX;
210 v++; 210 v++;
211 assertEquals(0x40000000, v, "smimax++"); 211 assertEquals(0x40000000, v, "smimax++");
212 v = SMI_MIN; 212 v = SMI_MIN;
213 v--; 213 v--;
214 assertEquals(-0x40000001, v, "smimin--"); 214 assertEquals(-0x40000001, v, "smimin--");
215 215
216 // Check that comparisons of numbers separated by MIN_SMI work.
217 assertFalse(SMI_MIN > 0);
218 assertFalse(SMI_MIN + 1 > 1);
219 assertFalse(SMI_MIN + 1 > 2);
220 assertFalse(SMI_MIN + 2 > 1);
221 assertFalse(0 < SMI_MIN);
222 assertTrue(-1 < SMI_MAX);
223 assertFalse(SMI_MAX < -1);
224
216 // Not actually Smi operations. 225 // Not actually Smi operations.
217 // Check that relations on unary ops work. 226 // Check that relations on unary ops work.
218 var v = -1.2; 227 var v = -1.2;
219 assertTrue(v == v); 228 assertTrue(v == v);
220 assertTrue(v === v); 229 assertTrue(v === v);
221 assertTrue(v <= v); 230 assertTrue(v <= v);
222 assertTrue(v >= v); 231 assertTrue(v >= v);
223 assertFalse(v < v); 232 assertFalse(v < v);
224 assertFalse(v > v); 233 assertFalse(v > v);
225 assertFalse(v != v); 234 assertFalse(v != v);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 function LeftShiftThreeBy(x) {return 3 << x;} 692 function LeftShiftThreeBy(x) {return 3 << x;}
684 assertEquals(24, LeftShiftThreeBy(3)); 693 assertEquals(24, LeftShiftThreeBy(3));
685 assertEquals(24, LeftShiftThreeBy(35)); 694 assertEquals(24, LeftShiftThreeBy(35));
686 assertEquals(24, LeftShiftThreeBy(67)); 695 assertEquals(24, LeftShiftThreeBy(67));
687 assertEquals(24, LeftShiftThreeBy(-29)); 696 assertEquals(24, LeftShiftThreeBy(-29));
688 697
689 // Regression test for a bug in the ARM code generator. For some register 698 // Regression test for a bug in the ARM code generator. For some register
690 // allocations we got the Smi overflow case wrong. 699 // allocations we got the Smi overflow case wrong.
691 function f(x, y) { return y + ( 1 << (x & 31)); } 700 function f(x, y) { return y + ( 1 << (x & 31)); }
692 assertEquals(-2147483647, f(31, 1)); 701 assertEquals(-2147483647, f(31, 1));
OLDNEW
« no previous file with comments | « test/mjsunit/int32-ops.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698