Sha256: 5076f2ccc9f8292262f1f8e37e4648e752d0ad16d0f551665e066205f77141d4

Contents?: true

Size: 1.73 KB

Versions: 52

Compression:

Stored size: 1.73 KB

Contents

describe :array_pack_numeric_basic, :shared => true do
  it "returns an empty String if count is zero" do
    [1].pack(pack_format(0)).should == ""
  end

  it "raises a TypeError when passed nil" do
    lambda { [nil].pack(pack_format) }.should raise_error(TypeError)
  end

  it "raises a TypeError when passed true" do
    lambda { [true].pack(pack_format) }.should raise_error(TypeError)
  end

  it "raises a TypeError when passed false" do
    lambda { [false].pack(pack_format) }.should raise_error(TypeError)
  end

  ruby_version_is '1.9' do
    it "returns an ASCII-8BIT string" do
      [0xFF].pack(pack_format).encoding.should == Encoding::ASCII_8BIT
      [0xE3, 0x81, 0x82].pack(pack_format(3)).encoding.should == Encoding::ASCII_8BIT
    end
  end
end

describe :array_pack_integer, :shared => true do
  it "raises a TypeError when the object does not respond to #to_int" do
    obj = mock('not an integer')
    lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
  end

  it "raises a TypeError when passed a String" do
    lambda { ["5"].pack(pack_format) }.should raise_error(TypeError)
  end
end

describe :array_pack_float, :shared => true do
  ruby_version_is ""..."1.9" do
    it "raises a ArgumentError if a String does not represent a floating point number" do
      lambda { ["a"].pack(pack_format) }.should raise_error(ArgumentError)
    end
  end

  ruby_version_is "1.9" do
    it "raises a TypeError if a String does not represent a floating point number" do
      lambda { ["a"].pack(pack_format) }.should raise_error(TypeError)
    end
  end

  it "raises a TypeError when the object does not respond to #to_f" do
    obj = mock('not an float')
    lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/array/pack/shared/numeric_basic.rb