| 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 import "native_testing.dart"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
| 6 | 7 |
| 7 // Test to see if resolving a hidden native class's method to noSuchMethod | 8 // Test to see if resolving a hidden native class's method to noSuchMethod |
| 8 // interferes with subsequent resolving of the method. This might happen if the | 9 // interferes with subsequent resolving of the method. This might happen if the |
| 9 // noSuchMethod is cached on Object.prototype. | 10 // noSuchMethod is cached on Object.prototype. |
| 10 | 11 |
| 11 @Native("A1") | 12 @Native("A1") |
| 12 class A1 {} | 13 class A1 {} |
| 13 | 14 |
| 14 @Native("B1") | 15 @Native("B1") |
| 15 class B1 extends A1 {} | 16 class B1 extends A1 {} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 52 |
| 52 function A2(){} | 53 function A2(){} |
| 53 function B2(){} | 54 function B2(){} |
| 54 inherits(B2, A2); | 55 inherits(B2, A2); |
| 55 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';} | 56 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';} |
| 56 | 57 |
| 57 makeA2 = function(){return new A2}; | 58 makeA2 = function(){return new A2}; |
| 58 makeB2 = function(){return new B2}; | 59 makeB2 = function(){return new B2}; |
| 59 | 60 |
| 60 makeObject = function(){return new Object}; | 61 makeObject = function(){return new Object}; |
| 61 | |
| 62 self.nativeConstructor(A1); | |
| 63 self.nativeConstructor(A2); | |
| 64 self.nativeConstructor(B1); | |
| 65 self.nativeConstructor(B2); | |
| 66 """; | 62 """; |
| 67 | 63 |
| 68 main() { | 64 main() { |
| 69 nativeTesting(); | |
| 70 setup(); | 65 setup(); |
| 71 | 66 |
| 72 var a1 = makeA1(); | 67 var a1 = makeA1(); |
| 73 var b1 = makeB1(); | 68 var b1 = makeB1(); |
| 74 var ob = makeObject(); | 69 var ob = makeObject(); |
| 75 | 70 |
| 76 // Does calling missing methods in one tree of inheritance forest affect other | 71 // Does calling missing methods in one tree of inheritance forest affect other |
| 77 // trees? | 72 // trees? |
| 78 expectNoSuchMethod(() => b1.foo(), 'b1.foo()'); | 73 expectNoSuchMethod(() => b1.foo(), 'b1.foo()'); |
| 79 expectNoSuchMethod(() => a1.foo(), 'a1.foo()'); | 74 expectNoSuchMethod(() => a1.foo(), 'a1.foo()'); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 94 expectNoSuchMethod(action, note) { | 89 expectNoSuchMethod(action, note) { |
| 95 bool caught = false; | 90 bool caught = false; |
| 96 try { | 91 try { |
| 97 action(); | 92 action(); |
| 98 } catch (ex) { | 93 } catch (ex) { |
| 99 caught = true; | 94 caught = true; |
| 100 Expect.isTrue(ex is NoSuchMethodError, note); | 95 Expect.isTrue(ex is NoSuchMethodError, note); |
| 101 } | 96 } |
| 102 Expect.isTrue(caught, note); | 97 Expect.isTrue(caught, note); |
| 103 } | 98 } |
| OLD | NEW |