| 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 // Regression test for dart2js. Test that the argument to an unresolved static |
| 6 // getter is only evaluated once. |
| 7 |
| 5 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 6 | 9 |
| 7 class A { | 10 int i = 0; |
| 8 factory A() => 42; | 11 |
| 9 } | 12 p(x) => i++; |
| 13 |
| 14 class A {} |
| 10 | 15 |
| 11 main() { | 16 main() { |
| 12 bool isCheckedMode = false; | 17 bool caught = false; |
| 13 try { | 18 try { |
| 14 String a = 42; | 19 A.unknown = p(2); |
| 15 } catch (e) { | 20 } catch (_) { |
| 16 isCheckedMode = true; | 21 caught = true; |
| 17 } | 22 } |
| 18 if (isCheckedMode) { | 23 Expect.isTrue(caught); |
| 19 Expect.throws(() => new A(), (e) => e is TypeError); | 24 Expect.equals(1, i); |
| 20 } else { | |
| 21 Expect.equals(42, new A()); | |
| 22 } | |
| 23 } | 25 } |
| OLD | NEW |