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 to see if resolving a hidden native class's method interferes with | 5 // Test to see if resolving a hidden native class's method interferes with |
6 // subsequent resolving the subclass's method. This might happen if the | 6 // subsequent resolving the subclass's method. This might happen if the |
7 // superclass caches the method in the prototype, so shadowing the dispatcher | 7 // superclass caches the method in the prototype, so shadowing the dispatcher |
8 // stored on Object.prototype. | 8 // stored on Object.prototype. |
9 | 9 |
10 // Version 1: It might be possible to call foo directly. | 10 // Version 1: It might be possible to call foo directly. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 var b2 = makeB2(); | 81 var b2 = makeB2(); |
82 Expect.equals(10000 + 99, a2.foo()); | 82 Expect.equals(10000 + 99, a2.foo()); |
83 Expect.equals(20000 + 1000, b2.foo()); | 83 Expect.equals(20000 + 1000, b2.foo()); |
84 | 84 |
85 Expect.equals(10000 + 1, a2.foo(1)); | 85 Expect.equals(10000 + 1, a2.foo(1)); |
86 Expect.equals(20000 + 2, b2.foo(2)); | 86 Expect.equals(20000 + 2, b2.foo(2)); |
87 | 87 |
88 bool caught = false; | 88 bool caught = false; |
89 try { | 89 try { |
90 a1.foo(20); | 90 a1.foo(20); |
91 } catch (var ex) { | 91 } catch (ex) { |
92 caught = true; | 92 caught = true; |
93 Expect.isTrue(ex is NoSuchMethodException); | 93 Expect.isTrue(ex is NoSuchMethodException); |
94 } | 94 } |
95 Expect.isTrue(caught, 'a1.foo(20) should throw'); | 95 Expect.isTrue(caught, 'a1.foo(20) should throw'); |
96 | 96 |
97 caught = false; | 97 caught = false; |
98 try { | 98 try { |
99 var x = 123; | 99 var x = 123; |
100 x.foo(20); | 100 x.foo(20); |
101 } catch (var ex) { | 101 } catch (ex) { |
102 caught = true; | 102 caught = true; |
103 Expect.isTrue(ex is NoSuchMethodException); | 103 Expect.isTrue(ex is NoSuchMethodException); |
104 } | 104 } |
105 Expect.isTrue(caught, "x.foo(20) should throw"); | 105 Expect.isTrue(caught, "x.foo(20) should throw"); |
106 } | 106 } |
OLD | NEW |