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

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

Issue 11472022: Reject constructor names that conflict with members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test that deprecated language features are diagnosed correctly.
6
7 import '../../../sdk/lib/_internal/compiler/compiler.dart';
8 import 'dart:uri';
9 import '../../utils/dummy_compiler_test.dart' as dummy;
10
11 main() {
12 StringBuffer messages = new StringBuffer();
13 void handler(Uri uri, int begin, int end, String message, Diagnostic kind) {
14 if (kind == Diagnostic.VERBOSE_INFO) return;
15 if (identical(kind.name, 'source map')) return;
16 if (uri == null) {
17 messages.add('$kind: $message\n');
18 } else {
19 Expect.equals('main:', '$uri');
20 messages.add('$begin<${TEST_SOURCE.substring(begin, end)}>:$kind: '
21 '$message\n');
22 }
23 }
24
25 Future<String> provider(Uri uri) {
26 if (uri.scheme != "main") return dummy.provider(uri);
27 return (new Completer<String>()..complete(TEST_SOURCE)).future;
28 }
29
30 String code = compile(new Uri.fromComponents(scheme: 'main'),
31 new Uri.fromComponents(scheme: 'lib', path: '/'),
32 new Uri.fromComponents(scheme: 'package', path: '/'),
33 provider, handler).value;
34 if (code == null) {
35 throw 'Compilation failed: ${messages}';
36 }
37 Expect.stringEquals(
38 // This string is comprised of lines of the following format:
39 //
40 // offset<source>:kind: message
41 //
42 // "offset" is the character offset from the beginning of TEST_SOURCE.
43 // "source" is the substring of TEST_SOURCE that the compiler is
44 // indicating as erroneous.
45 // "kind" is the result of calling toString on a [Diagnostic] object.
46 // "message" is the expected message as a [String]. This is a
47 // short-term solution and should eventually changed to include
48 // a symbolic reference to a MessageKind.
49 "0<#library('test');>:${deprecatedMessage('# tags')}\n"
50 "19<interface>:${deprecatedMessage('interface declarations')}\n"
51 "144<Fisk>:${deprecatedMessage('interface factories')}\n"
52
53 // TODO(ahe): Should be <Fisk.hest>.
54 "164<Fisk>:${deprecatedMessage('interface factories')}\n"
55
56 // TODO(ahe): Should be <bar>.
57 "90<Foo>:${deprecatedMessage('conflicting constructor')}\n"
58
59 "110<bar>:info: This member conflicts with a constructor.\n"
60 "181<Dynamic>:${deprecatedMessage('Dynamic')}\n"
61 "202<()>:${deprecatedMessage('getter parameters')}\n",
62 messages.toString());
63 }
64
65 deprecatedMessage(feature) {
66 return
67 "warning: Warning: deprecated language feature, $feature"
68 ", will be removed in a future Dart milestone.";
69 }
70
71 const String TEST_SOURCE = """
72 #library('test');
73
74 interface Fisk default Foo {
75 Fisk();
76 Fisk.hest();
77 }
78
79 class Foo {
80 Foo.bar();
81 static bar() => new Foo.bar();
82 factory Fisk() {}
83 factory Fisk.hest() {}
84 Dynamic fisk;
85 get x() => null;
86 }
87
88 main() {
89 var a = Foo.bar();
90 var b = new Foo.bar();
91 new Fisk();
92 new Fisk.hest();
93 }
94 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698