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

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

Issue 22871009: Address long-standing review comments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; 8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart";
9 import "compiler_helper.dart"; 9 import "compiler_helper.dart";
10 import "parser_helper.dart"; 10 import "parser_helper.dart";
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 testClassHierarchy(); 69 testClassHierarchy();
70 testInitializers(); 70 testInitializers();
71 testThis(); 71 testThis();
72 testSuperCalls(); 72 testSuperCalls();
73 testTypeVariables(); 73 testTypeVariables();
74 testToString(); 74 testToString();
75 testIndexedOperator(); 75 testIndexedOperator();
76 testIncrementsAndDecrements(); 76 testIncrementsAndDecrements();
77 testOverrideHashCodeCheck(); 77 testOverrideHashCodeCheck();
78 testSupertypeOrder(); 78 testSupertypeOrder();
79 testConstructorArgumentMismatch();
79 } 80 }
80 81
81 testSupertypeOrder() { 82 testSupertypeOrder() {
82 MockCompiler compiler = new MockCompiler(); 83 MockCompiler compiler = new MockCompiler();
83 compiler.parseScript(""" 84 compiler.parseScript("""
84 class I1 {} 85 class I1 {}
85 class I2 {} 86 class I2 {}
86 class J1 extends K1 {} 87 class J1 extends K1 {}
87 class J2 implements K2 {} 88 class J2 implements K2 {}
88 class K1 {} 89 class K1 {}
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 compiler.resolver.resolve(fooElement); 569 compiler.resolver.resolve(fooElement);
569 570
570 TreeElements elements = compiler.resolveStatement("new A();"); 571 TreeElements elements = compiler.resolveStatement("new A();");
571 NewExpression expression = 572 NewExpression expression =
572 compiler.parsedTree.asExpressionStatement().expression; 573 compiler.parsedTree.asExpressionStatement().expression;
573 Element element = elements[expression.send]; 574 Element element = elements[expression.send];
574 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); 575 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind);
575 Expect.isTrue(element.isSynthesized); 576 Expect.isTrue(element.isSynthesized);
576 } 577 }
577 578
579 testConstructorArgumentMismatch() {
580 String script = "class A {} foo() { print(new A(42)); }";
581 MockCompiler compiler = new MockCompiler();
582 compiler.parseScript(script);
583 FunctionElement fooElement = compiler.mainApp.find(buildSourceString('foo'));
584 Expect.isNotNull(fooElement);
585 fooElement.parseNode(compiler);
586 compiler.resolver.resolve(fooElement);
587
588 compareWarningKinds(
589 script, [MessageKind.INVALID_ARGUMENTS.warning], compiler.warnings);
590 compareWarningKinds(script, [], compiler.errors);
591 }
592
578 testTopLevelFields() { 593 testTopLevelFields() {
579 MockCompiler compiler = new MockCompiler(); 594 MockCompiler compiler = new MockCompiler();
580 compiler.parseScript("int a;"); 595 compiler.parseScript("int a;");
581 VariableElement element = compiler.mainApp.find(buildSourceString("a")); 596 VariableElement element = compiler.mainApp.find(buildSourceString("a"));
582 Expect.equals(ElementKind.FIELD, element.kind); 597 Expect.equals(ElementKind.FIELD, element.kind);
583 VariableDefinitions node = element.variables.parseNode(compiler); 598 VariableDefinitions node = element.variables.parseNode(compiler);
584 Identifier typeName = node.type.typeName; 599 Identifier typeName = node.type.typeName;
585 Expect.equals(typeName.source.slowToString(), 'int'); 600 Expect.equals(typeName.source.slowToString(), 'int');
586 601
587 compiler.parseScript("var b, c;"); 602 compiler.parseScript("var b, c;");
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 } 915 }
901 main() { 916 main() {
902 new A() == new B(); 917 new A() == new B();
903 }"""; 918 }""";
904 final compiler = compileScript(script); 919 final compiler = compileScript(script);
905 Expect.equals(1, compiler.warnings.length); 920 Expect.equals(1, compiler.warnings.length);
906 Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE, 921 Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE,
907 compiler.warnings[0].message.kind); 922 compiler.warnings[0].message.kind);
908 Expect.equals(0, compiler.errors.length); 923 Expect.equals(0, compiler.errors.length);
909 } 924 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/optimize.dart ('k') | tests/language/closure_in_initializer2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698