diff options
author | Benoit Daloze <[email protected]> | 2022-03-28 17:47:04 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2022-03-28 17:47:04 +0200 |
commit | 8db4f25bf4327f169902afd9ea8f4b03b65656f0 (patch) | |
tree | ad61b99fb2d5ebfe9c07de8c2b5885e80d20b8e1 /spec/ruby/core/array | |
parent | ae650f0372e10cea4d695769b1fcdc23a76fdf17 (diff) |
Update to ruby/spec@aaf998f
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r-- | spec/ruby/core/array/pack/x_spec.rb | 1 | ||||
-rw-r--r-- | spec/ruby/core/array/sample_spec.rb | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/spec/ruby/core/array/pack/x_spec.rb b/spec/ruby/core/array/pack/x_spec.rb index a28dd0bf21..86c3ad1aa4 100644 --- a/spec/ruby/core/array/pack/x_spec.rb +++ b/spec/ruby/core/array/pack/x_spec.rb @@ -30,6 +30,7 @@ describe "Array#pack with format 'x'" do it "does not add a NULL byte when passed the '*' modifier" do [].pack("x*").should == "" + [1, 2].pack("Cx*C").should == "\x01\x02" end end diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb index 565d7ff7f9..755b46f126 100644 --- a/spec/ruby/core/array/sample_spec.rb +++ b/spec/ruby/core/array/sample_spec.rb @@ -19,10 +19,18 @@ describe "Array#sample" do [].sample.should be_nil end + it "returns nil for an empty array when called without n and a Random is given" do + [].sample(random: Random.new(42)).should be_nil + end + it "returns a single value when not passed a count" do [4].sample.should equal(4) end + it "returns a single value when not passed a count and a Random is given" do + [4].sample(random: Random.new(42)).should equal(4) + end + it "returns an empty Array when passed zero" do [4].sample(0).should == [] end |