Sfoglia il codice sorgente

[tests] next batch of parser error diagnostics tests

closes #7943
closes #7945
closes #7946
see #7947
Jens Fischer 6 anni fa
parent
commit
23ca866a7a

+ 27 - 0
tests/display/src/cases/Issue7943.hx

@@ -0,0 +1,27 @@
+package cases;
+
+class Issue7943 extends DisplayTestCase {
+	/**
+		class Main {
+			static function main() {
+				{-1-}0{-2-}{-3-}1{-4-};
+			}
+		}
+	**/
+	function test() {
+		arrayEq([
+			{
+				kind: DKParserError,
+				severity: Error,
+				range: diagnosticsRange(pos(3), pos(4)),
+				args: "Missing ;"
+			},
+			{
+				kind: DKCompilerError,
+				severity: Warning,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "This code has no effect"
+			}
+		], diagnostics());
+	}
+}

+ 31 - 0
tests/display/src/cases/Issue7945.hx

@@ -0,0 +1,31 @@
+package cases;
+
+class Issue7945 extends DisplayTestCase {
+	/**
+		abstract Test(Int) {-1-}too{-2-} Int {}
+	**/
+	function test1() {
+		arrayEq([
+			{
+				kind: DKParserError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Unexpected too"
+			}
+		], diagnostics());
+	}
+
+	/**
+		class Test {-1-}extend{-2-} OtherClass {}
+	**/
+	function test2() {
+		arrayEq([
+			{
+				kind: DKParserError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Expected extends or implements or {"
+			}
+		], diagnostics());
+	}
+}

+ 31 - 0
tests/display/src/cases/Issue7946.hx

@@ -0,0 +1,31 @@
+package cases;
+
+class Issue7946 extends DisplayTestCase {
+	/**
+		{-1-}open{-2-} haxe.Json;
+	**/
+	function test1() {
+		arrayEq([
+			{
+				kind: DKParserError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Unexpected open"
+			}
+		], diagnostics());
+	}
+
+	/**
+		{-1-}clas{-2-} Test {}
+	**/
+	function test() {
+		arrayEq([
+			{
+				kind: DKParserError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Unexpected clas"
+			}
+		], diagnostics());
+	}
+}

+ 55 - 0
tests/display/src/cases/Issue7947.hx

@@ -0,0 +1,55 @@
+package cases;
+
+class Issue7947 extends DisplayTestCase {
+	/**
+		class Main {
+			public static function main() {
+				var either = haxe.ds.Either.Left(123);
+				return switch either {
+					case Left(_):
+						trace('Some logic...');
+						trace('Some logic...');
+						trace('Some logic...');
+						true;
+					{-1-}case Right(_){-2-}:
+				}
+			}
+		}
+	**/
+	function test1() {
+		arrayEq([
+			{
+				kind: DKCompilerError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Void should be Bool"
+			}
+		], diagnostics());
+	}
+
+	/**
+		class Main {
+			public static function main() {
+				var either = haxe.ds.Either.Left(123);
+				return switch either {
+					case Right(_):
+					case Left(_):
+						trace('Some logic...');
+						trace('Some logic...');
+						trace('Some logic...');
+						{-1-}true{-2-};
+				}
+			}
+		}
+	**/
+	function test2() {
+		arrayEq([
+			{
+				kind: DKCompilerError,
+				severity: Error,
+				range: diagnosticsRange(pos(1), pos(2)),
+				args: "Bool should be Void"
+			}
+		], diagnostics());
+	}
+}