File: Test.hx

package info (click to toggle)
haxe 1%3A4.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,556 kB
  • sloc: ml: 125,171; ansic: 2,408; makefile: 436; java: 362; cs: 323; cpp: 318; python: 316; sh: 75; objc: 64; php: 39; xml: 30; javascript: 11
file content (28 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
    }
}