File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/test/java/org/truffleruby Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,31 @@ public void timeoutExecution() throws Throwable {
64
64
}
65
65
}
66
66
67
+ @ Test
68
+ public void testCancellationWithFibers () throws Throwable {
69
+ Context context = RubyTest .createContext ();
70
+
71
+ // schedule a timeout in 100ms
72
+ TestingThread thread = new TestingThread (() -> {
73
+ try {
74
+ Thread .sleep (100 );
75
+ } catch (InterruptedException e ) {
76
+ throw new Error (e );
77
+ }
78
+ context .close (true );
79
+ });
80
+
81
+ context .eval ("ruby" , "init = 1" );
82
+ thread .start ();
83
+ try {
84
+ String code = "unstarted = Fiber.new {}; resumed = Fiber.new { Fiber.yield }.tap(&:resume); sleep 1" ;
85
+ RubyTest .assertThrows (() -> context .eval ("ruby" , code ),
86
+ e -> assertTrue (e .isCancelled ()));
87
+ } finally {
88
+ thread .join ();
89
+ }
90
+ }
91
+
67
92
@ Test
68
93
public void testEvalFromIntegratorThreadSingleThreaded () throws Throwable {
69
94
final String codeDependingOnCurrentThread = "Thread.current.object_id" ;
You can’t perform that action at this time.
0 commit comments