File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 553553 end . wait
554554 end
555555
556- it "can stop a task and provide a cause" do
556+ it "can stop a task from within with a cause" do
557557 error = nil
558558
559559 cause = Async ::Stop ::Cause . for ( "boom" )
572572 expect ( error ) . to be_a ( Async ::Stop )
573573 expect ( error . cause ) . to be == cause
574574 end
575+
576+ it "can stop a task from outside with a cause" do
577+ skip_unless_minimum_ruby_version ( "3.5" )
578+
579+ error = nil
580+
581+ cause = RuntimeError . new ( "boom" )
582+
583+ task = reactor . async do |task |
584+ begin
585+ task . yield
586+ rescue Async ::Stop => error
587+ raise
588+ end
589+ end
590+
591+ task . stop ( cause : cause )
592+
593+ reactor . run
594+
595+ expect ( task ) . to be ( :stopped? )
596+ expect ( error ) . to be_a ( Async ::Stop )
597+ expect ( error . cause ) . to be == cause
598+ end
575599 end
576600
577601 with "#sleep" do
You can’t perform that action at this time.
0 commit comments