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