Skip to content

Commit

Permalink
Merge pull request #1210 from headius/spec_update_20241105
Browse files Browse the repository at this point in the history
Spec update 20241105
  • Loading branch information
headius authored Nov 6, 2024
2 parents eab1c59 + 287ac86 commit a230079
Show file tree
Hide file tree
Showing 80 changed files with 1,891 additions and 230 deletions.
1 change: 1 addition & 0 deletions .mspec.constants
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Prime
Private
ProcFromMethod
Psych
RactorLocalSingleton
REXML
RUBY_SIGNALS
RbReadline
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ end
platform_is_not :linux, :darwin do # Not Linux and not Darwin
end

platform_is wordsize: 64 do
platform_is pointer_size: 64 do
# 64-bit platform
end

Expand Down
1 change: 0 additions & 1 deletion command_line/fixtures/debug_info.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# frozen_string_literal: true
a = 'string'
b = a
c = b
Expand Down
13 changes: 11 additions & 2 deletions command_line/frozen_strings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,18 @@

describe "The --debug flag produces" do
it "debugging info on attempted frozen string modification" do
error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--debug', args: "2>&1")
error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--enable-frozen-string-literal --debug', args: "2>&1")
error_str.should include("can't modify frozen String")
error_str.should include("created at")
error_str.should include("command_line/fixtures/debug_info.rb:2")
error_str.should include("command_line/fixtures/debug_info.rb:1")
end

guard -> { ruby_version_is "3.4" and !"test".frozen? } do
it "debugging info on mutating chilled string" do
error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '-w --debug', args: "2>&1")
error_str.should include("literal string will be frozen in the future")
error_str.should include("the string was created here")
error_str.should include("command_line/fixtures/debug_info.rb:1")
end
end
end
48 changes: 48 additions & 0 deletions core/array/fetch_values_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

describe "Array#fetch_values" do
before :each do
@array = [:a, :b, :c]
end

ruby_version_is "3.4" do
describe "with matched indexes" do
it "returns the values for indexes" do
@array.fetch_values(0).should == [:a]
@array.fetch_values(0, 2).should == [:a, :c]
end

it "returns the values for indexes ordered in the order of the requested indexes" do
@array.fetch_values(2, 0).should == [:c, :a]
end
end

describe "with unmatched indexes" do
it "raises a index error if no block is provided" do
-> { @array.fetch_values(0, 1, 44) }.should raise_error(IndexError)
end

it "returns the default value from block" do
@array.fetch_values(44) { |index| "`#{index}' is not found" }.should == ["`44' is not found"]
@array.fetch_values(0, 44) { |index| "`#{index}' is not found" }.should == [:a, "`44' is not found"]
end
end

describe "without keys" do
it "returns an empty Array" do
@array.fetch_values.should == []
end
end

it "tries to convert the passed argument to an Integer using #to_int" do
obj = mock('to_int')
obj.should_receive(:to_int).and_return(2)
@array.fetch_values(obj).should == [:c]
end

it "raises a TypeError when the passed argument can't be coerced to Integer" do
-> { [].fetch_values("cat") }.should raise_error(TypeError)
end
end
end
16 changes: 8 additions & 8 deletions core/array/pack/l_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
it_behaves_like :array_pack_32bit_be, 'L>'
end

platform_is wordsize: 32 do
platform_is c_long_size: 32 do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'L<_'
it_behaves_like :array_pack_32bit_le, 'L_<'
Expand All @@ -51,7 +51,7 @@
end
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_64bit_le, 'L<_'
it_behaves_like :array_pack_64bit_le, 'L_<'
Expand Down Expand Up @@ -83,7 +83,7 @@
it_behaves_like :array_pack_32bit_be, 'l>'
end

platform_is wordsize: 32 do
platform_is c_long_size: 32 do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_32bit_le, 'l<_'
it_behaves_like :array_pack_32bit_le, 'l_<'
Expand All @@ -105,7 +105,7 @@
end
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
describe "with modifier '<' and '_'" do
it_behaves_like :array_pack_64bit_le, 'l<_'
it_behaves_like :array_pack_64bit_le, 'l_<'
Expand Down Expand Up @@ -137,7 +137,7 @@
it_behaves_like :array_pack_32bit_le, 'l'
end

platform_is wordsize: 32 do
platform_is c_long_size: 32 do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_le, 'L_'
end
Expand All @@ -155,7 +155,7 @@
end
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_64bit_le, 'L_'
end
Expand Down Expand Up @@ -183,7 +183,7 @@
it_behaves_like :array_pack_32bit_be, 'l'
end

platform_is wordsize: 32 do
platform_is c_long_size: 32 do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_32bit_be, 'L_'
end
Expand All @@ -201,7 +201,7 @@
end
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
describe "Array#pack with format 'L' with modifier '_'" do
it_behaves_like :array_pack_64bit_be, 'L_'
end
Expand Down
4 changes: 2 additions & 2 deletions core/array/pack/shared/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde\x21\x43\x65\x78"
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
it "encodes the least significant 32 bits of a number that is greater than 32 bits" do
[ [[0xff_7865_4321], "\x21\x43\x65\x78"],
[[-0xff_7865_4321], "\xdf\xbc\x9a\x87"]
Expand All @@ -299,7 +299,7 @@
str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd\x78\x65\x43\x21"
end

platform_is wordsize: 64 do
platform_is c_long_size: 64 do
it "encodes the least significant 32 bits of a number that is greater than 32 bits" do
[ [[0xff_7865_4321], "\x78\x65\x43\x21"],
[[-0xff_7865_4321], "\x87\x9a\xbc\xdf"]
Expand Down
Loading

0 comments on commit a230079

Please sign in to comment.