Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/compiler/dart2js_native/subclassing_super_field_2_test.dart

Issue 29853003: Test for shadowing fields when extending native classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js_native/subclassing_super_field_1_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import 'dart:_foreign_helper' show JS;
7 import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord;
8 import 'dart:_interceptors' show
9 findInterceptorForType, findConstructorForNativeSubclassType;
10
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.
13
14 class N native "N" {
15 var foo;
16 N.init();
17 }
18
19 class A extends N {
20 var foo = 222;
21 A.init() : super.init();
22 Nfoo() => super.foo; // TODO(sra): Fix compiler assert.
23 }
24
25 class B extends A {
26 var foo = 333;
27 B.init() : super.init();
28 Afoo() => super.foo;
29 Bfoo() => foo;
30
31 toString() => '[N.foo = ${Nfoo()}, A.foo = ${Afoo()}, B.foo = ${Bfoo()}]';
32 }
33
34 B makeB() native;
35
36 @Creates('=Object')
37 getBPrototype() native;
38
39 void setup() native r"""
40 function B() { this.foo = 111; } // N.foo
41 makeB = function(){return new B;};
42
43 getBPrototype = function(){return B.prototype;};
44 """;
45
46 var inscrutable;
47
48 main() {
49 setup();
50 inscrutable = (x) => x;
51
52 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B));
53
54 B b = makeB();
55
56 var constructor = findConstructorForNativeSubclassType(B, 'init');
57 Expect.isNotNull(constructor);
58 JS('', '#(#)', constructor, b);
59
60 print(b);
61
62 Expect.equals(333, inscrutable(b).Bfoo());
63 Expect.equals(222, inscrutable(b).Afoo());
64 Expect.equals(111, inscrutable(b).Nfoo());
65
66 Expect.equals(333, b.Bfoo());
67 Expect.equals(222, b.Afoo());
68 Expect.equals(111, b.Nfoo());
69 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/subclassing_super_field_1_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698