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

Side by Side Diff: tests/compiler/dart2js_native/core_type_check_native_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) 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 "native_testing.dart"; 5 import "dart:_js_helper";
6 import "package:expect/expect.dart";
7
8 var inscrutable = (int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
6 9
7 @Native("A") 10 @Native("A")
8 class A {} 11 class A {}
9 12
10 @Native("B") 13 @Native("B")
11 class B implements Comparable {} 14 class B implements Comparable {}
12 15
13 @Native("C") 16 @Native("C")
14 class C implements Pattern {} 17 class C implements Pattern {}
15 18
16 @Native("D") 19 @Native("D")
17 class D implements Pattern, Comparable {} 20 class D implements Pattern, Comparable {}
18 21
19 makeA() native ; 22 makeA() native ;
20 makeB() native ; 23 makeB() native ;
21 makeC() native ; 24 makeC() native ;
22 makeD() native ; 25 makeD() native ;
23 26
24 void setup() native """ 27 void setup() native """
25 function A() {}; 28 function A() {};
26 makeA = function() { return new A; } 29 makeA = function() { return new A; }
27 function B() {}; 30 function B() {};
28 makeB = function() { return new B; } 31 makeB = function() { return new B; }
29 function C() {}; 32 function C() {};
30 makeC = function() { return new C; } 33 makeC = function() { return new C; }
31 function D() {}; 34 function D() {};
32 makeD = function() { return new D; } 35 makeD = function() { return new D; }
33
34 self.nativeConstructor(A);
35 self.nativeConstructor(B);
36 self.nativeConstructor(C);
37 self.nativeConstructor(D);
38 """; 36 """;
39 37
40 checkTest(value, expectComparable, expectPattern) { 38 checkTest(value, expectComparable, expectPattern) {
41 Expect.equals(expectComparable, value is Comparable); 39 Expect.equals(expectComparable, value is Comparable);
42 Expect.equals(expectPattern, value is Pattern); 40 Expect.equals(expectPattern, value is Pattern);
43 } 41 }
44 42
45 checkCast(value, expectComparable, expectPattern) { 43 checkCast(value, expectComparable, expectPattern) {
46 if (expectComparable) { 44 if (expectComparable) {
47 Expect.identical(value, value as Comparable); 45 Expect.identical(value, value as Comparable);
(...skipping 12 matching lines...) Expand all
60 [], 58 [],
61 4, 59 4,
62 4.2, 60 4.2,
63 'foo', 61 'foo',
64 new Object(), 62 new Object(),
65 makeA(), 63 makeA(),
66 makeB(), 64 makeB(),
67 makeC(), 65 makeC(),
68 makeD() 66 makeD()
69 ]; 67 ];
70 value(i) => confuse(things[i]); 68 value(i) => things[inscrutable(i)];
71 69
72 check(value(0), false, false); // List 70 check(value(0), false, false); // List
73 check(value(1), true, false); // int 71 check(value(1), true, false); // int
74 check(value(2), true, false); // num 72 check(value(2), true, false); // num
75 check(value(3), true, true); // String 73 check(value(3), true, true); // String
76 check(value(4), false, false); // Object 74 check(value(4), false, false); // Object
77 check(value(5), false, false); // A 75 check(value(5), false, false); // A
78 check(value(6), true, false); // B 76 check(value(6), true, false); // B
79 check(value(7), false, true); // C 77 check(value(7), false, true); // C
80 check(value(8), true, true); // D 78 check(value(8), true, true); // D
81 } 79 }
82 80
83 main() { 81 main() {
84 nativeTesting();
85 setup(); 82 setup();
86 83
87 checkAll(checkTest); 84 checkAll(checkTest);
88 checkAll(checkCast); 85 checkAll(checkCast);
89 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698