OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
7 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; | 7 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; |
8 import 'dart:_interceptors' show | 8 import 'dart:_interceptors' |
9 findInterceptorForType, findConstructorForNativeSubclassType; | 9 show findInterceptorForType, findConstructorForNativeSubclassType; |
10 | 10 |
11 // Test for shadowed fields in classes that extend native classes. | 11 // Test for shadowed fields in classes that extend native classes. |
12 | 12 |
13 @Native("N") | 13 @Native("N") |
14 class N { | 14 class N { |
15 N.init(); | 15 N.init(); |
16 } | 16 } |
17 | 17 |
18 class A extends N { | 18 class A extends N { |
19 var foo = 111; | 19 var foo = 111; |
20 A.init() : super.init(); | 20 A.init() : super.init(); |
21 } | 21 } |
22 | 22 |
23 class B extends A { | 23 class B extends A { |
24 var foo = 222; | 24 var foo = 222; |
25 B.init() : super.init(); | 25 B.init() : super.init(); |
26 | 26 |
27 Afoo() => super.foo; | 27 Afoo() => super.foo; |
28 Bfoo() => foo; | 28 Bfoo() => foo; |
29 } | 29 } |
30 | 30 |
31 B makeB() native; | 31 B makeB() native ; |
32 | 32 |
33 @Creates('=Object') | 33 @Creates('=Object') |
34 getBPrototype() native; | 34 getBPrototype() native ; |
35 | 35 |
36 void setup() native r""" | 36 void setup() native r""" |
37 function B() { } | 37 function B() { } |
38 makeB = function(){return new B;}; | 38 makeB = function(){return new B;}; |
39 | 39 |
40 getBPrototype = function(){return B.prototype;}; | 40 getBPrototype = function(){return B.prototype;}; |
41 """; | 41 """; |
42 | 42 |
43 var inscrutable; | 43 var inscrutable; |
44 | 44 |
(...skipping 10 matching lines...) Expand all Loading... |
55 JS('', '#(#)', constructor, b); | 55 JS('', '#(#)', constructor, b); |
56 | 56 |
57 print(b); | 57 print(b); |
58 | 58 |
59 Expect.equals(222, inscrutable(b).Bfoo()); | 59 Expect.equals(222, inscrutable(b).Bfoo()); |
60 Expect.equals(111, inscrutable(b).Afoo()); | 60 Expect.equals(111, inscrutable(b).Afoo()); |
61 | 61 |
62 Expect.equals(222, b.Bfoo()); | 62 Expect.equals(222, b.Bfoo()); |
63 Expect.equals(111, b.Afoo()); | 63 Expect.equals(111, b.Afoo()); |
64 } | 64 } |
OLD | NEW |