Chromium Code Reviews| Index: frog/tests/leg/src/TypeCheckerTest.dart |
| diff --git a/frog/tests/leg/src/TypeCheckerTest.dart b/frog/tests/leg/src/TypeCheckerTest.dart |
| index 9d6c972bd1506ce63f8c9b37f2ed578bb40f2467..331645676b5bd5495e8c295f960bf26a08bdd603 100644 |
| --- a/frog/tests/leg/src/TypeCheckerTest.dart |
| +++ b/frog/tests/leg/src/TypeCheckerTest.dart |
| @@ -22,6 +22,8 @@ main() { |
| testFor, |
| testWhile, |
| testOperators, |
| + testConstructorInvocationArgumentCount, |
| + testConstructorInvocationArgumentTypes, |
| testMethodInvocationArgumentCount, |
| testMethodInvocations, |
| testControlFlow, |
| @@ -132,6 +134,41 @@ testOperators() { |
| } |
| } |
| +void testConstructorInvocationArgumentCount() { |
| + compiler.parseScript(""" |
| + class C1 { C1(x, y); } |
| + class C2 { C2(int x, int y); } |
| + """); |
| + // calls to untyped constructor C1 |
| + analyze("new C1(1, 2);"); |
| + analyze("new C1();", |
|
karlklose
2012/03/30 08:55:31
I think most of these would fit on one line (also
polux
2012/03/30 09:01:28
Done, I thought the layout of the other methods wa
|
| + MessageKind.MISSING_ARGUMENT); |
| + analyze("new C1(1);", |
| + MessageKind.MISSING_ARGUMENT); |
| + analyze("new C1(1, 2, 3);", |
| + MessageKind.ADDITIONAL_ARGUMENT); |
| + analyze("new C1(1, 2);"); |
| + // calls to typed constructor C2 |
| + analyze("new C1();", |
|
karlklose
2012/03/30 08:55:31
new C1() -> new C2() (also in l. 154 and 156). Ple
polux
2012/03/30 09:01:28
Thanks for catching that.
|
| + MessageKind.MISSING_ARGUMENT); |
| + analyze("new C1(1);", |
| + MessageKind.MISSING_ARGUMENT); |
| + analyze("new C1(1, 2, 3);", |
| + MessageKind.ADDITIONAL_ARGUMENT); |
| +} |
| + |
| +void testConstructorInvocationArgumentTypes() { |
| + compiler.parseScript(""" |
| + class C1 { C1(x); } |
| + class C2 { C2(int x); } |
| + """); |
| + analyze("new C1(42);"); |
| + analyze("new C1('string');"); |
| + analyze("new C2(42);"); |
| + analyze("new C2('string');", |
| + MessageKind.NOT_ASSIGNABLE); |
| +} |
| + |
| void testMethodInvocationArgumentCount() { |
| compiler.parseScript(CLASS_WITH_METHODS); |
| final String header = "{ ClassWithMethods c; "; |
| @@ -199,6 +236,12 @@ void testMethodInvocations() { |
| analyze("${header}int k = c.intTwoArgumentMethod(i, j); }"); |
| analyze("${header}ClassWithMethods x = c.intTwoArgumentMethod(i, j); }", |
| MessageKind.NOT_ASSIGNABLE); |
| + |
| + analyze("${header}c.intField(); }", |
| + MessageKind.METHOD_NOT_FOUND); |
| + analyze("${header}d.intField(); }", |
| + MessageKind.METHOD_NOT_FOUND); |
| + |
| } |
| /** Tests analysis of returns (not required by the specification). */ |