Skip to content

Commit 081bc6b

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 3effc7b commit 081bc6b

File tree

1 file changed

+31
-1
lines changed

1 file changed

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

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

0 commit comments

Comments
 (0)