test/jdk/tools/jjs/modulepath.js
author prr
Wed, 29 Nov 2017 09:47:02 -0800
changeset 47982 44371ff1ee9a
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41374
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     1
/*
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     2
 * This is the test JavaScript program used in jjs-modulepathTest.sh
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     3
 */
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     4
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     5
print("--module-path passed: " + $OPTIONS._module_path);
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     6
print("--add-modules passed: " + $OPTIONS._add_modules);
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     7
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     8
var Hello = com.greetings.Hello;
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
     9
var moduleName = Hello.class.module.name;
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    10
if (moduleName != "com.greetings") {
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    11
    throw new Error("Expected module name to be com.greetings");
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    12
} else {
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    13
    print("Module name is " + moduleName);
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    14
}
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    15
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    16
var msg = Hello.greet();
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    17
if (msg != "Hello World!") {
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    18
    throw new Error("Expected 'Hello World!'");
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    19
} else {
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    20
    print(msg);
092e014ed01e 8167018: Nashorn and jjs should support --module-path and --add-modules options
sundar
parents:
diff changeset
    21
}