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

Side by Side Diff: tests/compiler/dart2js_native/native_field_rename_2_frog_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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // A native method prevents other members from having that name, including 5 // A native method prevents other members from having that name, including
6 // fields. However, native fields keep their name. The implication: a getter 6 // fields. However, native fields keep their name. The implication: a getter
7 // for the field must be based on the field's name, not the field's jsname. 7 // for the field must be based on the field's name, not the field's jsname.
8 8
9 import 'native_testing.dart'; 9 import "package:expect/expect.dart";
10 import 'dart:_js_helper' show Native, JSName;
10 11
11 abstract class I { 12 abstract class I {
12 int key; 13 int key;
13 } 14 }
14 15
15 @Native("A") 16 @Native("A")
16 class A implements I { 17 class A implements I {
17 int key; // jsname is 'key' 18 int key; // jsname is 'key'
18 int getKey() => key; 19 int getKey() => key;
19 } 20 }
(...skipping 19 matching lines...) Expand all
39 void setup() native """ 40 void setup() native """
40 // This code is all inside 'setup' and so not accesible from the global scope. 41 // This code is all inside 'setup' and so not accesible from the global scope.
41 function A(){ this.key = 111; } 42 function A(){ this.key = 111; }
42 A.prototype.getKey = function(){return this.key;}; 43 A.prototype.getKey = function(){return this.key;};
43 44
44 function X(){} 45 function X(){}
45 X.prototype.key = function(){return 666;}; 46 X.prototype.key = function(){return 666;};
46 47
47 makeA = function(){return new A}; 48 makeA = function(){return new A};
48 makeX = function(){return new X}; 49 makeX = function(){return new X};
49
50 self.nativeConstructor(A);
51 self.nativeConstructor(X);
52 """; 50 """;
53 51
54 testDynamic() { 52 testDynamic() {
55 var a = confuse(makeA()); 53 var things = [makeA(), new B(), makeX()];
56 var b = confuse(new B()); 54 var a = things[0];
57 var x = confuse(makeX()); 55 var b = things[1];
56 var x = things[2];
58 57
59 Expect.equals(111, a.key); 58 Expect.equals(111, a.key);
60 Expect.equals(222, b.key); 59 Expect.equals(222, b.key);
61 Expect.equals(111, a.getKey()); 60 Expect.equals(111, a.getKey());
62 Expect.equals(222, b.getKey()); 61 Expect.equals(222, b.getKey());
63 62
64 Expect.equals(666, x.native_key_method()); 63 Expect.equals(666, x.native_key_method());
65 Expect.equals(666, x.key()); 64 Expect.equals(666, x.key());
66 var fn = x.key; 65 var fn = x.key;
67 Expect.equals(666, fn()); 66 Expect.equals(666, fn());
(...skipping 17 matching lines...) Expand all
85 X x = makeX(); 84 X x = makeX();
86 85
87 Expect.equals(666, x.native_key_method()); 86 Expect.equals(666, x.native_key_method());
88 Expect.equals(111, a.key); 87 Expect.equals(111, a.key);
89 Expect.equals(222, b.key); 88 Expect.equals(222, b.key);
90 Expect.equals(111, a.getKey()); 89 Expect.equals(111, a.getKey());
91 Expect.equals(222, b.getKey()); 90 Expect.equals(222, b.getKey());
92 } 91 }
93 92
94 main() { 93 main() {
95 nativeTesting();
96 setup(); 94 setup();
97 95
98 testTyped(); 96 testTyped();
99 testPartial(); 97 testPartial();
100 testDynamic(); 98 testDynamic();
101 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698