Chromium Code Reviews| Index: frog/tests/leg/src/ResolverTest.dart |
| diff --git a/frog/tests/leg/src/ResolverTest.dart b/frog/tests/leg/src/ResolverTest.dart |
| index 3c8954b258cca0e248f6221f68623ca891d78076..0ccf8d518acc922ab66b5a34f5bcae63c47442f6 100644 |
| --- a/frog/tests/leg/src/ResolverTest.dart |
| +++ b/frog/tests/leg/src/ResolverTest.dart |
| @@ -113,7 +113,7 @@ testThis() { |
| compiler.resolveStatement("main() { return this; }"); |
| Expect.equals(0, compiler.warnings.length); |
| Expect.equals(1, compiler.errors.length); |
| - Expect.equals(MessageKind.NO_THIS_IN_STATIC, |
| + Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| compiler.errors[0].message.kind); |
| compiler = new MockCompiler(); |
| @@ -128,7 +128,7 @@ testThis() { |
| visitor.visit(function.body); |
| Expect.equals(0, compiler.warnings.length); |
| Expect.equals(1, compiler.errors.length); |
| - Expect.equals(MessageKind.NO_THIS_IN_STATIC, |
| + Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| compiler.errors[0].message.kind); |
| } |
| @@ -429,7 +429,8 @@ testTopLevelFields() { |
| VariableElement element = compiler.universe.find(buildSourceString("a")); |
| Expect.equals(ElementKind.FIELD, element.kind); |
| VariableDefinitions node = element.variables.parseNode(compiler, compiler); |
| - Expect.equals(node.type.typeName.asIdentifier().source.stringValue, 'int'); |
| + Identifier typeName = node.type.typeName; |
| + Expect.equals(typeName.source.stringValue, 'int'); |
| compiler.parseScript("var b, c;"); |
| VariableElement bElement = compiler.universe.find(buildSourceString("b")); |
| @@ -458,7 +459,8 @@ resolveConstructor(String script, String statement, String className, |
| classElement.lookupConstructor(buildSourceString(constructor)); |
| FunctionExpression tree = element.parseNode(compiler, compiler); |
| ResolverVisitor visitor = new FullResolverVisitor(compiler, element); |
| - compiler.resolver.resolveInitializers(element, tree, visitor); |
| + new InitializerResolver(visitor, element).resolveInitializers(tree); |
| + visitor.visit(tree.body); |
| Expect.equals(expectedElementCount, visitor.mapping.map.length); |
| compareWarningKinds(script, expectedWarnings, compiler.warnings); |
| @@ -477,7 +479,7 @@ testInitializers() { |
| int foo; A a; |
| A() : a.foo = 1; |
| }"""; |
| - resolveConstructor(script, "A a = new A();", "A", "A", 1, |
| + resolveConstructor(script, "A a = new A();", "A", "A", 0, |
| [], [MessageKind.INVALID_RECEIVER_IN_INITIALIZER]); |
| script = """class A { |
| @@ -500,7 +502,50 @@ testInitializers() { |
| A() : this.foo = bar; |
| }"""; |
| resolveConstructor(script, "A a = new A();", "A", "A", 2, |
| - [], [MessageKind.NOT_STATIC]); |
| + [], [MessageKind.NO_INSTANCE_AVAILABLE]); |
| + |
| + script = """class A { |
| + int foo() => 42; |
| + A() : foo(); |
| + }"""; |
| + resolveConstructor(script, "A a = new A();", "A", "A", 1, |
| + [], [MessageKind.CONSTRUCTOR_CALL_EXPECTED]); |
| + |
| + script = """class A { |
| + int i; |
| + A.a() : this.b(0); |
| + A.b(int this.i); |
| + }"""; |
| + resolveConstructor(script, "A a = new A.a();", "A", "A.a", 1, |
| + [], []); |
| + |
| + script = """class A { |
| + int i; |
| + A.a() : i = 42, this(0); |
| + A(int this.i); |
| + }"""; |
| + resolveConstructor(script, "A a = new A.a();", "A", "A.a", 2, |
| + [], [MessageKind.REDIRECTING_CTOR_HAS_INITIALIZER]); |
| + |
| + script = """class A { |
| + int i; |
| + A(this.i); |
| + } |
| + class B extends A { |
| + B() : super(0); |
| + }"""; |
| + resolveConstructor(script, "B a = new B();", "B", "B", 1, |
| + [], []); |
| + |
| + script = """class A { |
| + int i; |
| + A(this.i); |
| + } |
| + class B extends A { |
| + B() : super(0), super(1); |
| + }"""; |
| + resolveConstructor(script, "B b = new B();", "B", "B", 2, |
| + [], [MessageKind.DUPLICATE_SUPER_INITIALIZER]); |
|
ngeoffray
2012/01/19 08:56:12
Could you also add tests for class Object?
karlklose
2012/01/19 13:51:24
Done.
|
| } |
| length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; |