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

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

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 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
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 "native_testing.dart";
6 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; 6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' show findInterceptorForType; 7 import 'dart:_interceptors' show findInterceptorForType;
8 8
9 // Test that subclasses of native classes can be defined by setting the dispatch 9 // Test that subclasses of native classes can be defined by setting the dispatch
10 // record. 10 // record.
11 11
12 @Native("A") 12 @Native("A")
13 class A { 13 class A {
14 foo(x) => '$x,${this.oof()}'; 14 foo(x) => '$x,${this.oof()}';
15 oof() => 'A'; 15 oof() => 'A';
16 } 16 }
(...skipping 19 matching lines...) Expand all
36 makeA = function(){return new A;}; 36 makeA = function(){return new A;};
37 makeB1 = function(){return new B;}; 37 makeB1 = function(){return new B;};
38 makeB2 = function(){return new B;}; 38 makeB2 = function(){return new B;};
39 makeC = function(){return new C;}; 39 makeC = function(){return new C;};
40 40
41 getBPrototype = function(){return B.prototype;}; 41 getBPrototype = function(){return B.prototype;};
42 getCPrototype = function(){return C.prototype;}; 42 getCPrototype = function(){return C.prototype;};
43 """; 43 """;
44 44
45 main() { 45 main() {
46 nativeTesting();
46 setup(); 47 setup();
47 48
48 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); 49 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B));
49 setNativeSubclassDispatchRecord(getCPrototype(), findInterceptorForType(B)); 50 setNativeSubclassDispatchRecord(getCPrototype(), findInterceptorForType(B));
50 51
51 B b1 = makeB1(); 52 B b1 = makeB1();
52 Expect.equals('1,B', b1.foo(1)); 53 Expect.equals('1,B', b1.foo(1));
53 54
54 B b2 = makeB2(); 55 B b2 = makeB2();
55 Expect.equals('2,B', b2.foo(2)); 56 Expect.equals('2,B', b2.foo(2));
56 57
57 B b3 = makeC(); 58 B b3 = makeC();
58 Expect.equals('3,B', b3.foo(3)); 59 Expect.equals('3,B', b3.foo(3));
59 } 60 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/static_methods_test.dart ('k') | tests/compiler/dart2js_native/subclassing_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698