Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/Issue176Test.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.javascript.tests;
6
7 import java.io.InputStreamReader;
8
9 import junit.framework.TestCase;
10
11 import org.mozilla.javascript.Context;
12 import org.mozilla.javascript.Script;
13 import org.mozilla.javascript.ScriptRuntime;
14 import org.mozilla.javascript.Scriptable;
15
16 public class Issue176Test extends TestCase {
17
18
19 Context cx;
20 Scriptable scope;
21
22 public void testThrowing() throws Exception {
23 cx = Context.enter();
24 try {
25 Script script = cx.compileReader(new InputStreamReader(
26 Bug482203Test.class.getResourceAsStream("Issue176.js")),
27 "Issue176.js", 1, null);
28 scope = cx.initStandardObjects();
29 scope.put("host", scope, this);
30 script.exec(cx, scope); // calls our methods
31 } finally {
32 Context.exit();
33 }
34 }
35
36
37 public void throwError(String msg) {
38 throw ScriptRuntime.throwError(cx, scope, msg);
39 }
40
41
42 public void throwCustomError(String constr, String msg) {
43 throw ScriptRuntime.throwCustomError(cx, scope, constr, msg);
44 }
45
46 }