Chromium Code Reviews| Index: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
| diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
| index 150b4b83f271310ef43d43fa28e813363d85bea7..323622dc52cd3356d413a5d8b124a8f103e15dff 100644 |
| --- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
| +++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java |
| @@ -2643,6 +2643,59 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase { |
| errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 8, 4, 2)); |
| } |
| + /** |
| + * It is a static warning if T does not denote a type available in the current lexical scope. |
| + * <p> |
| + * http://code.google.com/p/dart/issues/detail?id=2373 |
| + */ |
| + public void test_asType_unknown() throws Exception { |
| + AnalyzeLibraryResult libraryResult = analyzeLibrary( |
| + "// filler filler filler filler filler filler filler filler filler filler", |
| + "main() {", |
| + " null as T;", |
| + "}", |
| + ""); |
| + assertErrors( |
| + libraryResult.getErrors(), |
| + errEx(TypeErrorCode.NO_SUCH_TYPE, 3, 11, 1)); |
| + } |
| + |
| + /** |
| + * It is a compile-time error if T is a parameterized type of the form G < T1; : : : ; Tn > and G |
| + * is not a generic type with n type parameters. |
| + * <p> |
| + * http://code.google.com/p/dart/issues/detail?id=2373 |
| + */ |
| + public void test_asType_wrongNumberOfTypeArguments() throws Exception { |
| + AnalyzeLibraryResult libraryResult = analyzeLibrary( |
| + "// filler filler filler filler filler filler filler filler filler filler", |
| + "class A {}", |
| + "main() {", |
| + " null as A<int, bool>;", |
| + "}", |
| + ""); |
| + assertErrors( |
| + libraryResult.getErrors(), |
| + errEx(ResolverErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, 4, 11, 12)); |
| + } |
| + |
| + /** |
| + * It is a static warning if T does not denote a type available in the current lexical scope. |
| + * <p> |
| + * http://code.google.com/p/dart/issues/detail?id=2373 |
| + */ |
| + public void test_unknownIsType() throws Exception { |
|
Brian Wilkerson
2012/06/19 16:16:51
nit: I would prefer to see this named "test_isType
|
| + AnalyzeLibraryResult libraryResult = analyzeLibrary( |
| + "// filler filler filler filler filler filler filler filler filler filler", |
| + "main() {", |
| + " null is T;", |
| + "}", |
| + ""); |
| + assertErrors( |
| + libraryResult.getErrors(), |
| + errEx(TypeErrorCode.NO_SUCH_TYPE, 3, 11, 1)); |
| + } |
| + |
| private AnalyzeLibraryResult analyzeLibrary(String... lines) throws Exception { |
| return analyzeLibrary(getName(), makeCode(lines)); |
| } |