File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ require_relative '../../spec_helper'
2
+
3
+ describe "Thread.each_caller_location" do
4
+ ruby_version_is "3.2" do
5
+ context "starts at the default frame that caller_locations would start at and" do
6
+ it "yields Thread::Backtrace::Location" do
7
+ i = 0 ;
8
+ ecl = Thread . each_caller_location do |loc |
9
+ i += 1 ;
10
+ break loc if i == 1 ;
11
+ end
12
+
13
+ ecl . to_s . should == caller_locations ( 1 , 1 ) [ 0 ] . to_s
14
+ ecl . should be_kind_of ( Thread ::Backtrace ::Location )
15
+ end
16
+
17
+ it "yields multiple Thread::Backtrace::Locations" do
18
+ i = 0 ;
19
+ ar = [ ]
20
+ ecl = Thread . each_caller_location do |loc |
21
+ ar << loc ;
22
+ i += 1 ;
23
+ break loc if i == 2 ;
24
+ end
25
+
26
+ ar . map ( &:to_s ) . should == caller_locations ( 1 ..2 ) . map ( &:to_s )
27
+ ecl . should be_kind_of ( Thread ::Backtrace ::Location )
28
+ end
29
+ end
30
+
31
+ it "raises StopIteration if reached an end" do
32
+ -> {
33
+ Thread . to_enum ( :each_caller_location ) . next
34
+ } . should raise_error ( StopIteration , "iteration reached an end" )
35
+ end
36
+ end
37
+ end
You can’t perform that action at this time.
0 commit comments