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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10823127: Issue 4300. Support for 'external' keyword (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e39ef928b92fdfc43ab5dcd21668b44052030de2..9b53680f35309ed515d748a86055135aa0573b3b 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -52,6 +52,7 @@ import java.io.StringReader;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -3174,6 +3175,63 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
errEx(ResolverErrorCode.RETHROW_NOT_IN_CATCH, 3, 3, 6));
}
+ public void test_externalKeyword_OK() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "external topFunction();",
+ "external get topGetter();",
+ "external set topSetter(var v);",
+ "class A {",
+ " external const A.con();",
+ " external A();",
+ " external factory A.named();",
+ " external classMethod();",
+ " external static classMethodStatic();",
+ " external get classGetter();",
+ " external set classSetter(var v);",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ // all method-like nodes here are "external"
+ final AtomicInteger methodCounter = new AtomicInteger();
+ testUnit.accept(new ASTVisitor<Void>() {
+ @Override
+ public Void visitMethodDefinition(DartMethodDefinition node) {
+ methodCounter.incrementAndGet();
+ assertTrue(node.getModifiers().isExternal());
+ return null;
+ }
+ });
+ assertEquals(10, methodCounter.get());
+ }
+
+ /**
+ * Methods with "external" cannot have body.
+ */
+ public void test_externalKeyword_bad() throws Exception {
Brian Wilkerson 2012/08/01 21:15:00 Not in this method, but we might want to test that
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "external var topVar1;",
+ "external int topVar2;",
+ "external topFunction() {}",
+ "class A {",
+ " external A() {}",
+ " external factory A.named() {}",
+ " external classMethod() {}",
+ " external abstract classMethodAbstract();",
+ "}",
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(ParserErrorCode.EXTERNAL_ONLY_METHOD, 2, 14, 7),
+ errEx(ParserErrorCode.EXTERNAL_ONLY_METHOD, 3, 14, 7),
+ errEx(ParserErrorCode.EXTERNAL_METHOD_BODY, 4, 24, 2),
+ errEx(ParserErrorCode.EXTERNAL_METHOD_BODY, 6, 16, 2),
+ errEx(ParserErrorCode.EXTERNAL_METHOD_BODY, 7, 30, 2),
+ errEx(ParserErrorCode.EXTERNAL_METHOD_BODY, 8, 26, 2),
+ errEx(ParserErrorCode.EXTERNAL_ABSTRACT, 9, 12, 8));
+ }
+
private static <T extends DartNode> T findNode(
AnalyzeLibraryResult libraryResult,
final Class<T> clazz,
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/Resolver.java ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698