| 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("../../../lib/compiler/compiler.dart"); | 8 #import("../../../lib/compiler/compiler.dart"); |
| 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg'); | 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg'); |
| 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); | 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 '''; | 42 '''; |
| 43 | 43 |
| 44 const ioLib = r''' | 44 const ioLib = r''' |
| 45 #library('io'); | 45 #library('io'); |
| 46 class Platform { | 46 class Platform { |
| 47 static int operatingSystem; | 47 static int operatingSystem; |
| 48 } | 48 } |
| 49 '''; | 49 '''; |
| 50 | 50 |
| 51 const helperLib = r''' |
| 52 #library('_js_helper'); |
| 53 void assert(x); |
| 54 '''; |
| 55 |
| 51 testDart2Dart(String src, [void continuation(String s), bool minify = false, | 56 testDart2Dart(String src, [void continuation(String s), bool minify = false, |
| 52 bool cutDeclarationTypes = false]) { | 57 bool cutDeclarationTypes = false]) { |
| 53 // If continuation is not provided, check that source string remains the same. | 58 // If continuation is not provided, check that source string remains the same. |
| 54 if (continuation === null) { | 59 if (continuation === null) { |
| 55 continuation = (s) { Expect.equals(src, s); }; | 60 continuation = (s) { Expect.equals(src, s); }; |
| 56 } | 61 } |
| 57 testDart2DartWithLibrary(src, '', continuation, minify, cutDeclarationTypes); | 62 testDart2DartWithLibrary(src, '', continuation, minify, cutDeclarationTypes); |
| 58 } | 63 } |
| 59 | 64 |
| 60 /** | 65 /** |
| 61 * Library name is assumed to be 'mylib' in 'mylib.dart' file. | 66 * Library name is assumed to be 'mylib' in 'mylib.dart' file. |
| 62 */ | 67 */ |
| 63 testDart2DartWithLibrary( | 68 testDart2DartWithLibrary( |
| 64 String srcMain, String srcLibrary, | 69 String srcMain, String srcLibrary, |
| 65 [void continuation(String s), bool minify = false, | 70 [void continuation(String s), bool minify = false, |
| 66 bool cutDeclarationTypes = false]) { | 71 bool cutDeclarationTypes = false]) { |
| 67 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); | 72 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); |
| 68 | 73 |
| 69 final scriptUri = fileUri('script.dart'); | 74 final scriptUri = fileUri('script.dart'); |
| 70 final libUri = fileUri('mylib.dart'); | 75 final libUri = fileUri('mylib.dart'); |
| 71 | 76 |
| 72 provider(uri) { | 77 provider(uri) { |
| 73 if (uri == scriptUri) return new Future.immediate(srcMain); | 78 if (uri == scriptUri) return new Future.immediate(srcMain); |
| 74 if (uri.toString() == libUri.toString()) { | 79 if (uri.toString() == libUri.toString()) { |
| 75 return new Future.immediate(srcLibrary); | 80 return new Future.immediate(srcLibrary); |
| 76 } | 81 } |
| 77 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); | 82 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); |
| 78 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib); | 83 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib); |
| 84 if (uri.path.endsWith('/js_helper.dart')) { |
| 85 return new Future.immediate(helperLib); |
| 86 } |
| 79 return new Future.immediate(''); | 87 return new Future.immediate(''); |
| 80 } | 88 } |
| 81 | 89 |
| 82 handler(uri, begin, end, message, kind) { | 90 handler(uri, begin, end, message, kind) { |
| 83 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) { | 91 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) { |
| 84 Expect.fail('$uri: $begin-$end: $message [$kind]'); | 92 Expect.fail('$uri: $begin-$end: $message [$kind]'); |
| 85 } | 93 } |
| 86 } | 94 } |
| 87 | 95 |
| 88 final options = <String>['--output-type=dart']; | 96 final options = <String>['--output-type=dart']; |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 testDoubleMains(); | 856 testDoubleMains(); |
| 849 testInterfaceDefaultAnotherLib(); | 857 testInterfaceDefaultAnotherLib(); |
| 850 testStaticAccessIoLib(); | 858 testStaticAccessIoLib(); |
| 851 testLocalFunctionPlaceholder(); | 859 testLocalFunctionPlaceholder(); |
| 852 testMinification(); | 860 testMinification(); |
| 853 testClosureLocalsMinified(); | 861 testClosureLocalsMinified(); |
| 854 testParametersMinified(); | 862 testParametersMinified(); |
| 855 testTypeVariablesInDifferentLibraries(); | 863 testTypeVariablesInDifferentLibraries(); |
| 856 testDeclarationTypePlaceholders(); | 864 testDeclarationTypePlaceholders(); |
| 857 } | 865 } |
| OLD | NEW |