| 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 // Test that deprecated language features are diagnosed correctly. | 5 // Test that deprecated language features are diagnosed correctly. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:uri'; | |
| 10 | 9 |
| 11 import '../../../sdk/lib/_internal/compiler/compiler.dart'; | 10 import '../../../sdk/lib/_internal/compiler/compiler.dart'; |
| 12 import '../../utils/dummy_compiler_test.dart' as dummy; | 11 import '../../utils/dummy_compiler_test.dart' as dummy; |
| 13 | 12 |
| 14 main() { | 13 main() { |
| 15 StringBuffer messages = new StringBuffer(); | 14 StringBuffer messages = new StringBuffer(); |
| 16 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { | 15 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { |
| 17 if (kind == Diagnostic.VERBOSE_INFO) return; | 16 if (kind == Diagnostic.VERBOSE_INFO) return; |
| 18 if (identical(kind.name, 'source map')) return; | 17 if (identical(kind.name, 'source map')) return; |
| 19 if (uri == null) { | 18 if (uri == null) { |
| 20 messages.write('$kind: $message\n'); | 19 messages.write('$kind: $message\n'); |
| 21 } else { | 20 } else { |
| 22 Expect.equals('main:${uri.path}', '$uri'); | 21 Expect.equals('main:${uri.path}', '$uri'); |
| 23 String source = TEST_SOURCE[uri.path]; | 22 String source = TEST_SOURCE[uri.path]; |
| 24 Expect.isNotNull(source); | 23 Expect.isNotNull(source); |
| 25 messages.write('$begin<${source.substring(begin, end)}>:${uri.path}:' | 24 messages.write('$begin<${source.substring(begin, end)}>:${uri.path}:' |
| 26 '$kind: $message\n'); | 25 '$kind: $message\n'); |
| 27 } | 26 } |
| 28 } | 27 } |
| 29 | 28 |
| 30 Future<String> provider(Uri uri) { | 29 Future<String> provider(Uri uri) { |
| 31 if (uri.scheme != "main") return dummy.provider(uri); | 30 if (uri.scheme != "main") return dummy.provider(uri); |
| 32 String source = TEST_SOURCE[uri.path]; | 31 String source = TEST_SOURCE[uri.path]; |
| 33 Expect.isNotNull(source); | 32 Expect.isNotNull(source); |
| 34 return new Future<String>.value(source); | 33 return new Future<String>.value(source); |
| 35 } | 34 } |
| 36 | 35 |
| 37 String code = deprecatedFutureValue( | 36 String code = deprecatedFutureValue( |
| 38 compile(new Uri.fromComponents(scheme: 'main'), | 37 compile(new Uri(scheme: 'main'), |
| 39 new Uri.fromComponents(scheme: 'lib', path: '/'), | 38 new Uri(scheme: 'lib', path: '/'), |
| 40 new Uri.fromComponents(scheme: 'package', path: '/'), | 39 new Uri(scheme: 'package', path: '/'), |
| 41 provider, handler)); | 40 provider, handler)); |
| 42 if (code == null) { | 41 if (code == null) { |
| 43 throw 'Compilation failed: ${messages}'; | 42 throw 'Compilation failed: ${messages}'; |
| 44 } | 43 } |
| 45 Expect.stringEquals( | 44 Expect.stringEquals( |
| 46 // This string is composed of lines of the following format: | 45 // This string is composed of lines of the following format: |
| 47 // | 46 // |
| 48 // offset<source>:path:kind: message | 47 // offset<source>:path:kind: message |
| 49 // | 48 // |
| 50 // "offset" is the character offset from the beginning of TEST_SOURCE. | 49 // "offset" is the character offset from the beginning of TEST_SOURCE. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 86 } |
| 88 | 87 |
| 89 main() { | 88 main() { |
| 90 var a = Foo.bar(); | 89 var a = Foo.bar(); |
| 91 var b = new Foo.bar(); | 90 var b = new Foo.bar(); |
| 92 } | 91 } |
| 93 """, | 92 """, |
| 94 // TODO(ahe): Why isn't this 'part.dart'? Why the leading slash? | 93 // TODO(ahe): Why isn't this 'part.dart'? Why the leading slash? |
| 95 '/part.dart': '', | 94 '/part.dart': '', |
| 96 }; | 95 }; |
| OLD | NEW |