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

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

Issue 10891020: Update almost all tests (except co19) to use the new try-catch syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Created 8 years, 3 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 | « tests/language/bad_named_parameters_test.dart ('k') | tests/language/bool_test.dart » ('j') | 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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++) { 57 for (int i = 0; i < 1000; i++) {
58 TestCornerCasesLeftShifts(); 58 TestCornerCasesLeftShifts();
59 } 59 }
60 } 60 }
61 61
62 static void TestCornerCasesLeftShifts() { 62 static void TestCornerCasesLeftShifts() {
63 var v32 = 0xFF000000; 63 var v32 = 0xFF000000;
64 var v64 = 0xFF00000000000000; 64 var v64 = 0xFF00000000000000;
65 Expect.equals(0x3, v32 >> 0x1E); 65 Expect.equals(0x3, v32 >> 0x1E);
66 Expect.equals(0x1, v32 >> 0x1F); 66 Expect.equals(0x1, v32 >> 0x1F);
67 Expect.equals(0x0, v32 >> 0x20); 67 Expect.equals(0x0, v32 >> 0x20);
68 Expect.equals(0x3, v64 >> 0x3E); 68 Expect.equals(0x3, v64 >> 0x3E);
69 Expect.equals(0x1, v64 >> 0x3F); 69 Expect.equals(0x1, v64 >> 0x3F);
70 Expect.equals(0x0, v64 >> 0x40); 70 Expect.equals(0x0, v64 >> 0x40);
71 } 71 }
72 72
73 static void TestNegativeCountShifts() { 73 static void TestNegativeCountShifts() {
74 bool throwOnLeft(a, b) { 74 bool throwOnLeft(a, b) {
75 try { 75 try {
76 var x = a << b; 76 var x = a << b;
77 return false; 77 return false;
78 } catch(var e) { 78 } catch (e) {
79 return true; 79 return true;
80 } 80 }
81 } 81 }
82 82
83 bool throwOnRight(a, b) { 83 bool throwOnRight(a, b) {
84 try { 84 try {
85 var x = a >> b; 85 var x = a >> b;
86 return false; 86 return false;
87 } catch(var e) { 87 } catch (e) {
88 return true; 88 return true;
89 } 89 }
90 } 90 }
91 91
92 Expect.isTrue(throwOnLeft(12, -3)); 92 Expect.isTrue(throwOnLeft(12, -3));
93 Expect.isTrue(throwOnRight(12, -3)); 93 Expect.isTrue(throwOnRight(12, -3));
94 for (int i = 0; i < 4000; i++) { 94 for (int i = 0; i < 4000; i++) {
95 Expect.isFalse(throwOnLeft(12, 3)); 95 Expect.isFalse(throwOnLeft(12, 3));
96 Expect.isFalse(throwOnRight(12, 3)); 96 Expect.isFalse(throwOnRight(12, 3));
97 } 97 }
98 } 98 }
99 99
100 static void TestNegativeValueShifts() { 100 static void TestNegativeValueShifts() {
101 for (int value = 0; value > -100; value--) { 101 for (int value = 0; value > -100; value--) {
(...skipping 30 matching lines...) Expand all
132 } 132 }
133 } 133 }
134 134
135 static int ShiftLeft(int a, int b) { return a << b; } 135 static int ShiftLeft(int a, int b) { return a << b; }
136 static int ShiftRight(int a, int b) { return a >> b; } 136 static int ShiftRight(int a, int b) { return a >> b; }
137 } 137 }
138 138
139 main() { 139 main() {
140 BitOperationsTest.testMain(); 140 BitOperationsTest.testMain();
141 } 141 }
OLDNEW
« no previous file with comments | « tests/language/bad_named_parameters_test.dart ('k') | tests/language/bool_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698