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

Side by Side Diff: tests/language/bit_operations_test.dart

Issue 10539068: Add righ shift test for corner cases, use macro for deopt reasons (all suggested by Slava in a prev… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 | « runtime/vm/code_generator.cc ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Dart test for testing bitwise operations. 4 // Dart test for testing bitwise operations.
5 5
6 class BitOperationsTest { 6 class BitOperationsTest {
7 static testMain() { 7 static testMain() {
8 for (int i = 0; i < 4; i++) { 8 for (int i = 0; i < 4; i++) {
9 testOne(); 9 testOne();
10 } 10 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 Expect.equals(15, 0xF00000000 >> 32); 47 Expect.equals(15, 0xF00000000 >> 32);
48 Expect.equals(1030792151040, 16492674416655 >> 4); 48 Expect.equals(1030792151040, 16492674416655 >> 4);
49 49
50 Expect.equals(0xF0000000000000000F0, 0xF0000000000000000F << 4); 50 Expect.equals(0xF0000000000000000F0, 0xF0000000000000000F << 4);
51 Expect.equals(0xF00000000, 15 << 32); 51 Expect.equals(0xF00000000, 15 << 32);
52 52
53 TestNegativeValueShifts(); 53 TestNegativeValueShifts();
54 TestPositiveValueShifts(); 54 TestPositiveValueShifts();
55 TestNoMaskingOfShiftCount(); 55 TestNoMaskingOfShiftCount();
56 TestNegativeCountShifts(); 56 TestNegativeCountShifts();
57 for (int i = 0; i < 1000; i++) {
58 TestCornerCasesLeftShifts();
59 }
60 }
61
62 static void TestCornerCasesLeftShifts() {
63 var v32 = 0xFF000000;
64 var v64 = 0xFF00000000000000;
65 Expect.equals(0x3, v32 >> 0x1E);
66 Expect.equals(0x1, v32 >> 0x1F);
67 Expect.equals(0x0, v32 >> 0x20);
68 Expect.equals(0x3, v64 >> 0x3E);
69 Expect.equals(0x1, v64 >> 0x3F);
70 Expect.equals(0x0, v64 >> 0x40);
57 } 71 }
58 72
59 static void TestNegativeCountShifts() { 73 static void TestNegativeCountShifts() {
60 bool throwOnLeft(a, b) { 74 bool throwOnLeft(a, b) {
61 try { 75 try {
62 var x = a << b; 76 var x = a << b;
63 return false; 77 return false;
64 } catch(var e) { 78 } catch(var e) {
65 return true; 79 return true;
66 } 80 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 132 }
119 } 133 }
120 134
121 static int ShiftLeft(int a, int b) { return a << b; } 135 static int ShiftLeft(int a, int b) { return a << b; }
122 static int ShiftRight(int a, int b) { return a >> b; } 136 static int ShiftRight(int a, int b) { return a >> b; }
123 } 137 }
124 138
125 main() { 139 main() {
126 BitOperationsTest.testMain(); 140 BitOperationsTest.testMain();
127 } 141 }
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698