| OLD | NEW |
| 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 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation --enable-inlining-annotations | 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-co
mpilation --enable-inlining-annotations |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 const neverInline = "NeverInline"; | 9 const neverInline = "NeverInline"; |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void testRightShift64Bit() { | 91 void testRightShift64Bit() { |
| 92 var t = 0x1ffffffff; | 92 var t = 0x1ffffffff; |
| 93 Expect.equals(0xffffffff, t >> 1); | 93 Expect.equals(0xffffffff, t >> 1); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void testLeftShift64Bit() { | 96 void testLeftShift64Bit() { |
| 97 var t = 0xffffffff; | 97 var t = 0xffffffff; |
| 98 Expect.equals(0xffffffff, t << 0); | 98 Expect.equals(0xffffffff, t << 0); |
| 99 Expect.equals(0x1fffffffe, t << 1); | 99 Expect.equals(0x1fffffffe, t << 1); |
| 100 Expect.equals(0x7fffffff80000000, t << 31); | 100 Expect.equals(0x7fffffff80000000, t << 31); |
| 101 Expect.equals(0x10000000000000000, 2*(t+1) << 31); //# 01: static type warning | 101 Expect.equals(0x10000000000000000, 2*(t+1) << 31); //# 01: compile-time error |
| 102 Expect.equals(0x20000000000000000, 4*(t+1) << 31); //# 02: static type warning | 102 Expect.equals(0x20000000000000000, 4*(t+1) << 31); //# 02: compile-time error |
| 103 Expect.equals(0x8000000000000000, (t + 1) << 31); | 103 Expect.equals(0x8000000000000000, (t + 1) << 31); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void testLeftShift64BitWithOverflow1() { | 106 void testLeftShift64BitWithOverflow1() { |
| 107 var t = 0xffffffff; | 107 var t = 0xffffffff; |
| 108 Expect.equals(0x10000000000000000, 2*(t+1) << 31); //# 03: static type warning | 108 Expect.equals(0x10000000000000000, 2*(t+1) << 31); //# 03: compile-time error |
| 109 } | 109 } |
| 110 | 110 |
| 111 void testLeftShift64BitWithOverflow2() { | 111 void testLeftShift64BitWithOverflow2() { |
| 112 var t = 0xffffffff; | 112 var t = 0xffffffff; |
| 113 Expect.equals(0x20000000000000000, 4*(t+1) << 31); //# 04: static type warning | 113 Expect.equals(0x20000000000000000, 4*(t+1) << 31); //# 04: compile-time error |
| 114 } | 114 } |
| 115 | 115 |
| 116 void testLeftShift64BitWithOverflow3() { | 116 void testLeftShift64BitWithOverflow3() { |
| 117 var t = 0xffffffff; | 117 var t = 0xffffffff; |
| 118 Expect.equals(0x8000000000000000, (t + 1) << 31); | 118 Expect.equals(0x8000000000000000, (t + 1) << 31); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void testNegativeCountShifts() { | 121 void testNegativeCountShifts() { |
| 122 bool throwOnLeft(a, b) { | 122 bool throwOnLeft(a, b) { |
| 123 try { | 123 try { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 testRightShift65() { | 210 testRightShift65() { |
| 211 var a = 0x5f22334455667788; | 211 var a = 0x5f22334455667788; |
| 212 var b = -0x5f22334455667788; | 212 var b = -0x5f22334455667788; |
| 213 | 213 |
| 214 for (var i = 0; i < 20; ++i) { | 214 for (var i = 0; i < 20; ++i) { |
| 215 Expect.equals(0, rightShift65Noinline(a)); | 215 Expect.equals(0, rightShift65Noinline(a)); |
| 216 Expect.equals(-1, rightShift65Noinline(b)); | 216 Expect.equals(-1, rightShift65Noinline(b)); |
| 217 } | 217 } |
| 218 } | 218 } |
| OLD | NEW |