diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 15:33:28 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 15:33:28 +0000 |
commit | fd8df3ab3d935b4a201f9cb28598c95e4bb1ef14 (patch) | |
tree | c4d9db00a864d5eb740b17cc32c0b557cb9b6360 /spec/rubyspec/core/string/modulo_spec.rb | |
parent | e779eee98b503a9d1ef2b306d68bfe74db4c7101 (diff) | |
download | ruby-fd8df3ab3d935b4a201f9cb28598c95e4bb1ef14.tar.gz |
Raise ArgumentError if sprintf format string ends with %
* Add tests and specs. See ruby/spec#401.
Patch by Yuta Iwama and Shintaro Morikawa.
[ruby-core:80153] [Bug #13315] [Fix GH-1560]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/core/string/modulo_spec.rb')
-rw-r--r-- | spec/rubyspec/core/string/modulo_spec.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/rubyspec/core/string/modulo_spec.rb b/spec/rubyspec/core/string/modulo_spec.rb index 249b15bf1e..4f26ac5033 100644 --- a/spec/rubyspec/core/string/modulo_spec.rb +++ b/spec/rubyspec/core/string/modulo_spec.rb @@ -14,9 +14,18 @@ describe "String#%" do ("%d%% %s" % [10, "of chickens!"]).should == "10% of chickens!" end - it "formats single % character at the end as literal %" do - ("%" % []).should == "%" - ("foo%" % []).should == "foo%" + ruby_version_is ""..."2.5" do + it "formats single % character at the end as literal %" do + ("%" % []).should == "%" + ("foo%" % []).should == "foo%" + end + end + + ruby_version_is "2.5" do + it "raises an error if single % appears at the end" do + lambda { ("%" % []) }.should raise_error(ArgumentError) + lambda { ("foo%" % [])}.should raise_error(ArgumentError) + end end it "formats single % character before a newline as literal %" do |