File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed
src/test/java/org/truffleruby Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change 15
15
import static org .junit .Assert .assertTrue ;
16
16
17
17
import org .graalvm .polyglot .Context ;
18
- import org .graalvm .polyglot .PolyglotException ;
19
18
import org .graalvm .polyglot .Value ;
20
- import org .junit .Assert ;
21
19
import org .junit .Test ;
22
20
23
21
public class MiscTest {
@@ -49,26 +47,18 @@ public void timeoutExecution() throws Throwable {
49
47
TestingThread thread = new TestingThread (() -> {
50
48
try {
51
49
Thread .sleep (1000 );
52
- context .close (true );
53
50
} catch (InterruptedException e ) {
54
51
throw new Error (e );
55
- } catch (PolyglotException e ) {
56
- if (e .isCancelled ()) {
57
- assertTrue (e .isCancelled ());
58
- } else {
59
- throw e ;
60
- }
61
52
}
53
+ context .close (true );
62
54
});
63
55
64
56
context .eval ("ruby" , "init = 1" );
65
57
thread .start ();
66
58
try {
67
59
String maliciousCode = "while true; end" ;
68
- context .eval ("ruby" , maliciousCode );
69
- Assert .fail ();
70
- } catch (PolyglotException e ) {
71
- assertTrue (e .isCancelled ());
60
+ RubyTest .assertThrows (() -> context .eval ("ruby" , maliciousCode ),
61
+ e -> assertTrue (e .isCancelled ()));
72
62
} finally {
73
63
thread .join ();
74
64
}
You can’t perform that action at this time.
0 commit comments