Skip to content

Commit 3f505ce

Browse files
herwinwandrykonchin
authored andcommitted
Add specs for Process::Status#>>
They're pretty minimal, since the method is deprecated and will be removed in Ruby 3.5. (Ruby 3.3 warns for removal in 3.4, but 3.4-dev still has the method and warns for removal in 3.5)
1 parent 081bc6b commit 3f505ce

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
require_relative '../../../spec_helper'
22

33
describe "Process::Status#>>" do
4-
it "needs to be reviewed for spec completeness"
4+
it "returns a right shift of the integer status of an exited child" do
5+
suppress_warning do
6+
ruby_exe("exit(29)", exit_status: 29)
7+
($? >> 0).should == $?.to_i
8+
($? >> 1).should == $?.to_i >> 1
9+
10+
# Actual value is implementation specific
11+
platform_is :linux do
12+
($? >> 8).should == 29
13+
end
14+
end
15+
end
16+
17+
ruby_version_is "3.3" do
18+
it "raises an ArgumentError if shift value is negative" do
19+
suppress_warning do
20+
ruby_exe("exit(0)")
21+
-> {
22+
$? >> -1
23+
}.should raise_error(ArgumentError, 'negative shift value: -1')
24+
end
25+
end
26+
27+
it "shows a deprecation warning" do
28+
ruby_exe("exit(0)")
29+
-> {
30+
$? >> 0
31+
}.should complain(/warning: Process::Status#>> is deprecated and will be removed .*use other Process::Status attributes instead/)
32+
end
33+
end
534
end

0 commit comments

Comments
 (0)