diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/string/gsub_spec.rb | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) | |
download | ruby-5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0.tar.gz |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/string/gsub_spec.rb')
-rw-r--r-- | spec/ruby/core/string/gsub_spec.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index 29b65c72a7..cd66a4f875 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -214,9 +214,9 @@ describe "String#gsub with pattern and replacement" do end it "raises a TypeError when pattern can't be converted to a string" do - lambda { "hello".gsub([], "x") }.should raise_error(TypeError) - lambda { "hello".gsub(Object.new, "x") }.should raise_error(TypeError) - lambda { "hello".gsub(nil, "x") }.should raise_error(TypeError) + -> { "hello".gsub([], "x") }.should raise_error(TypeError) + -> { "hello".gsub(Object.new, "x") }.should raise_error(TypeError) + -> { "hello".gsub(nil, "x") }.should raise_error(TypeError) end it "tries to convert replacement to a string using to_str" do @@ -227,9 +227,9 @@ describe "String#gsub with pattern and replacement" do end it "raises a TypeError when replacement can't be converted to a string" do - lambda { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError) - lambda { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError) - lambda { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError) end it "returns subclass instances when called on a subclass" do @@ -298,7 +298,7 @@ describe "String#gsub with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".gsub(/./, hsh).should == "lamblamblamblamblamb" end @@ -387,7 +387,7 @@ describe "String#gsub! with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".gsub!(/./, hsh).should == "lamblamblamblamblamb" end @@ -536,8 +536,8 @@ describe "String#gsub with pattern and block" do s = "hllëllo" s2 = "hellö" - lambda { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - lambda { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -549,7 +549,7 @@ describe "String#gsub with pattern and block" do not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - lambda { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) end end end @@ -607,9 +607,9 @@ describe "String#gsub! with pattern and replacement" do s = "hello" s.freeze - lambda { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class) - lambda { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class) - lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) + -> { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class) + -> { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class) + -> { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) end end @@ -644,9 +644,9 @@ describe "String#gsub! with pattern and block" do s = "hello" s.freeze - lambda { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) - lambda { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class) - lambda { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) + -> { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) + -> { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class) + -> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) end it "uses the compatible encoding if they are compatible" do @@ -661,8 +661,8 @@ describe "String#gsub! with pattern and block" do s = "hllëllo" s2 = "hellö" - lambda { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - lambda { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -674,7 +674,7 @@ describe "String#gsub! with pattern and block" do not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - lambda { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) end end end |