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

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

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 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
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 "native_testing.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; 6 import 'dart:_foreign_helper' show JS;
7 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' 8 import 'dart:_interceptors'
8 show findInterceptorForType, findConstructorForNativeSubclassType; 9 show findInterceptorForType, findConstructorForNativeSubclassType;
9 10
10 // 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
11 // 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.
12 13
13 @Native("N") 14 @Native("N")
14 class N { 15 class N {
15 var foo; 16 var foo;
16 N.init(); 17 N.init();
(...skipping 19 matching lines...) Expand all
36 @Creates('=Object') 37 @Creates('=Object')
37 getBPrototype() native ; 38 getBPrototype() native ;
38 39
39 void setup() native r""" 40 void setup() native r"""
40 function B() { this.foo = 111; } // N.foo 41 function B() { this.foo = 111; } // N.foo
41 makeB = function(){return new B;}; 42 makeB = function(){return new B;};
42 43
43 getBPrototype = function(){return B.prototype;}; 44 getBPrototype = function(){return B.prototype;};
44 """; 45 """;
45 46
47 var inscrutable;
48
46 main() { 49 main() {
47 nativeTesting();
48 setup(); 50 setup();
51 inscrutable = (x) => x;
49 52
50 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); 53 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B));
51 54
52 B b = makeB(); 55 B b = makeB();
53 56
54 var constructor = findConstructorForNativeSubclassType(B, 'init'); 57 var constructor = findConstructorForNativeSubclassType(B, 'init');
55 Expect.isNotNull(constructor); 58 Expect.isNotNull(constructor);
56 JS('', '#(#)', constructor, b); 59 JS('', '#(#)', constructor, b);
57 60
58 print(b); 61 print(b);
59 62
60 Expect.equals(333, confuse(b).Bfoo()); 63 Expect.equals(333, inscrutable(b).Bfoo());
61 Expect.equals(222, confuse(b).Afoo()); 64 Expect.equals(222, inscrutable(b).Afoo());
62 Expect.equals(111, confuse(b).Nfoo()); 65 Expect.equals(111, inscrutable(b).Nfoo());
63 66
64 Expect.equals(333, b.Bfoo()); 67 Expect.equals(333, b.Bfoo());
65 Expect.equals(222, b.Afoo()); 68 Expect.equals(222, b.Afoo());
66 Expect.equals(111, b.Nfoo()); 69 Expect.equals(111, b.Nfoo());
67 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698