OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import "package:expect/expect.dart"; | |
6 | |
7 constants() { | |
8 Expect.equals(0, 499 >> 33); | |
9 Expect.equals(0, (499 << 33) & 0xFFFFFFFF); | |
10 } | |
11 | |
12 foo(i) { | |
13 if (i != 0) { | |
14 y--; | |
15 foo(i - 1); | |
16 y++; | |
17 } | |
18 } | |
19 | |
20 var y; | |
21 | |
22 // id returns [x] in a way that should be difficult to predict statically. | |
23 id(x) { | |
24 y = x; | |
25 foo(10); | |
26 return y; | |
27 } | |
28 | |
29 interceptors() { | |
30 Expect.equals(0, id(499) >> 33); | |
31 Expect.equals(0, (id(499) << 33) & 0xFFFFFFFF); | |
32 } | |
33 | |
34 speculative() { | |
35 var a = id(499); | |
36 for (int i = 0; i < 1; i++) { | |
37 Expect.equals(0, a >> 33); | |
38 Expect.equals(0, (a << 33) & 0xFFFFFFFF); | |
39 } | |
40 } | |
41 | |
42 // JavaScript shifts by the amount modulo 32. That is x << y is equivalent to | |
43 // x << (y & 0x1F). Dart does not. | |
44 main() { | |
45 constants(); | |
46 interceptors(); | |
47 speculative(); | |
48 } | |
OLD | NEW |