jdk/test/tools/jjs/modulepath.js
author sundar
Fri, 07 Oct 2016 21:28:00 +0530
changeset 41374 092e014ed01e
permissions -rw-r--r--
8167018: Nashorn and jjs should support --module-path and --add-modules options Reviewed-by: jlaskey, hannesw
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
}