OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test the feature where the native string declares the native method's name. | 5 // Test the feature where the native string declares the native method's name. |
6 | 6 |
7 import "native_testing.dart"; | 7 import "native_testing.dart"; |
8 | 8 |
9 @Native("A") | 9 @Native("A") |
10 class A { | 10 class A { |
11 @JSName('fooA') | 11 @JSName('fooA') |
12 int foo() native ; | 12 int foo() native; |
13 } | 13 } |
14 | 14 |
15 @Native("B") | 15 @Native("B") |
16 class B extends A { | 16 class B extends A { |
17 @JSName('fooB') | 17 @JSName('fooB') |
18 int foo() native ; | 18 int foo() native; |
19 } | 19 } |
20 | 20 |
21 makeA() native ; | 21 makeA() native; |
22 makeB() native ; | 22 makeB() native; |
23 | 23 |
24 void setup() native """ | 24 void setup() native """ |
25 // This code is all inside 'setup' and so not accesible from the global scope. | 25 // This code is all inside 'setup' and so not accesible from the global scope. |
26 function inherits(child, parent) { | 26 function inherits(child, parent) { |
27 if (child.prototype.__proto__) { | 27 if (child.prototype.__proto__) { |
28 child.prototype.__proto__ = parent.prototype; | 28 child.prototype.__proto__ = parent.prototype; |
29 } else { | 29 } else { |
30 function tmp() {}; | 30 function tmp() {}; |
31 tmp.prototype = parent.prototype; | 31 tmp.prototype = parent.prototype; |
32 child.prototype = new tmp(); | 32 child.prototype = new tmp(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 expectNoSuchMethod(action, note) { | 88 expectNoSuchMethod(action, note) { |
89 bool caught = false; | 89 bool caught = false; |
90 try { | 90 try { |
91 action(); | 91 action(); |
92 } catch (ex) { | 92 } catch (ex) { |
93 caught = true; | 93 caught = true; |
94 Expect.isTrue(ex is NoSuchMethodError, note); | 94 Expect.isTrue(ex is NoSuchMethodError, note); |
95 } | 95 } |
96 Expect.isTrue(caught, note); | 96 Expect.isTrue(caught, note); |
97 } | 97 } |
OLD | NEW |