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

Side by Side Diff: tests/compiler/dart2js_native/browser_compat_1_unpatched_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";
7 //import 'dart:_foreign_helper' show JS;
8 //import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord;
6 9
7 // Test for dartNativeDispatchHooksTransformer, getTag hook. 10 // Test for dartNativeDispatchHooksTransformer, getTag hook.
8 // Same as browser_compat_1_prepatched_test but with prepatching disabled. 11 // Same as browser_compat_1_prepatched_test but with prepatching disabled.
9 12
10 @Native("T1A") 13 @Native("T1A")
11 class T1A {} 14 class T1A {}
12 15
13 @Native("T1B") 16 @Native("T1B")
14 class T1B {} 17 class T1B {}
15 18
(...skipping 17 matching lines...) Expand all
33 36
34 // Make constructors visible on 'window' for prepatching. 37 // Make constructors visible on 'window' for prepatching.
35 if (typeof window == "undefined") window = {} 38 if (typeof window == "undefined") window = {}
36 window.T1A = T1A; 39 window.T1A = T1A;
37 window.T1CrazyB = T1CrazyB; 40 window.T1CrazyB = T1CrazyB;
38 41
39 makeT1A = function(){return new T1A;}; 42 makeT1A = function(){return new T1A;};
40 makeT1B = function(){return new T1CrazyB;}; 43 makeT1B = function(){return new T1CrazyB;};
41 makeT1C = function(){return new T1fakeA;}; 44 makeT1C = function(){return new T1fakeA;};
42 45
43 self.nativeConstructor(T1A);
44 self.nativeConstructor(T1CrazyB);
45 self.nativeConstructor(T1fakeA);
46
47 var getTagCount = 0; 46 var getTagCount = 0;
48 getTagCallCount = function() { return getTagCount; } 47 getTagCallCount = function() { return getTagCount; }
49 48
50 function transformer1(hooks) { 49 function transformer1(hooks) {
51 var getTag = hooks.getTag; 50 var getTag = hooks.getTag;
52 51
53 function getTagNew(obj) { 52 function getTagNew(obj) {
54 ++getTagCount; 53 ++getTagCount;
55 54
56 // If something looks like a different native type we can check in advance 55 // If something looks like a different native type we can check in advance
57 // of the default algorithm. 56 // of the default algorithm.
58 if (obj instanceof T1fakeA) return "T1C"; 57 if (obj instanceof T1fakeA) return "T1C";
59 58
60 var tag = getTag(obj); 59 var tag = getTag(obj);
61 60
62 // New constructor names can be mapped here. 61 // New constructor names can be mapped here.
63 if (tag == "T1CrazyB") return "T1B"; 62 if (tag == "T1CrazyB") return "T1B";
64 63
65 return tag; 64 return tag;
66 } 65 }
67 66
68 hooks.getTag = getTagNew; 67 hooks.getTag = getTagNew;
69 // Disable prepatching. 68 // Disable prepatching.
70 hooks.prototypeForTag = function() { return null; } 69 hooks.prototypeForTag = function() { return null; }
71 } 70 }
72 71
73 dartNativeDispatchHooksTransformer = [transformer1]; 72 dartNativeDispatchHooksTransformer = [transformer1];
74 '''; 73 ''';
75 74
75 var inscrutable;
76
76 main() { 77 main() {
77 nativeTesting();
78 setup(); 78 setup();
79 inscrutable = (x) => x;
79 80
80 var t1a = makeT1A(); 81 var t1a = makeT1A();
81 var t1b = makeT1B(); 82 var t1b = makeT1B();
82 var t1c = makeT1C(); 83 var t1c = makeT1C();
83 84
84 Expect.equals(true, t1a is T1A, '$t1a is T1A'); 85 Expect.equals(true, t1a is T1A, '$t1a is T1A');
85 Expect.equals(true, t1b is T1B, '$t1b is T1B'); 86 Expect.equals(true, t1b is T1B, '$t1b is T1B');
86 Expect.equals(true, t1c is T1C, '$t1c is T1C'); 87 Expect.equals(true, t1c is T1C, '$t1c is T1C');
87 88
88 Expect.equals(3, getTagCallCount()); 89 Expect.equals(3, getTagCallCount());
89 90
90 Expect.equals(true, confuse(t1a) is T1A, '$t1a is T1A'); 91 Expect.equals(true, inscrutable(t1a) is T1A, '$t1a is T1A');
91 Expect.equals(true, confuse(t1b) is T1B, '$t1b is T1B'); 92 Expect.equals(true, inscrutable(t1b) is T1B, '$t1b is T1B');
92 Expect.equals(true, confuse(t1c) is T1C, '$t1c is T1C'); 93 Expect.equals(true, inscrutable(t1c) is T1C, '$t1c is T1C');
93 94
94 Expect.equals(3, getTagCallCount()); 95 Expect.equals(3, getTagCallCount());
95 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698