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

Side by Side Diff: tests/compiler/dart2js_native/fixup_get_tag_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 "dart:_js_helper"; 5 import "native_testing.dart";
6 import "package:expect/expect.dart";
7 6
8 // Test for dartExperimentalFixupGetTag. 7 // Test for dartExperimentalFixupGetTag.
9 8
10 @Native("A") 9 @Native("A")
11 class Foo { 10 class Foo {
12 // There is one native class with dispatch tag 'A'. 11 // There is one native class with dispatch tag 'A'.
13 token() native ; 12 token() native ;
14 } 13 }
15 14
16 void setup() native r""" 15 void setup() native r"""
(...skipping 10 matching lines...) Expand all
27 }; 26 };
28 27
29 function A(){ } 28 function A(){ }
30 A.prototype.token = function () { return 'isA'; } 29 A.prototype.token = function () { return 'isA'; }
31 30
32 function B(){ } 31 function B(){ }
33 B.prototype.token = function () { return 'isB'; } 32 B.prototype.token = function () { return 'isB'; }
34 33
35 makeA = function() { return new A; }; 34 makeA = function() { return new A; };
36 makeB = function() { return new B; }; 35 makeB = function() { return new B; };
36
37 self.nativeConstructor(A);
37 """; 38 """;
38 39
39 makeA() native ; 40 makeA() native ;
40 makeB() native ; 41 makeB() native ;
41 42
42 main() { 43 main() {
44 nativeTesting();
43 setup(); 45 setup();
44 46
45 var a = makeA(); 47 var a = makeA();
46 var b = makeB(); 48 var b = makeB();
47 49
48 Expect.equals('isA', a.token()); 50 Expect.equals('isA', a.token());
49 51
50 // This call succeeds because the fixed-up 'getTag' method returns Foo's 52 // This call succeeds because the fixed-up 'getTag' method returns Foo's
51 // dispatch tag, and B is a faithful polyfil for Foo/A. 53 // dispatch tag, and B is a faithful polyfil for Foo/A.
52 Expect.equals('isB', b.token()); 54 Expect.equals('isB', b.token());
53 55
54 Expect.isTrue(a is Foo); 56 Expect.isTrue(a is Foo);
55 Expect.isTrue(b is Foo); 57 Expect.isTrue(b is Foo);
56 } 58 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/field_type_test.dart ('k') | tests/compiler/dart2js_native/foreign_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698