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 | 9 |
10 import '../../../sdk/lib/_internal/compiler/compiler.dart'; | 10 import '../../../sdk/lib/_internal/compiler/compiler.dart'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 Future<String> provider(Uri uri) { | 29 Future<String> provider(Uri uri) { |
30 if (uri.scheme != "main") return dummy.provider(uri); | 30 if (uri.scheme != "main") return dummy.provider(uri); |
31 String source = TEST_SOURCE[uri.path]; | 31 String source = TEST_SOURCE[uri.path]; |
32 Expect.isNotNull(source); | 32 Expect.isNotNull(source); |
33 return new Future<String>.value(source); | 33 return new Future<String>.value(source); |
34 } | 34 } |
35 | 35 |
36 String code = deprecatedFutureValue( | 36 compile(new Uri(scheme: 'main'), |
37 compile(new Uri(scheme: 'main'), | 37 new Uri(scheme: 'lib', path: '/'), |
38 new Uri(scheme: 'lib', path: '/'), | 38 new Uri(scheme: 'package', path: '/'), |
39 new Uri(scheme: 'package', path: '/'), | 39 provider, handler).then((code) { |
40 provider, handler)); | 40 if (code == null) { |
41 if (code == null) { | 41 throw 'Compilation failed: ${messages}'; |
42 throw 'Compilation failed: ${messages}'; | 42 } |
43 } | 43 Expect.stringEquals( |
44 Expect.stringEquals( | 44 // This string is composed of lines of the following format: |
45 // This string is composed of lines of the following format: | 45 // |
46 // | 46 // offset<source>:path:kind: message |
47 // offset<source>:path:kind: message | 47 // |
48 // | 48 // "offset" is the character offset from the beginning of TEST_SOURCE. |
49 // "offset" is the character offset from the beginning of TEST_SOURCE. | 49 // "source" is the substring of TEST_SOURCE that the compiler is |
50 // "source" is the substring of TEST_SOURCE that the compiler is | 50 // indicating as erroneous. |
51 // indicating as erroneous. | 51 // "path" is the URI path. |
52 // "path" is the URI path. | 52 // "kind" is the result of calling toString on a [Diagnostic] object. |
53 // "kind" is the result of calling toString on a [Diagnostic] object. | 53 // "message" is the expected message as a [String]. This is a |
54 // "message" is the expected message as a [String]. This is a | 54 // short-term solution and should eventually changed to include |
55 // short-term solution and should eventually changed to include | 55 // a symbolic reference to a MessageKind. |
56 // a symbolic reference to a MessageKind. | 56 "0<#library('test');>::${deprecatedMessage('# tags')}\n" |
57 "0<#library('test');>::${deprecatedMessage('# tags')}\n" | 57 "19<part 'part.dart';>::${deprecatedMessage('missing part-of tag')}\n" |
58 "19<part 'part.dart';>::${deprecatedMessage('missing part-of tag')}\n" | 58 "0<>:/part.dart:info: Note: This file has no part-of tag, but it is" |
59 "0<>:/part.dart:info: Note: This file has no part-of tag, but it is being" | 59 " being used as a part.\n" |
60 " used as a part.\n" | |
61 | 60 |
62 // TODO(ahe): Should be <bar>. | 61 // TODO(ahe): Should be <bar>. |
63 "52<Foo>::${deprecatedMessage('conflicting constructor')}\n" | 62 "52<Foo>::${deprecatedMessage('conflicting constructor')}\n" |
64 | 63 |
65 "72<bar>::info: This member conflicts with a constructor.\n" | 64 "72<bar>::info: This member conflicts with a constructor.\n" |
66 "103<()>::${deprecatedMessage('getter parameters')}\n", | 65 "103<()>::${deprecatedMessage('getter parameters')}\n", |
67 messages.toString()); | 66 messages.toString()); |
| 67 }); |
68 } | 68 } |
69 | 69 |
70 deprecatedMessage(feature) { | 70 deprecatedMessage(feature) { |
71 return | 71 return |
72 "warning: Warning: deprecated language feature, $feature" | 72 "warning: Warning: deprecated language feature, $feature" |
73 ", will be removed in a future Dart milestone."; | 73 ", will be removed in a future Dart milestone."; |
74 } | 74 } |
75 | 75 |
76 const Map<String, String> TEST_SOURCE = | 76 const Map<String, String> TEST_SOURCE = |
77 const <String, String>{ '': """ | 77 const <String, String>{ '': """ |
78 #library('test'); | 78 #library('test'); |
79 | 79 |
80 part 'part.dart'; | 80 part 'part.dart'; |
81 | 81 |
82 class Foo { | 82 class Foo { |
83 Foo.bar(); | 83 Foo.bar(); |
84 static bar() => new Foo.bar(); | 84 static bar() => new Foo.bar(); |
85 get x() => null; | 85 get x() => null; |
86 } | 86 } |
87 | 87 |
88 main() { | 88 main() { |
89 var a = Foo.bar(); | 89 var a = Foo.bar(); |
90 var b = new Foo.bar(); | 90 var b = new Foo.bar(); |
91 } | 91 } |
92 """, | 92 """, |
93 // 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? |
94 '/part.dart': '', | 94 '/part.dart': '', |
95 }; | 95 }; |
OLD | NEW |