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

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

Issue 11111017: Re-land r13557 on behalf of Alexander. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | 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 #import('dart:uri'); 5 #import('dart:uri');
6 6
7 #import("../../../lib/compiler/implementation/leg.dart"); 7 #import("../../../lib/compiler/implementation/leg.dart");
8 #import("../../../lib/compiler/implementation/elements/elements.dart"); 8 #import("../../../lib/compiler/implementation/elements/elements.dart");
9 #import("../../../lib/compiler/implementation/tree/tree.dart"); 9 #import("../../../lib/compiler/implementation/tree/tree.dart");
10 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); 10 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart");
11 #import("../../../lib/compiler/implementation/universe/universe.dart");
11 #import("../../../lib/compiler/implementation/util/util.dart"); 12 #import("../../../lib/compiler/implementation/util/util.dart");
12 #import("compiler_helper.dart"); 13 #import("compiler_helper.dart");
13 #import("mock_compiler.dart"); 14 #import("mock_compiler.dart");
14 #import("parser_helper.dart"); 15 #import("parser_helper.dart");
15 16
16 Node buildIdentifier(String name) => new Identifier(scan(name)); 17 Node buildIdentifier(String name) => new Identifier(scan(name));
17 18
18 Node buildInitialization(String name) => 19 Node buildInitialization(String name) =>
19 parseBodyCode('$name = 1', 20 parseBodyCode('$name = 1',
20 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); 21 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens));
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 String constructor, int expectedElementCount, 557 String constructor, int expectedElementCount,
557 [List expectedWarnings = const [], 558 [List expectedWarnings = const [],
558 List expectedErrors = const [], 559 List expectedErrors = const [],
559 String corelib = DEFAULT_CORELIB]) { 560 String corelib = DEFAULT_CORELIB]) {
560 MockCompiler compiler = new MockCompiler(corelib); 561 MockCompiler compiler = new MockCompiler(corelib);
561 compiler.parseScript(script); 562 compiler.parseScript(script);
562 compiler.resolveStatement(statement); 563 compiler.resolveStatement(statement);
563 ClassElement classElement = 564 ClassElement classElement =
564 compiler.mainApp.find(buildSourceString(className)); 565 compiler.mainApp.find(buildSourceString(className));
565 Element element = 566 Element element =
566 classElement.lookupConstructor(buildSourceString(constructor)); 567 classElement.lookupConstructor(
568 new Selector.callConstructor(buildSourceString(constructor),
569 classElement.getLibrary()));
567 FunctionExpression tree = element.parseNode(compiler); 570 FunctionExpression tree = element.parseNode(compiler);
568 ResolverVisitor visitor = new ResolverVisitor(compiler, element); 571 ResolverVisitor visitor = new ResolverVisitor(compiler, element);
569 new InitializerResolver(visitor).resolveInitializers(element, tree); 572 new InitializerResolver(visitor).resolveInitializers(element, tree);
570 visitor.visit(tree.body); 573 visitor.visit(tree.body);
571 Expect.equals(expectedElementCount, map(visitor).length); 574 Expect.equals(expectedElementCount, map(visitor).length);
572 575
573 compareWarningKinds(script, expectedWarnings, compiler.warnings); 576 compareWarningKinds(script, expectedWarnings, compiler.warnings);
574 compareWarningKinds(script, expectedErrors, compiler.errors); 577 compareWarningKinds(script, expectedErrors, compiler.errors);
575 } 578 }
576 579
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 A() : foo(); 659 A() : foo();
657 }"""; 660 }""";
658 resolveConstructor(script, "A a = new A();", "A", "A", 0, 661 resolveConstructor(script, "A a = new A();", "A", "A", 0,
659 [], [MessageKind.CONSTRUCTOR_CALL_EXPECTED]); 662 [], [MessageKind.CONSTRUCTOR_CALL_EXPECTED]);
660 663
661 script = """class A { 664 script = """class A {
662 int i; 665 int i;
663 A.a() : this.b(0); 666 A.a() : this.b(0);
664 A.b(int i); 667 A.b(int i);
665 }"""; 668 }""";
666 resolveConstructor(script, "A a = new A.a();", "A", r"A$a", 1, 669 resolveConstructor(script, "A a = new A.a();", "A", "a", 1,
667 [], []); 670 [], []);
668 671
669 script = """class A { 672 script = """class A {
670 int i; 673 int i;
671 A.a() : i = 42, this(0); 674 A.a() : i = 42, this(0);
672 A(int i); 675 A(int i);
673 }"""; 676 }""";
674 resolveConstructor(script, "A a = new A.a();", "A", r"A$a", 2, 677 resolveConstructor(script, "A a = new A.a();", "A", "a", 2,
675 [], [MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER]); 678 [], [MessageKind.REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER]);
676 679
677 script = """class A { 680 script = """class A {
678 int i; 681 int i;
679 A(i); 682 A(i);
680 } 683 }
681 class B extends A { 684 class B extends A {
682 B() : super(0); 685 B() : super(0);
683 }"""; 686 }""";
684 resolveConstructor(script, "B a = new B();", "B", "B", 1, 687 resolveConstructor(script, "B a = new B();", "B", "B", 1,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 var d = new D(); 785 var d = new D();
783 --d; 786 --d;
784 }"""; 787 }""";
785 final compiler = compileScript(script); 788 final compiler = compileScript(script);
786 789
787 checkMemberResolved(compiler, 'A', operatorName('+', false)); 790 checkMemberResolved(compiler, 'A', operatorName('+', false));
788 checkMemberResolved(compiler, 'B', operatorName('+', false)); 791 checkMemberResolved(compiler, 'B', operatorName('+', false));
789 checkMemberResolved(compiler, 'C', operatorName('-', false)); 792 checkMemberResolved(compiler, 'C', operatorName('-', false));
790 checkMemberResolved(compiler, 'D', operatorName('-', false)); 793 checkMemberResolved(compiler, 'D', operatorName('-', false));
791 } 794 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698