OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 // The "if (negative) res2 |= 3" below can be emitted as negative && (res2 |= 3) | 5 // The "if (negative) res2 |= 3" below can be emitted as negative && (res2 |= 3) |
6 // in JavaScript. Dart2js produced the wrong output. | 6 // in JavaScript. Dart2js produced the wrong output. |
7 | 7 |
8 _shiftRight(x, y) => x; | 8 _shiftRight(x, y) => x; |
9 int64_bits(x) => x; | 9 int64_bits(x) => x; |
10 | 10 |
11 class A { | 11 class A { |
12 opshr(int n, a2) { | 12 opshr(int n, a2) { |
13 int res2; | 13 int res2; |
14 bool negative = a2 === 496; | 14 bool negative = a2 == 496; |
15 | 15 |
16 res2 = _shiftRight(a2, n); | 16 res2 = _shiftRight(a2, n); |
17 if (negative) { | 17 if (negative) { |
18 res2 |= 3; | 18 res2 |= 3; |
19 } | 19 } |
20 return int64_bits(res2); | 20 return int64_bits(res2); |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 main() { | 24 main() { |
25 var a = new A(); | 25 var a = new A(); |
26 var t; | 26 var t; |
27 for (int i = 0; i < 3; i++) { | 27 for (int i = 0; i < 3; i++) { |
28 t = a.opshr(99, 496); | 28 t = a.opshr(99, 496); |
29 } | 29 } |
30 Expect.equals(499, t); | 30 Expect.equals(499, t); |
31 } | 31 } |
OLD | NEW |