Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: dart/tests/compiler/dart2js/deprecated_features_test.dart

Issue 11464025: dart2js: complain about missing part-of tags. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 '../../../sdk/lib/_internal/compiler/compiler.dart'; 7 import '../../../sdk/lib/_internal/compiler/compiler.dart';
8 import 'dart:uri'; 8 import 'dart:uri';
9 import '../../utils/dummy_compiler_test.dart' as dummy; 9 import '../../utils/dummy_compiler_test.dart' as dummy;
10 10
11 main() { 11 main() {
12 StringBuffer messages = new StringBuffer(); 12 StringBuffer messages = new StringBuffer();
13 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) { 13 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
14 if (kind == Diagnostic.VERBOSE_INFO) return; 14 if (kind == Diagnostic.VERBOSE_INFO) return;
15 if (identical(kind.name, 'source map')) return; 15 if (identical(kind.name, 'source map')) return;
16 if (uri == null) { 16 if (uri == null) {
17 messages.add('$kind: $message\n'); 17 messages.add('$kind: $message\n');
18 } else { 18 } else {
19 Expect.equals('main:', '$uri'); 19 Expect.equals('main:${uri.path}', '$uri');
20 messages.add('$begin<${TEST_SOURCE.substring(begin, end)}>:$kind: ' 20 String source = TEST_SOURCE[uri.path];
21 '$message\n'); 21 Expect.isNotNull(source);
22 messages.add('$begin<${source.substring(begin, end)}>:${uri.path}:'
23 '$kind: $message\n');
22 } 24 }
23 } 25 }
24 26
25 Future<String> provider(Uri uri) { 27 Future<String> provider(Uri uri) {
26 if (uri.scheme != "main") return dummy.provider(uri); 28 if (uri.scheme != "main") return dummy.provider(uri);
27 return (new Completer<String>()..complete(TEST_SOURCE)).future; 29 String source = TEST_SOURCE[uri.path];
30 Expect.isNotNull(source);
31 return (new Completer<String>()..complete(source)).future;
28 } 32 }
29 33
30 String code = compile(new Uri.fromComponents(scheme: 'main'), 34 String code = compile(new Uri.fromComponents(scheme: 'main'),
31 new Uri.fromComponents(scheme: 'lib', path: '/'), 35 new Uri.fromComponents(scheme: 'lib', path: '/'),
32 new Uri.fromComponents(scheme: 'package', path: '/'), 36 new Uri.fromComponents(scheme: 'package', path: '/'),
33 provider, handler).value; 37 provider, handler).value;
34 if (code == null) { 38 if (code == null) {
35 throw 'Compilation failed: ${messages}'; 39 throw 'Compilation failed: ${messages}';
36 } 40 }
37 Expect.stringEquals( 41 Expect.stringEquals(
38 // This string is comprised of lines of the following format: 42 // This string is comprised of lines of the following format:
39 // 43 //
40 // offset<source>:kind: message 44 // offset<source>:path:kind: message
41 // 45 //
42 // "offset" is the character offset from the beginning of TEST_SOURCE. 46 // "offset" is the character offset from the beginning of TEST_SOURCE.
43 // "source" is the substring of TEST_SOURCE that the compiler is 47 // "source" is the substring of TEST_SOURCE that the compiler is
44 // indicating as erroneous. 48 // indicating as erroneous.
49 // "path" is the URI path.
45 // "kind" is the result of calling toString on a [Diagnostic] object. 50 // "kind" is the result of calling toString on a [Diagnostic] object.
46 // "message" is the expected message as a [String]. This is a 51 // "message" is the expected message as a [String]. This is a
47 // short-term solution and should eventually changed to include 52 // short-term solution and should eventually changed to include
48 // a symbolic reference to a MessageKind. 53 // a symbolic reference to a MessageKind.
49 "0<#library('test');>:${deprecatedMessage('# tags')}\n" 54 "0<#library('test');>::${deprecatedMessage('# tags')}\n"
50 "19<interface>:${deprecatedMessage('interface declarations')}\n" 55 "38<interface>::${deprecatedMessage('interface declarations')}\n"
51 "144<Fisk>:${deprecatedMessage('interface factories')}\n" 56 "19<part 'part.dart';>::${deprecatedMessage('missing part-of tag')}\n"
57 "0<>:/part.dart:info: Note: This file has no part-of tag, but it is being"
58 " used as a part.\n"
59 "163<Fisk>::${deprecatedMessage('interface factories')}\n"
52 60
53 // TODO(ahe): Should be <Fisk.hest>. 61 // TODO(ahe): Should be <Fisk.hest>.
54 "164<Fisk>:${deprecatedMessage('interface factories')}\n" 62 "183<Fisk>::${deprecatedMessage('interface factories')}\n"
55 63
56 // TODO(ahe): Should be <bar>. 64 // TODO(ahe): Should be <bar>.
57 "90<Foo>:${deprecatedMessage('conflicting constructor')}\n" 65 "109<Foo>::${deprecatedMessage('conflicting constructor')}\n"
58 66
59 "110<bar>:info: This member conflicts with a constructor.\n" 67 "129<bar>::info: This member conflicts with a constructor.\n"
60 "181<Dynamic>:${deprecatedMessage('Dynamic')}\n" 68 "200<Dynamic>::${deprecatedMessage('Dynamic')}\n"
61 "202<()>:${deprecatedMessage('getter parameters')}\n", 69 "221<()>::${deprecatedMessage('getter parameters')}\n",
62 messages.toString()); 70 messages.toString());
63 } 71 }
64 72
65 deprecatedMessage(feature) { 73 deprecatedMessage(feature) {
66 return 74 return
67 "warning: Warning: deprecated language feature, $feature" 75 "warning: Warning: deprecated language feature, $feature"
68 ", will be removed in a future Dart milestone."; 76 ", will be removed in a future Dart milestone.";
69 } 77 }
70 78
71 const String TEST_SOURCE = """ 79 const Map<String, String> TEST_SOURCE =
80 const <String, String>{ '': """
72 #library('test'); 81 #library('test');
73 82
83 part 'part.dart';
84
74 interface Fisk default Foo { 85 interface Fisk default Foo {
75 Fisk(); 86 Fisk();
76 Fisk.hest(); 87 Fisk.hest();
77 } 88 }
78 89
79 class Foo { 90 class Foo {
80 Foo.bar(); 91 Foo.bar();
81 static bar() => new Foo.bar(); 92 static bar() => new Foo.bar();
82 factory Fisk() {} 93 factory Fisk() {}
83 factory Fisk.hest() {} 94 factory Fisk.hest() {}
84 Dynamic fisk; 95 Dynamic fisk;
85 get x() => null; 96 get x() => null;
86 } 97 }
87 98
88 main() { 99 main() {
89 var a = Foo.bar(); 100 var a = Foo.bar();
90 var b = new Foo.bar(); 101 var b = new Foo.bar();
91 new Fisk(); 102 new Fisk();
92 new Fisk.hest(); 103 new Fisk.hest();
93 } 104 }
94 """; 105 """,
106 // TODO(ahe): Why isn't this 'part.dart'? Why the leading slash?
107 '/part.dart': '',
108 };
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698