summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string
diff options
context:
space:
mode:
authorAndrew Konchin <[email protected]>2025-01-30 17:39:10 +0200
committerBenoit Daloze <[email protected]>2025-01-30 20:43:46 +0100
commitd7a5ad2a21f7d2c45e3fea674ff077bb0e2cadae (patch)
treed49629b969bb4d13b74fd1bfeebf15553cc3d5d2 /spec/ruby/core/string
parentea2dd5b80e26036af83e7b37d722f4a106188555 (diff)
Update to ruby/spec@affef93
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12679
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r--spec/ruby/core/string/append_as_bytes_spec.rb12
-rw-r--r--spec/ruby/core/string/modulo_spec.rb4
2 files changed, 15 insertions, 1 deletions
diff --git a/spec/ruby/core/string/append_as_bytes_spec.rb b/spec/ruby/core/string/append_as_bytes_spec.rb
index 0e1d09558b..b1703e5f89 100644
--- a/spec/ruby/core/string/append_as_bytes_spec.rb
+++ b/spec/ruby/core/string/append_as_bytes_spec.rb
@@ -34,6 +34,18 @@ describe "String#append_bytes" do
str.should == "hello\xE2\x82\f+\xAC".b
end
+ it "truncates integers to the least significant byte" do
+ str = +""
+ str.append_as_bytes(0x131, 0x232, 0x333, bignum_value, bignum_value(1))
+ str.bytes.should == [0x31, 0x32, 0x33, 0, 1]
+ end
+
+ it "wraps negative integers" do
+ str = "".b
+ str.append_as_bytes(-1, -bignum_value, -bignum_value(1))
+ str.bytes.should == [0xFF, 0, 0xFF]
+ end
+
it "only accepts strings or integers, and doesn't attempt to cast with #to_str or #to_int" do
to_str = mock("to_str")
to_str.should_not_receive(:to_str)
diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb
index 8e3853551f..33c2141812 100644
--- a/spec/ruby/core/string/modulo_spec.rb
+++ b/spec/ruby/core/string/modulo_spec.rb
@@ -749,9 +749,11 @@ describe "String#%" do
(format % "-10.4e-20").should == (format % -10.4e-20)
(format % ".5").should == (format % 0.5)
(format % "-.5").should == (format % -0.5)
- ruby_bug("#20705", ""..."3.4") do
+
+ ruby_version_is "3.4" do
(format % "10.").should == (format % 10)
end
+
# Something's strange with this spec:
# it works just fine in individual mode, but not when run as part of a group
(format % "10_1_0.5_5_5").should == (format % 1010.555)