| OLD | NEW |
| 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 // Test that dart2js produces the expected static type warnings for type | 5 // Test that dart2js produces the expected static type warnings for type |
| 6 // promotion langauge tests. This ensures that the analyzer and dart2js agrees | 6 // promotion langauge tests. This ensures that the analyzer and dart2js agrees |
| 7 // on these tests. | 7 // on these tests. |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| 11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 12 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
| 13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; | 13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| 14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; | 14 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; |
| 15 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; | 15 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
| 16 import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart'
; | 16 import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart'
; |
| 17 import 'dart:convert'; |
| 17 | 18 |
| 18 const List<String> TESTS = const [ | 19 const List<String> TESTS = const [ |
| 19 'language/type_promotion_assign_test.dart', | 20 'language/type_promotion_assign_test.dart', |
| 20 'language/type_promotion_closure_test.dart', | 21 'language/type_promotion_closure_test.dart', |
| 21 'language/type_promotion_functions_test.dart', | 22 'language/type_promotion_functions_test.dart', |
| 22 'language/type_promotion_local_test.dart', | 23 'language/type_promotion_local_test.dart', |
| 23 'language/type_promotion_logical_and_test.dart', | 24 'language/type_promotion_logical_and_test.dart', |
| 24 'language/type_promotion_more_specific_test.dart', | 25 'language/type_promotion_more_specific_test.dart', |
| 25 'language/type_promotion_multiple_test.dart', | 26 'language/type_promotion_multiple_test.dart', |
| 26 'language/type_promotion_parameter_test.dart', | 27 'language/type_promotion_parameter_test.dart', |
| 27 ]; | 28 ]; |
| 28 | 29 |
| 29 void main() { | 30 void main() { |
| 30 bool isWindows = (Platform.operatingSystem == 'windows'); | 31 bool isWindows = (Platform.operatingSystem == 'windows'); |
| 31 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 32 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); |
| 32 bool warningsMismatch = false; | 33 bool warningsMismatch = false; |
| 33 Future.forEach(TESTS, (String test) { | 34 Future.forEach(TESTS, (String test) { |
| 34 Uri uri = script.resolve('../../$test'); | 35 Uri uri = script.resolve('../../$test'); |
| 35 String source = readAll(uriPathToNative(uri.path)); | 36 String source = UTF8.decode(readAll(uriPathToNative(uri.path))); |
| 36 SourceFile file = new SourceFile( | 37 SourceFile file = new StringSourceFile( |
| 37 relativize(currentDirectory, uri, isWindows), source); | 38 relativize(currentDirectory, uri, isWindows), source); |
| 38 Map<int,String> expectedWarnings = {}; | 39 Map<int,String> expectedWarnings = {}; |
| 39 int lineNo = 0; | 40 int lineNo = 0; |
| 40 for (String line in source.split('\n')) { | 41 for (String line in source.split('\n')) { |
| 41 if (line.contains('///') && line.contains('static type warning')) { | 42 if (line.contains('///') && line.contains('static type warning')) { |
| 42 expectedWarnings[lineNo] = line; | 43 expectedWarnings[lineNo] = line; |
| 43 } | 44 } |
| 44 lineNo++; | 45 lineNo++; |
| 45 } | 46 } |
| 46 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); | 47 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 String line = expectedWarnings[lineNo]; | 69 String line = expectedWarnings[lineNo]; |
| 69 print('$uri [${lineNo+1}]: Missing static type warning.'); | 70 print('$uri [${lineNo+1}]: Missing static type warning.'); |
| 70 print(line); | 71 print(line); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 }); | 74 }); |
| 74 }).then((_) { | 75 }).then((_) { |
| 75 Expect.isFalse(warningsMismatch); | 76 Expect.isFalse(warningsMismatch); |
| 76 }); | 77 }); |
| 77 } | 78 } |
| OLD | NEW |