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

Unified Diff: compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java

Issue 9421001: Issue 1606/1108. The 'native' keyword is supposed to only be allowed in core libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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/parser/NegativeParserTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
index cd2aa9496feadf8776e9dac2784f4d5ac18d94b7..1b407a941aa4528646ae7e6697b3005c34404e0f 100644
--- a/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
+++ b/compiler/javatests/com/google/dart/compiler/parser/NegativeParserTest.java
@@ -680,4 +680,73 @@ public class NegativeParserTest extends CompilerTestCase {
"}",
""));
}
+
+ /**
+ * "native" can be specified only for classes.
+ */
+ public void test_native_inInterace() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "interface A native 'N' {",
+ "}",
+ ""),
+ errEx(ParserErrorCode.NATIVE_ONLY_CLASS, 2, 13, 6));
+ }
+
+ /**
+ * "native" can be specified only for classes without "extends".
+ */
+ public void test_native_classWithExtends() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ "}",
+ "class B extends A native 'N' {",
+ "}",
+ ""),
+ errEx(ParserErrorCode.NATIVE_MUST_NOT_EXTEND, 4, 19, 6));
+ }
+
+ /**
+ * "native" can be specified only in "corelib".
+ */
+ public void test_native_onlyCoreLib() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A native 'N' {",
+ "}",
+ ""),
+ errEx(ParserErrorCode.NATIVE_ONLY_CORE_LIB, 2, 9, 6));
+ }
+
+ /**
+ * "native" can be specified only in "corelib".
+ */
+ public void test_native_onlyCoreLib_factory() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " factory A() native;",
+ "}",
+ ""),
+ errEx(ParserErrorCode.NATIVE_ONLY_CORE_LIB, 3, 15, 6));
+ }
+
+ /**
+ * "native" can be specified only in "corelib".
+ */
+ public void test_native_onlyCoreLib_method() {
+ parseExpectErrors(
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " factory A() native;",
+ "}",
+ ""),
+ errEx(ParserErrorCode.NATIVE_ONLY_CORE_LIB, 3, 15, 6));
+ }
}
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/end2end/NativeTestLib.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698