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

Side by Side Diff: tests/compiler/dart2js_native/native_mixin_field_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 "dart:_js_helper";
6 import "package:expect/expect.dart";
6 7
7 // Test that native classes can use ordinary Dart classes with fields 8 // Test that native classes can use ordinary Dart classes with fields
8 // as mixins. 9 // as mixins.
9 10
10 @Native("A") 11 @Native("A")
11 class A { 12 class A {
12 var foo; 13 var foo;
13 } 14 }
14 15
15 @Native("B") 16 @Native("B")
(...skipping 11 matching lines...) Expand all
27 } 28 }
28 29
29 A makeA() native ; 30 A makeA() native ;
30 B makeB() native ; 31 B makeB() native ;
31 32
32 void setup() native """ 33 void setup() native """
33 function A() {this.foo='A-foo';} 34 function A() {this.foo='A-foo';}
34 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';} 35 function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
35 makeA = function(){return new A;}; 36 makeA = function(){return new A;};
36 makeB = function(){return new B;}; 37 makeB = function(){return new B;};
37
38 self.nativeConstructor(A);
39 self.nativeConstructor(B);
40 """; 38 """;
41 39
42
43 main() { 40 main() {
44 nativeTesting();
45 setup(); 41 setup();
46 A a = makeA(); 42 A a = makeA();
47 Expect.equals("A-foo", a.foo); 43 Expect.equals("A-foo", a.foo);
48 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError); 44 Expect.throws(() => a.bar, (e) => e is NoSuchMethodError);
49 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError); 45 Expect.throws(() => a.baz, (e) => e is NoSuchMethodError);
50 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError); 46 Expect.throws(() => a.buz, (e) => e is NoSuchMethodError);
51 47
52 B b = makeB(); 48 B b = makeB();
53 Expect.equals("A-foo", b.foo); 49 Expect.equals("A-foo", b.foo);
54 Expect.equals("B-bar", b.bar); 50 Expect.equals("B-bar", b.bar);
55 // Expect.equals("M1-baz", b.baz); // not true, see M1. 51 // Expect.equals("M1-baz", b.baz); // not true, see M1.
56 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz. 52 Expect.isNull(b.baz); // native b.baz is not the same as dart b.baz.
57 Expect.isNull(b.buz); 53 Expect.isNull(b.buz);
58 54
59 M1 m1 = new M1(); 55 M1 m1 = new M1();
60 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError); 56 Expect.throws(() => m1.foo, (e) => e is NoSuchMethodError);
61 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError); 57 Expect.throws(() => m1.bar, (e) => e is NoSuchMethodError);
62 Expect.isNull(m1.baz); 58 Expect.isNull(m1.baz);
63 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError); 59 Expect.throws(() => m1.buz, (e) => e is NoSuchMethodError);
64 60
65 M2 m2 = new M2(); 61 M2 m2 = new M2();
66 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError); 62 Expect.throws(() => m2.foo, (e) => e is NoSuchMethodError);
67 Expect.isNull(m2.bar); 63 Expect.isNull(m2.bar);
68 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError); 64 Expect.throws(() => m2.baz, (e) => e is NoSuchMethodError);
69 Expect.isNull(m2.buz); 65 Expect.isNull(m2.buz);
70 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698