OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 http://dartbug.com/23432. Test that the receiver of a | 5 // Regression test for http://dartbug.com/23432. Test that the receiver of a |
6 // NoSuchMethodError is correct on an intercepted method. The bug (issue 23432) | 6 // NoSuchMethodError is correct on an intercepted method. The bug (issue 23432) |
7 // is that the interceptor is captured instead of the receiver. | 7 // is that the interceptor is captured instead of the receiver. |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
11 class N { | 11 class N { |
12 noSuchMethod(i) { print('x'); return 42; } | 12 noSuchMethod(i) { |
| 13 print('x'); |
| 14 return 42; |
| 15 } |
13 } | 16 } |
14 | 17 |
15 @NoInline() @AssumeDynamic() | 18 @NoInline() |
| 19 @AssumeDynamic() |
16 get NEVER => false; | 20 get NEVER => false; |
17 | 21 |
18 main() { | 22 main() { |
19 var c = 12345; | 23 var c = 12345; |
20 if (NEVER) c = new N(); | 24 if (NEVER) c = new N(); |
21 var e; | 25 var e; |
22 try { | 26 try { |
23 c..toString()..add(88); | 27 c |
| 28 ..toString() |
| 29 ..add(88); |
24 } catch (ex) { | 30 } catch (ex) { |
25 e = ex; | 31 e = ex; |
26 } | 32 } |
27 var s = e.toString(); | 33 var s = e.toString(); |
28 Expect.isTrue(s.contains('$c'), 'Text "$s" should contain "$c"'); | 34 Expect.isTrue(s.contains('$c'), 'Text "$s" should contain "$c"'); |
29 } | 35 } |
OLD | NEW |