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

Unified Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java

Issue 10693074: Another small batch of Junit test for errors in the resolver (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
index d95f17532a850f5721c9cabc040bcbfd4a9ba4a9..2c12a2bb65d0437769229c7018370343db3c1c5a 100644
--- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
+++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java
@@ -1150,17 +1150,26 @@ public class ResolverTest extends ResolverTestCase {
ResolverErrorCode.CANNOT_USE_TYPE);
}
+ public void test_classUsedAsExpression() {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "main() {",
+ " 0.25 - Object;",
+ "}"),
+ ResolverErrorCode.IS_A_CLASS);
+ }
+
public void test_typeVariableUsedAsExpression() {
resolveAndTest(Joiner.on("\n").join(
"class Object {}",
"class A<B> {",
+ " var field = B;",
" f() {",
- " try {",
- " 0.25 - B;",
- " } catch(var e) {}",
+ " 0.25 - B;",
" }",
"}"),
- ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER);
+ ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER,
+ ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER);
}
public void test_shadowType_withVariable() throws Exception {
@@ -1524,4 +1533,66 @@ public class ResolverTest extends ResolverTestCase {
"}"),
errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_REDIRECT, 10, 21, 8));
}
+
+ public void test_unresolvedRedirectConstructor() throws Exception {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class A {",
+ " A() : this.named();",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_RESOLVE_CONSTRUCTOR, 3, 9, 12));
+ }
+
+ public void test_unresolvedSuperConstructor() throws Exception {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class A {",
+ " A() : super.named() {}",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_RESOLVE_SUPER_CONSTRUCTOR, 3, 9, 13));
+ }
+
+ public void test_unresolvedFieldInInitializer() throws Exception {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class A {",
+ " const A() : this.field = 1;",
+ "}"),
+ errEx(ResolverErrorCode.CANNOT_RESOLVE_FIELD, 3, 20, 5));
+ }
+
+ public void test_illegalConstructorModifiers() throws Exception {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "class A {",
+ " abstract A();",
+ " abstract A.named();",
+ "}",
+ "class B {",
+ " static B() {}",
+ " static B.named() {}",
+ "}"),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_ABSTRACT, 3, 12, 1),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_ABSTRACT, 4, 12, 7),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_STATIC, 7, 10, 1),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_BE_STATIC, 8, 10, 7));
+ }
+
+ public void test_illegalConstructorReturnType() throws Exception {
+ resolveAndTest(Joiner.on("\n").join(
+ "class Object {}",
+ "interface int {}",
+ "class A {",
+ " void A();",
+ " void A.named();",
+ "}",
+ "class B {",
+ " int B();",
+ " int B.named();",
+ "}"),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 4, 3, 4),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 5, 3, 4),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 8, 3, 3),
+ errEx(ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE, 9, 3, 3));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698