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

Unified Diff: frog/tests/leg/src/TypeCheckerTest.dart

Issue 9835007: Typecheck constructor calls. I'm pretty sure about the call to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: trailing whitespace Created 8 years, 9 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 | « no previous file | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2686f7d13966d0b53009a2a873788a6753a2b2a0 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,35 @@ 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();", MessageKind.MISSING_ARGUMENT);
+ analyze("new C1(1);", MessageKind.MISSING_ARGUMENT);
+ analyze("new C1(1, 2, 3);", MessageKind.ADDITIONAL_ARGUMENT);
+ // calls to typed constructor C2
+ analyze("new C2(1, 2);");
+ analyze("new C2();", MessageKind.MISSING_ARGUMENT);
+ analyze("new C2(1);", MessageKind.MISSING_ARGUMENT);
+ analyze("new C2(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 +230,9 @@ 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). */
« no previous file with comments | « no previous file | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698