OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; |
| 6 |
5 // Regression test for dart2js that used to crash on this program. | 7 // Regression test for dart2js that used to crash on this program. |
6 | 8 |
7 class A { | 9 class A { |
8 var b; | 10 var b; |
9 | 11 |
10 // The parameter check here used to confuse the SSA builder when it | 12 // The parameter check here used to confuse the SSA builder when it |
11 // created the call to the constructor body. | 13 // created the call to the constructor body. |
12 A([Map a]) : b = ?a { | 14 A([Map a]) : b = ?a { |
13 Expect.isTrue(b); | 15 Expect.isTrue(b); |
14 } | 16 } |
15 | 17 |
16 // The closure in the constructor body used to confuse the SSA builder | 18 // The closure in the constructor body used to confuse the SSA builder |
17 // when it created the call to the constructor body. | 19 // when it created the call to the constructor body. |
18 A.withClosure(Map a) { | 20 A.withClosure(Map a) { |
19 var c; | 21 var c; |
20 var f = () { return c = 42; }; | 22 var f = () { return c = 42; }; |
21 b = f(); | 23 b = f(); |
22 Expect.equals(42, b); | 24 Expect.equals(42, b); |
23 Expect.equals(42, c); | 25 Expect.equals(42, c); |
24 } | 26 } |
25 } | 27 } |
26 | 28 |
27 main() { | 29 main() { |
28 new A(null); | 30 new A(null); |
29 new A({}); | 31 new A({}); |
30 new A.withClosure(null); | 32 new A.withClosure(null); |
31 new A.withClosure({}); | 33 new A.withClosure({}); |
32 } | 34 } |
OLD | NEW |