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

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

Issue 10440082: Fix a bug in ia32 shift left , implemented more inlined binary operations in x64. (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/token.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Expect.equals(0xF0000000000000000F, 0xF0000000000000000F7 >> 4); 46 Expect.equals(0xF0000000000000000F, 0xF0000000000000000F7 >> 4);
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();
57 }
58
59 static void TestNegativeCountShifts() {
60 bool throwOnLeft(a, b) {
61 try {
62 var x = a << b;
63 return false;
64 } catch(var e) {
65 return true;
66 }
67 }
68
69 bool throwOnRight(a, b) {
70 try {
71 var x = a >> b;
72 return false;
73 } catch(var e) {
74 return true;
75 }
76 }
77
78 Expect.isTrue(throwOnLeft(12, -3));
79 Expect.isTrue(throwOnRight(12, -3));
80 for (int i = 0; i < 4000; i++) {
81 Expect.isFalse(throwOnLeft(12, 3));
82 Expect.isFalse(throwOnRight(12, 3));
83 }
56 } 84 }
57 85
58 static void TestNegativeValueShifts() { 86 static void TestNegativeValueShifts() {
59 for (int value = 0; value > -100; value--) { 87 for (int value = 0; value > -100; value--) {
60 for (int i = 0; i < 300; i++) { 88 for (int i = 0; i < 300; i++) {
61 int b = (value << i) >> i; 89 int b = (value << i) >> i;
62 Expect.equals(value, b); 90 Expect.equals(value, b);
63 } 91 }
64 } 92 }
65 } 93 }
(...skipping 24 matching lines...) Expand all
90 } 118 }
91 } 119 }
92 120
93 static int ShiftLeft(int a, int b) { return a << b; } 121 static int ShiftLeft(int a, int b) { return a << b; }
94 static int ShiftRight(int a, int b) { return a >> b; } 122 static int ShiftRight(int a, int b) { return a >> b; }
95 } 123 }
96 124
97 main() { 125 main() {
98 BitOperationsTest.testMain(); 126 BitOperationsTest.testMain();
99 } 127 }
OLDNEW
« no previous file with comments | « runtime/vm/token.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698