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

Side by Side Diff: tests/compiler/dart2js_native/native_use_native_name_in_table_frog_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 that we put native names and not Dart names into the dynamic 7 // Test that we put native names and not Dart names into the dynamic
9 // dispatch table. 8 // dispatch table.
10 9
11 @Native("NativeA") 10 @Native("NativeA")
12 class A { 11 class A {
13 foo() native ; 12 foo() native ;
14 } 13 }
15 14
16 @Native("NativeB") 15 @Native("NativeB")
(...skipping 13 matching lines...) Expand all
30 child.prototype.constructor = child; 29 child.prototype.constructor = child;
31 } 30 }
32 } 31 }
33 function NativeA() {} 32 function NativeA() {}
34 function NativeB() {} 33 function NativeB() {}
35 inherits(NativeB, NativeA); 34 inherits(NativeB, NativeA);
36 NativeA.prototype.foo = function() { return 42; }; 35 NativeA.prototype.foo = function() { return 42; };
37 36
38 makeA = function(){return new NativeA;}; 37 makeA = function(){return new NativeA;};
39 makeB = function(){return new NativeB;}; 38 makeB = function(){return new NativeB;};
39
40 self.nativeConstructor(NativeA);
41 self.nativeConstructor(NativeB);
40 """; 42 """;
41 43
42 main() { 44 main() {
45 nativeTesting();
43 setup(); 46 setup();
44 47
45 var a = makeA(); 48 Expect.equals(42, makeA().foo());
46 Expect.equals(42, a.foo()); 49 Expect.equals(42, confuse(makeA()).foo());
47 A aa = a;
48 Expect.equals(42, aa.foo());
49 50
50 var b = makeB(); 51 Expect.equals(42, makeB().foo());
51 Expect.equals(42, b.foo()); 52 Expect.equals(42, confuse(makeB()).foo());
52 B bb = b;
53 Expect.equals(42, bb.foo());
54 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698