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

Side by Side Diff: tests/compiler/dart2js_native/jsobject_test.dart

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments Created 3 years, 4 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 'native_testing.dart';
6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; 6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' 7 import 'dart:_interceptors'
8 show 8 show
9 JSObject, // The interface, which may be re-exported by a 9 JSObject, // The interface, which may be re-exported by a
10 // js-interop library. 10 // js-interop library.
11 JavaScriptObject, // The interceptor abstract class. 11 JavaScriptObject, // The interceptor abstract class.
12 PlainJavaScriptObject, // The interceptor concrete class. 12 PlainJavaScriptObject, // The interceptor concrete class.
13 UnknownJavaScriptObject, // The interceptor concrete class. 13 UnknownJavaScriptObject, // The interceptor concrete class.
14 Interceptor; 14 Interceptor;
15 15
16 // Test for JavaScript objects from outside the Dart program. Although we only 16 // Test for JavaScript objects from outside the Dart program. Although we only
17 // export the interface [JSObject] to user level code, this test makes sure we 17 // export the interface [JSObject] to user level code, this test makes sure we
18 // can distinguish plain JavaScript objects from ones with a complex prototype. 18 // can distinguish plain JavaScript objects from ones with a complex prototype.
19 19
20 @Native('QQ') 20 @Native('QQ')
21 class Q {} 21 class Q {}
22 22
23 makeA() native; 23 makeA() native;
24 makeB() native; 24 makeB() native;
25 makeQ() native; 25 makeQ() native;
26 26
27 void setup() native r""" 27 void setup() {
28 JS('', r"""
29 (function(){
28 makeA = function(){return {hello: 123};}; 30 makeA = function(){return {hello: 123};};
29 31
30 function BB(){} 32 function BB(){}
31 makeB = function(){return new BB();}; 33 makeB = function(){return new BB();};
32 34
33 function QQ(){} 35 function QQ(){}
34 makeQ = function(){return new QQ();}; 36 makeQ = function(){return new QQ();};
35 37
36 self.nativeConstructor(QQ); 38 self.nativeConstructor(QQ);
37 """; 39 })()""");
40 }
38 41
39 class Is<T> { 42 class Is<T> {
40 bool check(x) => x is T; 43 bool check(x) => x is T;
41 } 44 }
42 45
43 static_test() { 46 static_test() {
44 var x = makeA(); 47 var x = makeA();
45 Expect.isTrue(x is JSObject); 48 Expect.isTrue(x is JSObject);
46 Expect.isTrue(x is JavaScriptObject); 49 Expect.isTrue(x is JavaScriptObject);
47 Expect.isTrue(x is PlainJavaScriptObject); 50 Expect.isTrue(x is PlainJavaScriptObject);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Expect.isFalse(x.runtimeType == JSObject); 97 Expect.isFalse(x.runtimeType == JSObject);
95 } 98 }
96 99
97 main() { 100 main() {
98 nativeTesting(); 101 nativeTesting();
99 setup(); 102 setup();
100 103
101 dynamic_test(); 104 dynamic_test();
102 static_test(); 105 static_test();
103 } 106 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/issue9182_test.dart ('k') | tests/compiler/dart2js_native/native_class_fields_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698