2
0
Эх сурвалжийг харах

add test for character "code" field completion (closes #4270)

Dan Korostelev 10 жил өмнө
parent
commit
ff9462c3c3

+ 5 - 0
tests/misc/projects/Issue4270/EmptyString.hx

@@ -0,0 +1,5 @@
+class EmptyString {
+    static function main() {
+        "".
+    }
+}

+ 5 - 0
tests/misc/projects/Issue4270/MultiChar.hx

@@ -0,0 +1,5 @@
+class MultiChar {
+    static function main() {
+        "ab".
+    }
+}

+ 5 - 0
tests/misc/projects/Issue4270/SingleChar.hx

@@ -0,0 +1,5 @@
+class SingleChar {
+    static function main() {
+        "a".
+    }
+}

+ 28 - 0
tests/misc/projects/Issue4270/Test.hx

@@ -0,0 +1,28 @@
+class Test {
+    static function error(msg, code) {
+        Sys.stderr().writeString(msg);
+        Sys.exit(code);
+    }
+
+    static function test(file:String, pos:Int, shouldExist:Bool) {
+        var arg = '$file@$pos';
+        var proc = new sys.io.Process("haxe", ["--display", arg]);
+        var stderr = proc.stderr.readAll().toString();
+        var exit = proc.exitCode();
+        if (exit != 0) {
+            error(arg + ":\n" + stderr, exit);
+        } else {
+            var exist = stderr.indexOf("<i n=\"code\">") != -1;
+            if (shouldExist && !exist)
+                error(arg + ":\nNo 'code' field found in the completion output:\n\n" + stderr, 1);
+            else if (!shouldExist && exist)
+                error(arg + ":\nThe 'code' field should not present in the completion output:\n\n" + stderr, 1);
+        }
+    }
+
+    static function main() {
+        test("EmptyString.hx", 60, false);
+        test("MultiChar.hx", 60, false);
+        test("SingleChar.hx", 60, true);
+    }
+}

+ 1 - 0
tests/misc/projects/Issue4270/test.hxml

@@ -0,0 +1 @@
+--run Test