| 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 fields with same name as native fields. We expect N.foo to have the | 11 // Test for fields with same name as native fields. We expect N.foo to have the |
| 12 // property name 'foo' and A.foo and B.foo to have non-conflicting names. | 12 // property name 'foo' and A.foo and B.foo to have non-conflicting names. |
| 13 | 13 |
| 14 @Native("N") | 14 @Native("N") |
| 15 class N { | 15 class N { |
| 16 var foo; | 16 var foo; |
| 17 N.init(); | 17 N.init(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 class A extends N { | 20 class A extends N { |
| 21 var foo = 222; | 21 var foo = 222; |
| 22 A.init() : super.init(); | 22 A.init() : super.init(); |
| 23 Nfoo() => super.foo; // TODO(sra): Fix compiler assert. | 23 Nfoo() => super.foo; // TODO(sra): Fix compiler assert. |
| 24 } | 24 } |
| 25 | 25 |
| 26 class B extends A { | 26 class B extends A { |
| 27 var foo = 333; | 27 var foo = 333; |
| 28 B.init() : super.init(); | 28 B.init() : super.init(); |
| 29 Afoo() => super.foo; | 29 Afoo() => super.foo; |
| 30 Bfoo() => foo; | 30 Bfoo() => foo; |
| 31 | 31 |
| 32 toString() => '[N.foo = ${Nfoo()}, A.foo = ${Afoo()}, B.foo = ${Bfoo()}]'; | 32 toString() => '[N.foo = ${Nfoo()}, A.foo = ${Afoo()}, B.foo = ${Bfoo()}]'; |
| 33 } | 33 } |
| 34 | 34 |
| 35 B makeB() native; | 35 B makeB() native ; |
| 36 | 36 |
| 37 @Creates('=Object') | 37 @Creates('=Object') |
| 38 getBPrototype() native; | 38 getBPrototype() native ; |
| 39 | 39 |
| 40 void setup() native r""" | 40 void setup() native r""" |
| 41 function B() { this.foo = 111; } // N.foo | 41 function B() { this.foo = 111; } // N.foo |
| 42 makeB = function(){return new B;}; | 42 makeB = function(){return new B;}; |
| 43 | 43 |
| 44 getBPrototype = function(){return B.prototype;}; | 44 getBPrototype = function(){return B.prototype;}; |
| 45 """; | 45 """; |
| 46 | 46 |
| 47 var inscrutable; | 47 var inscrutable; |
| 48 | 48 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 print(b); | 61 print(b); |
| 62 | 62 |
| 63 Expect.equals(333, inscrutable(b).Bfoo()); | 63 Expect.equals(333, inscrutable(b).Bfoo()); |
| 64 Expect.equals(222, inscrutable(b).Afoo()); | 64 Expect.equals(222, inscrutable(b).Afoo()); |
| 65 Expect.equals(111, inscrutable(b).Nfoo()); | 65 Expect.equals(111, inscrutable(b).Nfoo()); |
| 66 | 66 |
| 67 Expect.equals(333, b.Bfoo()); | 67 Expect.equals(333, b.Bfoo()); |
| 68 Expect.equals(222, b.Afoo()); | 68 Expect.equals(222, b.Afoo()); |
| 69 Expect.equals(111, b.Nfoo()); | 69 Expect.equals(111, b.Nfoo()); |
| 70 } | 70 } |
| OLD | NEW |