jdk/test/tools/jjs/args.js
author dl
Fri, 03 Feb 2017 13:24:59 -0800
changeset 43522 f9c6f543c4db
parent 34721 59801fbd042e
permissions -rw-r--r--
8171886: Miscellaneous changes imported from jsr166 CVS 2017-02 Reviewed-by: martin, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34721
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     1
/*
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     2
 * This is the test JavaScript program used in jjs-argsTest.sh
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     3
 */
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     4
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     5
if (typeof(arguments) == 'undefined') {
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     6
    throw new Error("arguments expected");
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     7
}
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     8
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
     9
if (arguments.length != 2) {
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    10
    throw new Error("2 arguments are expected here");
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    11
}
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    12
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    13
if (arguments[0] != 'hello') {
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    14
    throw new Error("First arg should be 'hello'");
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    15
}
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    16
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    17
if (arguments[1] != 'world') {
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    18
    throw new Error("Second arg should be 'world'");
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    19
}
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    20
59801fbd042e 8145750: jjs fails to run simple scripts with security manager turned on
sundar
parents:
diff changeset
    21
print("Passed");