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

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

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 | « dart/tests/compiler/dart2js_native/dart2js_native.status ('k') | dart/tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Creates, setNativeSubclassDispatchRecord; 7 import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord;
8 import 'dart:_interceptors' show 8 import 'dart:_interceptors' show
9 findInterceptorForType, findConstructorForNativeSubclassType; 9 findInterceptorForType, findConstructorForNativeSubclassType;
10 10
11 // Test for super access from classes that extend native classes. 11 // Test for super access from classes that extend native classes.
12 12
13 class N1 native "N1" { 13 class N1 native "N1" {
14 } 14 }
15 15
16 class N2 extends N1 native "N2" { 16 class N2 extends N1 native "N2" {
17 N2.init(); 17 N2.init();
18 var text; 18 String text;
19 foo() native; 19 foo() native;
20 } 20 }
21 21
22 class AA extends N2 { 22 class AA extends N2 {
23 AA.init() : super.init(); 23 AA.init() : super.init();
24 var afield; 24 String afield;
25 afun() => 'afun:$afield'; 25 afun() => 'afun:$afield';
26 } 26 }
27 27
28 class BB extends AA { 28 class BB extends AA {
29 BB.init() : super.init(); 29 BB.init() : super.init();
30 30
31 get text => super.text; 31 get text => super.text;
32 set text(value) => super.text = value; 32 set text(value) => super.text = value;
33 foo() => super.foo(); 33 foo() => super.foo();
34 34
(...skipping 21 matching lines...) Expand all
56 56
57 testSuperOnNative() { 57 testSuperOnNative() {
58 BB b1 = makeBB(); 58 BB b1 = makeBB();
59 BB b2 = makeBB(); 59 BB b2 = makeBB();
60 60
61 var constructor = findConstructorForNativeSubclassType(BB, 'init'); 61 var constructor = findConstructorForNativeSubclassType(BB, 'init');
62 Expect.isNotNull(constructor); 62 Expect.isNotNull(constructor);
63 JS('', '#(#)', constructor, b1); 63 JS('', '#(#)', constructor, b1);
64 JS('', '#(#)', constructor, b2); 64 JS('', '#(#)', constructor, b2);
65 65
66 b1.text = 'one'; 66 b1.text = inscrutable('one');
67 b2.text = 'two'; 67 b2.text = inscrutable('two');
68 68
69 print('b1.text ${inscrutable(b1).text}'); 69 print('b1.text ${inscrutable(b1).text}');
70 print('b2.text ${inscrutable(b2).text}'); 70 print('b2.text ${inscrutable(b2).text}');
71 71
72 print('b1.foo() ${inscrutable(b1).foo()}'); 72 print('b1.foo() ${inscrutable(b1).foo()}');
73 print('b2.foo() ${inscrutable(b2).foo()}'); 73 print('b2.foo() ${inscrutable(b2).foo()}');
74 74
75 Expect.equals('one', b1.text); 75 Expect.equals('one', b1.text);
76 Expect.equals('two', b1.text); 76 Expect.equals('two', b2.text);
77 77
78 Expect.equals('foo:one', b1.foo()); 78 Expect.equals('foo:one', b1.foo());
79 Expect.equals('foo:two', b2.foo()); 79 Expect.equals('foo:two', b2.foo());
80 80
81 inscrutable(b1).text = 'three'; 81 inscrutable(b1).text = inscrutable('three');
82 inscrutable(b2).text = 'four'; 82 inscrutable(b2).text = inscrutable('four');
83 83
84 Expect.equals('three', inscrutable(b1).text); 84 Expect.equals('three', inscrutable(b1).text);
85 Expect.equals('four', inscrutable(b1).text); 85 Expect.equals('four', inscrutable(b2).text);
86 86
87 Expect.equals('foo:three', inscrutable(b1).foo()); 87 Expect.equals('foo:three', inscrutable(b1).foo());
88 Expect.equals('foo:four', inscrutable(b2).foo()); 88 Expect.equals('foo:four', inscrutable(b2).foo());
89 } 89 }
90 90
91 testSuperOnSubclassOfNative() { 91 testSuperOnSubclassOfNative() {
92 BB b1 = makeBB(); 92 BB b1 = makeBB();
93 BB b2 = makeBB(); 93 BB b2 = makeBB();
94 94
95 var constructor = findConstructorForNativeSubclassType(BB, 'init'); 95 var constructor = findConstructorForNativeSubclassType(BB, 'init');
96 Expect.isNotNull(constructor); 96 Expect.isNotNull(constructor);
97 JS('', '#(#)', constructor, b1); 97 JS('', '#(#)', constructor, b1);
98 JS('', '#(#)', constructor, b2); 98 JS('', '#(#)', constructor, b2);
99 99
100 b1.afield = 'one'; 100 b1.afield = inscrutable('one');
101 b2.afield = 'two'; 101 b2.afield = inscrutable('two');
102 102
103 print('b1.afield ${inscrutable(b1).afield}'); 103 print('b1.afield ${inscrutable(b1).afield}');
104 print('b2.afield ${inscrutable(b2).afield}'); 104 print('b2.afield ${inscrutable(b2).afield}');
105 105
106 print('b1.afun() ${inscrutable(b1).afun()}'); 106 print('b1.afun() ${inscrutable(b1).afun()}');
107 print('b2.afun() ${inscrutable(b2).afun()}'); 107 print('b2.afun() ${inscrutable(b2).afun()}');
108 108
109 Expect.equals('one', b1.afield); 109 Expect.equals('one', b1.afield);
110 Expect.equals('two', b1.afield); 110 Expect.equals('two', b2.afield);
111 111
112 Expect.equals('afun:one', b1.afun()); 112 Expect.equals('afun:one', b1.afun());
113 Expect.equals('afun:two', b2.afun()); 113 Expect.equals('afun:two', b2.afun());
114 114
115 115
116 inscrutable(b1).afield = 'three'; 116 inscrutable(b1).afield = inscrutable('three');
117 inscrutable(b2).afield = 'four'; 117 inscrutable(b2).afield = inscrutable('four');
118 118
119 Expect.equals('three', inscrutable(b1).afield); 119 Expect.equals('three', inscrutable(b1).afield);
120 Expect.equals('four', inscrutable(b1).afield); 120 Expect.equals('four', inscrutable(b2).afield);
121 121
122 Expect.equals('afun:three', inscrutable(b1).afun()); 122 Expect.equals('afun:three', inscrutable(b1).afun());
123 Expect.equals('afun:four', inscrutable(b2).afun()); 123 Expect.equals('afun:four', inscrutable(b2).afun());
124 } 124 }
125 125
126 main() { 126 main() {
127 setup(); 127 setup();
128 inscrutable = (x) => x; 128 inscrutable = (x) => x;
129 129
130 setNativeSubclassDispatchRecord(getBBPrototype(), findInterceptorForType(BB)); 130 setNativeSubclassDispatchRecord(getBBPrototype(), findInterceptorForType(BB));
131 131
132 testSuperOnNative(); 132 testSuperOnNative();
133 testSuperOnSubclassOfNative(); 133 testSuperOnSubclassOfNative();
134 } 134 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js_native/dart2js_native.status ('k') | dart/tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698