File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 22
22
locations . length . should == 1
23
23
end
24
24
25
+ it "can be called with a range" do
26
+ locations1 = caller_locations ( 0 )
27
+ locations2 = caller_locations ( 2 ..4 )
28
+ locations1 [ 2 ..4 ] . map ( &:to_s ) . should == locations2 . map ( &:to_s )
29
+ end
30
+
31
+ it "can be called with a range whose end is negative" do
32
+ locations1 = caller_locations ( 0 )
33
+ locations2 = caller_locations ( 2 ..-1 )
34
+ locations3 = caller_locations ( 2 ..-2 )
35
+ locations1 [ 2 ..-1 ] . map ( &:to_s ) . should == locations2 . map ( &:to_s )
36
+ locations1 [ 2 ..-2 ] . map ( &:to_s ) . should == locations3 . map ( &:to_s )
37
+ end
38
+
39
+ it "must return nil if omitting more locations than available" do
40
+ caller_locations ( 100 ) . should == nil
41
+ caller_locations ( 100 ..-1 ) . should == nil
42
+ end
43
+
44
+ it "must return [] if omitting exactly the number of locations available" do
45
+ omit = caller_locations ( 0 ) . length
46
+ caller_locations ( omit ) . should == [ ]
47
+ end
48
+
25
49
it 'returns the locations as Thread::Backtrace::Location instances' do
26
50
locations = KernelSpecs ::CallerLocationsTest . locations
27
51
28
52
locations . each do |location |
29
53
location . kind_of? ( Thread ::Backtrace ::Location ) . should == true
30
54
end
31
55
end
56
+
57
+ it "must return the same locations when called with 1..-1 and when called with no arguments" do
58
+ caller_locations . map ( &:to_s ) . should == caller_locations ( 1 ..-1 ) . map ( &:to_s )
59
+ end
32
60
end
You can’t perform that action at this time.
0 commit comments