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

Side by Side Diff: tests/compiler/dart2js/dart_backend_test.dart

Issue 383413003: Add @Native(...) annotation for native class names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/lib/annotations.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'mock_compiler.dart'; 8 import 'mock_compiler.dart';
9 import 'mock_libraries.dart';
9 import 'package:compiler/compiler.dart'; 10 import 'package:compiler/compiler.dart';
10 import 'package:compiler/implementation/dart2jslib.dart' as leg; 11 import 'package:compiler/implementation/dart2jslib.dart' as leg;
11 import 'package:compiler/implementation/dart_backend/dart_backend.dart'; 12 import 'package:compiler/implementation/dart_backend/dart_backend.dart';
12 import 'package:compiler/implementation/elements/elements.dart'; 13 import 'package:compiler/implementation/elements/elements.dart';
13 import 'package:compiler/implementation/tree/tree.dart'; 14 import 'package:compiler/implementation/tree/tree.dart';
14 15
15 const coreLib = r'''
16 library corelib;
17 class Object {
18 Object();
19 }
20 class bool {}
21 class num {}
22 class int extends num {}
23 class double extends num {}
24 abstract class String {}
25 class Function {}
26 class List<T> {}
27 class Map<K,V> {}
28 class BoundClosure {}
29 class Closure {}
30 class Dynamic_ {}
31 class Null {}
32 class TypeError {}
33 class Type {}
34 class StackTrace {}
35 class LinkedHashMap {
36 factory LinkedHashMap._empty() => null;
37 factory LinkedHashMap._literal(elements) => null;
38 }
39 class Math {
40 static double parseDouble(String s) => 1.0;
41 }
42 print(x) {}
43 identical(a, b) => true;
44 const proxy = 0;
45 ''';
46
47 const corePatch = r'''
48 import 'dart:_js_helper';
49 import 'dart:_interceptors';
50 import 'dart:_isolate_helper';
51 import 'dart:_foreign_helper';
52 ''';
53
54 const ioLib = r''' 16 const ioLib = r'''
55 library io; 17 library io;
56 class Platform { 18 class Platform {
57 static int operatingSystem; 19 static int operatingSystem;
58 } 20 }
59 '''; 21 ''';
60 22
61 const htmlLib = r''' 23 const htmlLib = r'''
62 library html; 24 library html;
63 Window __window; 25 Window __window;
64 Window get window => __window; 26 Window get window => __window;
65 abstract class Window { 27 abstract class Window {
66 Navigator get navigator; 28 Navigator get navigator;
67 } 29 }
68 abstract class Navigator { 30 abstract class Navigator {
69 String get userAgent; 31 String get userAgent;
70 } 32 }
71 '''; 33 ''';
72 34
73 const helperLib = r'''
74 library js_helper;
75 class JSInvocationMirror {}
76 assertHelper(a) {}
77 class Closure {}
78 class BoundClosure {}
79 const patch = 0;
80 ''';
81
82 const foreignLib = r'''
83 var JS;
84 ''';
85
86 const isolateHelperLib = r'''
87 class _WorkerStub {
88 }
89 ''';
90
91 testDart2Dart(String src, {void continuation(String s), bool minify: false, 35 testDart2Dart(String src, {void continuation(String s), bool minify: false,
92 bool stripTypes: false}) { 36 bool stripTypes: false}) {
93 // If continuation is not provided, check that source string remains the same. 37 // If continuation is not provided, check that source string remains the same.
94 if (continuation == null) { 38 if (continuation == null) {
95 continuation = (s) { Expect.equals(src, s); }; 39 continuation = (s) { Expect.equals(src, s); };
96 } 40 }
97 testDart2DartWithLibrary(src, '', continuation: continuation, minify: minify, 41 testDart2DartWithLibrary(src, '', continuation: continuation, minify: minify,
98 stripTypes: stripTypes); 42 stripTypes: stripTypes);
99 } 43 }
100 44
101 /** 45 /**
102 * Library name is assumed to be 'mylib' in 'mylib.dart' file. 46 * Library name is assumed to be 'mylib' in 'mylib.dart' file.
103 */ 47 */
104 testDart2DartWithLibrary( 48 testDart2DartWithLibrary(
105 String srcMain, String srcLibrary, 49 String srcMain, String srcLibrary,
106 {void continuation(String s), bool minify: false, 50 {void continuation(String s), bool minify: false,
107 bool stripTypes: false}) { 51 bool stripTypes: false}) {
108 fileUri(path) => new Uri(scheme: 'file', path: path); 52 fileUri(path) => new Uri(scheme: 'file', path: path);
109 53
110 final scriptUri = fileUri('script.dart'); 54 final scriptUri = fileUri('script.dart');
111 final libUri = fileUri('mylib.dart'); 55 final libUri = fileUri('mylib.dart');
112 56
113 provider(uri) { 57 provider(uri) {
114 if (uri == scriptUri) return new Future.value(srcMain); 58 if (uri == scriptUri) return new Future.value(srcMain);
115 if (uri.toString() == libUri.toString()) { 59 if (uri.toString() == libUri.toString()) {
116 return new Future.value(srcLibrary); 60 return new Future.value(srcLibrary);
117 } 61 }
118 if (uri.path.endsWith('/core.dart')) { 62 if (uri.path.endsWith('/core.dart')) {
119 return new Future.value(coreLib); 63 return new Future.value(buildLibrarySource(DEFAULT_CORE_LIBRARY));
120 } else if (uri.path.endsWith('/core_patch.dart')) { 64 } else if (uri.path.endsWith('/core_patch.dart')) {
121 return new Future.value(corePatch); 65 return new Future.value(DEFAULT_PATCH_CORE_SOURCE);
122 } else if (uri.path.endsWith('/io.dart')) { 66 } else if (uri.path.endsWith('/io.dart')) {
123 return new Future.value(ioLib); 67 return new Future.value(ioLib);
124 } else if (uri.path.endsWith('/js_helper.dart')) { 68 } else if (uri.path.endsWith('/js_helper.dart')) {
125 return new Future.value(helperLib); 69 return new Future.value(buildLibrarySource(DEFAULT_JS_HELPER_LIBRARY));
126 } else if (uri.path.endsWith('/html_dart2js.dart')) { 70 } else if (uri.path.endsWith('/html_dart2js.dart')) {
127 // TODO(smok): The file should change to html_dartium at some point. 71 // TODO(smok): The file should change to html_dartium at some point.
128 return new Future.value(htmlLib); 72 return new Future.value(htmlLib);
129 } else if (uri.path.endsWith('/foreign_helper.dart')) { 73 } else if (uri.path.endsWith('/foreign_helper.dart')) {
130 return new Future.value(foreignLib); 74 return new Future.value(
75 buildLibrarySource(DEFAULT_FOREIGN_HELPER_LIBRARY));
131 } else if (uri.path.endsWith('/isolate_helper.dart')) { 76 } else if (uri.path.endsWith('/isolate_helper.dart')) {
132 return new Future.value(isolateHelperLib); 77 return new Future.value(
78 buildLibrarySource(DEFAULT_ISOLATE_HELPER_LIBRARY));
133 } 79 }
134 return new Future.value(''); 80 return new Future.value('');
135 } 81 }
136 82
137 handler(uri, begin, end, message, kind) { 83 handler(uri, begin, end, message, kind) {
138 if (identical(kind, Diagnostic.ERROR) || identical(kind, Diagnostic.CRASH)) { 84 if (identical(kind, Diagnostic.ERROR) || identical(kind, Diagnostic.CRASH)) {
139 Expect.fail('$uri: $begin-$end: $message [$kind]'); 85 Expect.fail('$uri: $begin-$end: $message [$kind]');
140 } 86 }
141 } 87 }
142 88
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 new B<Object>(); 529 new B<Object>();
584 } 530 }
585 class A<T extends Object> {} 531 class A<T extends Object> {}
586 class B<T extends Object> extends A<T> {} 532 class B<T extends Object> extends A<T> {}
587 '''); 533 ''');
588 } 534 }
589 535
590 testStaticInvocation() { 536 testStaticInvocation() {
591 testDart2Dart(''' 537 testDart2Dart('''
592 main() { 538 main() {
593 var x = Math.parseDouble("1"); 539 var x = double.parseDouble("1");
594 } 540 }
595 '''); 541 ''');
596 } 542 }
597 543
598 testLibraryGetSet() { 544 testLibraryGetSet() {
599 var librarySrc = ''' 545 var librarySrc = '''
600 library mylib; 546 library mylib;
601 547
602 get topgetset => 5; 548 get topgetset => 5;
603 set topgetset(arg) {} 549 set topgetset(arg) {}
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 testStaticAccessIoLib(); 934 testStaticAccessIoLib();
989 testLocalFunctionPlaceholder(); 935 testLocalFunctionPlaceholder();
990 testMinification(); 936 testMinification();
991 testClosureLocalsMinified(); 937 testClosureLocalsMinified();
992 testParametersMinified(); 938 testParametersMinified();
993 testDeclarationTypePlaceholders(); 939 testDeclarationTypePlaceholders();
994 testPlatformLibraryMemberNamesAreFixed(); 940 testPlatformLibraryMemberNamesAreFixed();
995 testConflictsWithCoreLib(); 941 testConflictsWithCoreLib();
996 testUnresolvedNamedConstructor(); 942 testUnresolvedNamedConstructor();
997 } 943 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/annotations.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698