Skip to content

Commit

Permalink
Test that Ruby exception cause does not stack up
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed May 9, 2022
1 parent a90fc86 commit 92aa508
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions core/src/test/java/org/jruby/embed/jsr223/JRubyEngineTest.java
Expand Up @@ -827,6 +827,38 @@ public void testClearVariables() throws ScriptException {
assertNotNull( getVarMap(instance).getVariable("ARGV") );
}

@Test
public void testRaiseDoesNotStackCause()
throws Exception
{
try
{
final ScriptEngine _jruby1 = new JRubyEngineFactory().getScriptEngine();
_jruby1.eval("raise 'foo'");
}
catch (Exception _e)
{
try (ByteArrayOutputStream _bos = new ByteArrayOutputStream();
PrintStream _s = new PrintStream(_bos))
{
assertFalse("stack contains bar: " + _bos.toString(), _bos.toString().contains("bar"));
}
}
try
{
final ScriptEngine _jruby2 = new JRubyEngineFactory().getScriptEngine();
_jruby2.eval("raise 'bar'");
}
catch (Exception _e)
{
try (ByteArrayOutputStream _bos = new ByteArrayOutputStream();
PrintStream _s = new PrintStream(_bos))
{
assertFalse("stack contains foo: " + _bos.toString(), _bos.toString().contains("foo"));
}
}
}

private static BiVariableMap getVarMap(final ScriptEngine engine) {
return ((JRubyEngine) engine).container.getVarMap();
}
Expand Down

0 comments on commit 92aa508

Please sign in to comment.