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

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

Issue 10343002: Make bit-operations return a positive result. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cache unsigned shift precedences. Created 8 years, 7 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/language.status ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 constants() {
6 Expect.equals(0x80000000, 0x80000000 | 0);
7 Expect.equals(0x80000001, 0x80000000 | 1);
8 Expect.equals(0x80000000, 0x80000000 | 0x80000000);
9 Expect.equals(0xFFFFFFFF, 0xFFFF0000 | 0xFFFF);
10 Expect.equals(0x80000000, 0x80000000 & 0xFFFFFFFF);
11 Expect.equals(0x80000000, 0x80000000 & 0x80000000);
12 Expect.equals(0x80000000, 0x80000000 & 0xF0000000);
13 Expect.equals(0x80000000, 0xFFFFFFFF & 0x80000000);
14 Expect.equals(0x80000000, 0x80000000 ^ 0);
15 Expect.equals(0xFFFFFFFF, 0x80000000 ^ 0x7FFFFFFF);
16 Expect.equals(0xFFFFFFFF, 0x7FFFFFFF ^ 0x80000000);
17 Expect.equals(0xF0000000, 0x70000000 ^ 0x80000000);
18 Expect.equals(0x80000000, 1 << 31);
19 Expect.equals(0xFFFFFFF0, 0xFFFFFFF << 4);
20 Expect.equals(0x7FFFFFFF, 0xFFFFFFFF >> 1);
21 Expect.equals(0xFFFFFFFC,
22 ((((((0xFFFFFFF << 4) // 0xFFFFFFF0
23 >> 1) // 0x7FFFFFF8
24 | 0x80000000) // 0xFFFFFFF8
25 >> 2) // 0x3FFFFFFE
26 ^ 0x40000000) // 0x7FFFFFFE
27 << 1));
28 }
29
30 foo(i) {
31 if (i != 0) {
32 y--;
33 foo(i - 1);
34 y++;
35 }
36 }
37
38 var y;
39
40 // id returns [x] in a way that should be difficult to predict statically.
41 id(x) {
42 y = x;
43 foo(10);
44 return y;
45 }
46
47 interceptors() {
48 Expect.equals(0x80000000, id(0x80000000) | id(0));
49 Expect.equals(0x80000001, id(0x80000000) | id(1));
50 Expect.equals(0x80000000, id(0x80000000) | id(0x80000000));
51 Expect.equals(0xFFFFFFFF, id(0xFFFF0000) | id(0xFFFF));
52 Expect.equals(0x80000000, id(0x80000000) & id(0xFFFFFFFF));
53 Expect.equals(0x80000000, id(0x80000000) & id(0x80000000));
54 Expect.equals(0x80000000, id(0x80000000) & id(0xF0000000));
55 Expect.equals(0x80000000, id(0xFFFFFFFF) & id(0x80000000));
56 Expect.equals(0x80000000, id(0x80000000) ^ id(0));
57 Expect.equals(0xFFFFFFFF, id(0x80000000) ^ id(0x7FFFFFFF));
58 Expect.equals(0xFFFFFFFF, id(0x7FFFFFFF) ^ id(0x80000000));
59 Expect.equals(0xF0000000, id(0x70000000) ^ id(0x80000000));
60 Expect.equals(0x80000000, id(1) << id(31));
61 Expect.equals(0xFFFFFFF0, id(0xFFFFFFF) << id(4));
62 Expect.equals(0x7FFFFFFF, id(0xFFFFFFFF) >> id(1));
63 Expect.equals(0xFFFFFFFC,
64 ((((((id(0xFFFFFFF) << 4) // 0xFFFFFFF0
65 >> 1) // 0x7FFFFFF8
66 | 0x80000000) // 0xFFFFFFF8
67 >> 2) // 0x3FFFFFFE
68 ^ 0x40000000) // 0x7FFFFFFE
69 << 1));
70 }
71
72 speculative() {
73 var a = id(0x80000000);
74 var b = id(0);
75 var c = id(1);
76 var d = id(0xFFFF0000);
77 var e = id(0xFFFF);
78 var f = id(0xFFFFFFFF);
79 var g = id(0xF0000000);
80 var h = id(0x7FFFFFFF);
81 var j = id(0x70000000);
82 var k = id(31);
83 var l = id(4);
84 var m = id(0xFFFFFFF);
85 for (int i = 0; i < 1; i++) {
86 Expect.equals(0x80000000, a | b);
87 Expect.equals(0x80000001, a | c);
88 Expect.equals(0x80000000, a | a);
89 Expect.equals(0xFFFFFFFF, d | e);
90 Expect.equals(0x80000000, a & f);
91 Expect.equals(0x80000000, a & a);
92 Expect.equals(0x80000000, a & g);
93 Expect.equals(0x80000000, f & a);
94 Expect.equals(0x80000000, a ^ b);
95 Expect.equals(0xFFFFFFFF, a ^ h);
96 Expect.equals(0xFFFFFFFF, h ^ a);
97 Expect.equals(0xF0000000, j ^ a);
98 Expect.equals(0x80000000, c << k);
99 Expect.equals(0xFFFFFFF0, m << l);
100 Expect.equals(0x7FFFFFFF, f >> c);
101 Expect.equals(0xFFFFFFFC,
102 ((((((m << 4) // 0xFFFFFFF0
103 >> 1) // 0x7FFFFFF8
104 | 0x80000000) // 0xFFFFFFF8
105 >> 2) // 0x3FFFFFFE
106 ^ 0x40000000) // 0x7FFFFFFE
107 << 1));
108 }
109 }
110
111 main() {
112 constants();
113 interceptors();
114 speculative();
115 }
OLDNEW
« no previous file with comments | « tests/language/language.status ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698