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

Unified Diff: tests/compiler/dart2js/find_my_name_test.dart

Issue 18072002: Fix Element.findMyName for named constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/elements/modelx.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/find_my_name_test.dart
diff --git a/tests/compiler/dart2js/find_my_name_test.dart b/tests/compiler/dart2js/find_my_name_test.dart
index 1c24d17d8640b1a462e1aa52ae0f23b7914a5fe8..d5e7d0f0957826ff7712af618c05f613313d9b3e 100644
--- a/tests/compiler/dart2js/find_my_name_test.dart
+++ b/tests/compiler/dart2js/find_my_name_test.dart
@@ -7,18 +7,36 @@ import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
import "mock_compiler.dart";
import "parser_helper.dart";
-main() {
- MockCompiler compiler = new MockCompiler();
-
- String code = '''
+String TEST_0 = '''
class Foo {
+ Foo();
+ Foo.named();
+ factory Foo._internal() => null;
operator+(other) => null;
}
''';
- ClassElement foo = parseUnit(code, compiler, compiler.mainApp).head;
- foo.parseNode(compiler);
- for (Element e in foo.localMembers) {
- Expect.equals(code.indexOf(e.name.slowToString()), e.position().charOffset);
+String TEST_1 = '''
+class Bar {
+ const Bar();
+ const Bar.named();
+ Map<int, List<int>> baz() => null;
+}
+''';
+
+main() {
+ MockCompiler compiler = new MockCompiler();
+ testClass(TEST_0, compiler);
+ testClass(TEST_1, compiler);
+}
+
+testClass(String code, MockCompiler compiler) {
+ int skip = code.indexOf('{');
+ ClassElement cls = parseUnit(code, compiler, compiler.mainApp).head;
+ cls.parseNode(compiler);
+ for (Element e in cls.localMembers) {
+ String name = e.name.slowToString();
+ if (e.isConstructor()) name = name.replaceFirst(r'$', '.');
+ Expect.equals(code.indexOf(name, skip), e.position().charOffset);
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/elements/modelx.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698