summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-20 01:04:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-20 03:57:13 +0900
commit1ef49de83483e6f78bfe9c795a473ccfb29db150 (patch)
treef6c48f28801763a95372f143b2cdea5564b96336 /spec/ruby/core/string
parentce384ef5a95b809f248e089c1608e60753dabe45 (diff)
[Bug #18955] format single character for `%c`
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6258
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r--spec/ruby/core/string/modulo_spec.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb
index 99c1694417..bf96a82874 100644
--- a/spec/ruby/core/string/modulo_spec.rb
+++ b/spec/ruby/core/string/modulo_spec.rb
@@ -368,8 +368,16 @@ describe "String#%" do
("%c" % 'A').should == "A"
end
- it "raises an exception for multiple character strings as argument for %c" do
- -> { "%c" % 'AA' }.should raise_error(ArgumentError)
+ ruby_version_is ""..."3.2" do
+ it "raises an exception for multiple character strings as argument for %c" do
+ -> { "%c" % 'AA' }.should raise_error(ArgumentError)
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it "supports only the first character as argument for %c" do
+ ("%c" % 'AA').should == "A"
+ end
end
it "calls to_str on argument for %c formats" do