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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; 6 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' show 7 import 'dart:_interceptors'
8 JSObject, // The interface, which may be re-exported by a 8 show
9 // js-interop library. 9 JSObject, // The interface, which may be re-exported by a
10 JavaScriptObject, // The interceptor abstract class. 10 // js-interop library.
11 PlainJavaScriptObject, // The interceptor concrete class. 11 JavaScriptObject, // The interceptor abstract class.
12 UnknownJavaScriptObject, // The interceptor concrete class. 12 PlainJavaScriptObject, // The interceptor concrete class.
13 Interceptor; 13 UnknownJavaScriptObject, // The interceptor concrete class.
14 Interceptor;
14 15
15 // 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
16 // 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
17 // can distinguish plain JavaScript objects from ones with a complex prototype. 18 // can distinguish plain JavaScript objects from ones with a complex prototype.
18 19
19 @Native('QQ') 20 @Native('QQ')
20 class Q {} 21 class Q {}
21 22
22 makeA() native; 23 makeA() native ;
23 makeB() native; 24 makeB() native ;
24 makeQ() native; 25 makeQ() native ;
25 26
26 void setup() native r""" 27 void setup() native r"""
27 makeA = function(){return {hello: 123};}; 28 makeA = function(){return {hello: 123};};
28 29
29 function BB(){} 30 function BB(){}
30 makeB = function(){return new BB();}; 31 makeB = function(){return new BB();};
31 32
32 function QQ(){} 33 function QQ(){}
33 makeQ = function(){return new QQ();}; 34 makeQ = function(){return new QQ();};
34 """; 35 """;
35 36
36 class Is<T> { 37 class Is<T> {
37 bool check(x) => x is T; 38 bool check(x) => x is T;
38 } 39 }
39 40
40 static_test() { 41 static_test() {
41 var x = makeA(); 42 var x = makeA();
42 Expect.isTrue(x is JSObject); 43 Expect.isTrue(x is JSObject);
43 Expect.isTrue(x is JavaScriptObject); 44 Expect.isTrue(x is JavaScriptObject);
44 Expect.isTrue(x is PlainJavaScriptObject); 45 Expect.isTrue(x is PlainJavaScriptObject);
45 Expect.isTrue(x is !UnknownJavaScriptObject); 46 Expect.isTrue(x is! UnknownJavaScriptObject);
46 Expect.equals(JSObject, x.runtimeType); 47 Expect.equals(JSObject, x.runtimeType);
47 48
48 x = makeB(); 49 x = makeB();
49 Expect.isTrue(x is JSObject); 50 Expect.isTrue(x is JSObject);
50 Expect.isTrue(x is JavaScriptObject); 51 Expect.isTrue(x is JavaScriptObject);
51 Expect.isTrue(x is !PlainJavaScriptObject); 52 Expect.isTrue(x is! PlainJavaScriptObject);
52 Expect.isTrue(x is UnknownJavaScriptObject); 53 Expect.isTrue(x is UnknownJavaScriptObject);
53 Expect.equals(JSObject, x.runtimeType); 54 Expect.equals(JSObject, x.runtimeType);
54 55
55 x = makeQ(); 56 x = makeQ();
56 Expect.isFalse(x is JSObject); 57 Expect.isFalse(x is JSObject);
57 Expect.isFalse(x is JavaScriptObject); 58 Expect.isFalse(x is JavaScriptObject);
58 Expect.isFalse(x is PlainJavaScriptObject); 59 Expect.isFalse(x is PlainJavaScriptObject);
59 Expect.isFalse(x is UnknownJavaScriptObject); 60 Expect.isFalse(x is UnknownJavaScriptObject);
60 Expect.isFalse(x.runtimeType == JSObject); 61 Expect.isFalse(x.runtimeType == JSObject);
61 Expect.isTrue(x is Q); 62 Expect.isTrue(x is Q);
(...skipping 28 matching lines...) Expand all
90 Expect.isTrue(isQ(x)); 91 Expect.isTrue(isQ(x));
91 Expect.isFalse(x.runtimeType == JSObject); 92 Expect.isFalse(x.runtimeType == JSObject);
92 } 93 }
93 94
94 main() { 95 main() {
95 setup(); 96 setup();
96 97
97 dynamic_test(); 98 dynamic_test();
98 static_test(); 99 static_test();
99 } 100 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/js_constant_test.dart ('k') | tests/compiler/dart2js_native/native_call_arity1_frog_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698