diff options
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 |
