OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 "native_testing.dart"; | 5 import "native_testing.dart"; |
6 | 6 |
7 @Native("A") | 7 @Native("A") |
8 class A { | 8 class A { |
9 bar() => 42; | 9 bar() => 42; |
10 } | 10 } |
11 | 11 |
12 @Native("B") | 12 @Native("B") |
13 class B { | 13 class B { |
14 foo() => 42; | 14 foo() => 42; |
15 } | 15 } |
16 | 16 |
17 makeA() native ; | 17 makeA() native; |
18 | 18 |
19 setup() native """ | 19 setup() native """ |
20 function A() {} | 20 function A() {} |
21 makeA = function() { return new A; } | 21 makeA = function() { return new A; } |
22 self.nativeConstructor(A); | 22 self.nativeConstructor(A); |
23 """; | 23 """; |
24 | 24 |
25 main() { | 25 main() { |
26 nativeTesting(); | 26 nativeTesting(); |
27 setup(); | 27 setup(); |
28 var a = makeA(); | 28 var a = makeA(); |
29 a.bar(); | 29 a.bar(); |
30 var exception; | 30 var exception; |
31 try { | 31 try { |
32 a.foo(); | 32 a.foo(); |
33 } on NoSuchMethodError catch (e) { | 33 } on NoSuchMethodError catch (e) { |
34 exception = e; | 34 exception = e; |
35 } | 35 } |
36 Expect.isNotNull(exception); | 36 Expect.isNotNull(exception); |
37 } | 37 } |
OLD | NEW |