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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 var b2 = makeB2(); | 76 var b2 = makeB2(); |
77 Expect.equals(10000 + 99, a2.foo()); | 77 Expect.equals(10000 + 99, a2.foo()); |
78 Expect.equals(20000 + 1000, b2.foo()); | 78 Expect.equals(20000 + 1000, b2.foo()); |
79 | 79 |
80 Expect.equals(10000 + 1, a2.foo(1)); | 80 Expect.equals(10000 + 1, a2.foo(1)); |
81 Expect.equals(20000 + 2, b2.foo(2)); | 81 Expect.equals(20000 + 2, b2.foo(2)); |
82 | 82 |
83 bool caught = false; | 83 bool caught = false; |
84 try { | 84 try { |
85 a1.foo(20); | 85 a1.foo(20); |
86 } catch (var ex) { | 86 } catch (ex) { |
87 caught = true; | 87 caught = true; |
88 Expect.isTrue(ex is NoSuchMethodException); | 88 Expect.isTrue(ex is NoSuchMethodException); |
89 } | 89 } |
90 Expect.isTrue(caught, 'a1.foo(20) should throw'); | 90 Expect.isTrue(caught, 'a1.foo(20) should throw'); |
91 | 91 |
92 caught = false; | 92 caught = false; |
93 try { | 93 try { |
94 var x = 123; | 94 var x = 123; |
95 x.foo(20); | 95 x.foo(20); |
96 } catch (var ex) { | 96 } catch (ex) { |
97 caught = true; | 97 caught = true; |
98 Expect.isTrue(ex is NoSuchMethodException); | 98 Expect.isTrue(ex is NoSuchMethodException); |
99 } | 99 } |
100 Expect.isTrue(caught, "x.foo(20) should throw"); | 100 Expect.isTrue(caught, "x.foo(20) should throw"); |
101 } | 101 } |
OLD | NEW |