| OLD | NEW |
| 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 'dart:uri'; | 5 import 'dart:uri'; |
| 6 import 'parser_helper.dart'; | 6 import 'parser_helper.dart'; |
| 7 import 'mock_compiler.dart'; | 7 import 'mock_compiler.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/compiler.dart'; | 8 import '../../../sdk/lib/_internal/compiler/compiler.dart'; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' as l
eg; | 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' as l
eg; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_bac
kend.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_bac
kend.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 const helperLib = r''' | 55 const helperLib = r''' |
| 56 library js_helper; | 56 library js_helper; |
| 57 class JSInvocationMirror {} | 57 class JSInvocationMirror {} |
| 58 '''; | 58 '''; |
| 59 | 59 |
| 60 const foreignLib = r''' | 60 const foreignLib = r''' |
| 61 var JS; | 61 var JS; |
| 62 '''; | 62 '''; |
| 63 | 63 |
| 64 const isolateHelperLib = r''' |
| 65 class _WorkerStub { |
| 66 } |
| 67 '''; |
| 68 |
| 64 testDart2Dart(String src, {void continuation(String s), bool minify: false, | 69 testDart2Dart(String src, {void continuation(String s), bool minify: false, |
| 65 bool stripTypes: false}) { | 70 bool stripTypes: false}) { |
| 66 // If continuation is not provided, check that source string remains the same. | 71 // If continuation is not provided, check that source string remains the same. |
| 67 if (continuation == null) { | 72 if (continuation == null) { |
| 68 continuation = (s) { Expect.equals(src, s); }; | 73 continuation = (s) { Expect.equals(src, s); }; |
| 69 } | 74 } |
| 70 testDart2DartWithLibrary(src, '', continuation: continuation, minify: minify, | 75 testDart2DartWithLibrary(src, '', continuation: continuation, minify: minify, |
| 71 stripTypes: stripTypes); | 76 stripTypes: stripTypes); |
| 72 } | 77 } |
| 73 | 78 |
| 74 /** | 79 /** |
| 75 * Library name is assumed to be 'mylib' in 'mylib.dart' file. | 80 * Library name is assumed to be 'mylib' in 'mylib.dart' file. |
| 76 */ | 81 */ |
| 77 testDart2DartWithLibrary( | 82 testDart2DartWithLibrary( |
| 78 String srcMain, String srcLibrary, | 83 String srcMain, String srcLibrary, |
| 79 {void continuation(String s), bool minify: false, | 84 {void continuation(String s), bool minify: false, |
| 80 bool stripTypes: false}) { | 85 bool stripTypes: false}) { |
| 81 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); | 86 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); |
| 82 | 87 |
| 83 final scriptUri = fileUri('script.dart'); | 88 final scriptUri = fileUri('script.dart'); |
| 84 final libUri = fileUri('mylib.dart'); | 89 final libUri = fileUri('mylib.dart'); |
| 85 | 90 |
| 86 provider(uri) { | 91 provider(uri) { |
| 87 if (uri == scriptUri) return new Future.immediate(srcMain); | 92 if (uri == scriptUri) return new Future.immediate(srcMain); |
| 88 if (uri.toString() == libUri.toString()) { | 93 if (uri.toString() == libUri.toString()) { |
| 89 return new Future.immediate(srcLibrary); | 94 return new Future.immediate(srcLibrary); |
| 90 } | 95 } |
| 91 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); | 96 if (uri.path.endsWith('/core.dart')) { |
| 92 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib); | 97 return new Future.immediate(coreLib); |
| 93 if (uri.path.endsWith('/js_helper.dart')) return new Future.immediate(helper
Lib); | 98 } else if (uri.path.endsWith('/io.dart')) { |
| 94 // TODO(smok): The file should change to html_dartium at some point. | 99 return new Future.immediate(ioLib); |
| 95 if (uri.path.endsWith('/html_dart2js.dart')) return new Future.immediate(htm
lLib); | 100 } else if (uri.path.endsWith('/js_helper.dart')) { |
| 96 if (uri.path.endsWith('/foreign_helper.dart')) return new Future.immediate(f
oreignLib); | 101 return new Future.immediate(helperLib); |
| 102 } else if (uri.path.endsWith('/html_dart2js.dart')) { |
| 103 // TODO(smok): The file should change to html_dartium at some point. |
| 104 return new Future.immediate(htmlLib); |
| 105 } else if (uri.path.endsWith('/foreign_helper.dart')) { |
| 106 return new Future.immediate(foreignLib); |
| 107 } else if (uri.path.endsWith('/isolate_helper.dart')) { |
| 108 return new Future.immediate(isolateHelperLib); |
| 109 } |
| 97 return new Future.immediate(''); | 110 return new Future.immediate(''); |
| 98 } | 111 } |
| 99 | 112 |
| 100 handler(uri, begin, end, message, kind) { | 113 handler(uri, begin, end, message, kind) { |
| 101 if (identical(kind, Diagnostic.ERROR) || identical(kind, Diagnostic.CRASH))
{ | 114 if (identical(kind, Diagnostic.ERROR) || identical(kind, Diagnostic.CRASH))
{ |
| 102 Expect.fail('$uri: $begin-$end: $message [$kind]'); | 115 Expect.fail('$uri: $begin-$end: $message [$kind]'); |
| 103 } | 116 } |
| 104 } | 117 } |
| 105 | 118 |
| 106 final options = <String>['--output-type=dart']; | 119 final options = <String>['--output-type=dart']; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 testStaticAccessIoLib(); | 751 testStaticAccessIoLib(); |
| 739 testLocalFunctionPlaceholder(); | 752 testLocalFunctionPlaceholder(); |
| 740 testMinification(); | 753 testMinification(); |
| 741 testClosureLocalsMinified(); | 754 testClosureLocalsMinified(); |
| 742 testParametersMinified(); | 755 testParametersMinified(); |
| 743 testDeclarationTypePlaceholders(); | 756 testDeclarationTypePlaceholders(); |
| 744 testPlatformLibraryMemberNamesAreFixed(); | 757 testPlatformLibraryMemberNamesAreFixed(); |
| 745 testConflictsWithCoreLib(); | 758 testConflictsWithCoreLib(); |
| 746 testUnresolvedNamedConstructor(); | 759 testUnresolvedNamedConstructor(); |
| 747 } | 760 } |
| OLD | NEW |