本文整理汇总了Java中org.mozilla.javascript.RhinoException.useMozillaStackStyle方法的典型用法代码示例。如果您正苦于以下问题:Java RhinoException.useMozillaStackStyle方法的具体用法?Java RhinoException.useMozillaStackStyle怎么用?Java RhinoException.useMozillaStackStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.RhinoException
的用法示例。
在下文中一共展示了RhinoException.useMozillaStackStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultStack
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
@Test
public void defaultStack() {
RhinoException.useMozillaStackStyle(false);
testScriptStackTrace("null.method()", "\tat myScript.js:1" + LS);
final String script = "function f() \n{\n null.method();\n}\nf();\n";
testScriptStackTrace(script, "\tat myScript.js:3 (f)" + LS + "\tat myScript.js:5" + LS);
testIt("try { null.method() } catch (e) { e.stack }", "\tat myScript.js:1" + LS);
final String expectedStack = "\tat myScript.js:2 (f)" + LS + "\tat myScript.js:4" + LS;
testIt("function f() {\n null.method(); \n}\n try { f() } catch (e) { e.stack }", expectedStack);
}
示例2: mozillaStack
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
@Test
public void mozillaStack() {
RhinoException.useMozillaStackStyle(true);
testScriptStackTrace("null.method()", "@myScript.js:1" + LS);
final String script = "function f() \n{\n null.method();\n}\nf();\n";
testScriptStackTrace(script, "f()@myScript.js:3" + LS + "@myScript.js:5" + LS);
testIt("try { null.method() } catch (e) { e.stack }", "@myScript.js:1" + LS);
final String expectedStack = "f()@myScript.js:2" + LS + "@myScript.js:4" + LS;
testIt("function f() {\n null.method(); \n}\n try { f() } catch (e) { e.stack }", expectedStack);
}
示例3: testFailureStackTrace
import org.mozilla.javascript.RhinoException; //导入方法依赖的package包/类
/**
* As of CVS head on May, 11. 2009, stacktrace information is lost when a call to some
* native function has been made.
*/
public void testFailureStackTrace() {
RhinoException.useMozillaStackStyle(false);
final String source1 = "function f2() { throw 'hello'; }; f2();";
final String source2 = "function f2() { 'H'.toLowerCase(); throw 'hello'; }; f2();";
final String source3 = "function f2() { new java.lang.String('H').toLowerCase(); throw 'hello'; }; f2();";
final String result = "\tat test.js (f2)" + LS + "\tat test.js" + LS;
runWithExpectedStackTrace(source1, result);
runWithExpectedStackTrace(source2, result);
runWithExpectedStackTrace(source3, result);
}