}
public void testSetMainForAlreadyLoadedModule() throws Exception {
final Context cx = createContext();
final Scriptable scope = cx.initStandardObjects();
final Require require = getSandboxedRequire(cx, scope, false);
require.install(scope);
cx.evaluateReader(scope, getReader("testSetMainForAlreadyLoadedModule.js"),
"testSetMainForAlreadyLoadedModule.js", 1, null);
try {
require.requireMain(cx, "assert");
fail();
}
catch(IllegalStateException e) {
assertEquals(e.getMessage(), "Attempt to set main module after it was loaded");
}