diff options
Diffstat (limited to 'spec/ruby/language/pattern_matching_spec.rb')
| -rw-r--r-- | spec/ruby/language/pattern_matching_spec.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/ruby/language/pattern_matching_spec.rb b/spec/ruby/language/pattern_matching_spec.rb index cb4f5864d7..a24500c9fd 100644 --- a/spec/ruby/language/pattern_matching_spec.rb +++ b/spec/ruby/language/pattern_matching_spec.rb @@ -185,7 +185,7 @@ describe "Pattern matching" do in [] end RUBY - }.should raise_error(SyntaxError, /syntax error, unexpected `in'|\(eval\):3: syntax error, unexpected keyword_in|unexpected 'in'/) + }.should.raise(SyntaxError, /syntax error, unexpected `in'|\(eval\):3: syntax error, unexpected keyword_in|unexpected 'in'/) -> { eval <<~RUBY @@ -194,7 +194,7 @@ describe "Pattern matching" do when 1 == 1 end RUBY - }.should raise_error(SyntaxError, /syntax error, unexpected `when'|\(eval\):3: syntax error, unexpected keyword_when|unexpected 'when'/) + }.should.raise(SyntaxError, /syntax error, unexpected `when'|\(eval\):3: syntax error, unexpected keyword_when|unexpected 'when'/) end it "checks patterns until the first matching" do @@ -222,14 +222,14 @@ describe "Pattern matching" do case [0, 1] in [0] end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) error_pattern = ruby_version_is("3.4") ? /\{a: 0, b: 1\}/ : /\{:a=>0, :b=>1\}/ -> { case {a: 0, b: 1} in a: 1, b: 1 end - }.should raise_error(NoMatchingPatternError, error_pattern) + }.should.raise(NoMatchingPatternError, error_pattern) end it "raises NoMatchingPatternError if no pattern matches and evaluates the expression only once" do @@ -238,7 +238,7 @@ describe "Pattern matching" do case (evals += 1; [0, 1]) in [0] end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) evals.should == 1 end @@ -250,7 +250,7 @@ describe "Pattern matching" do true end RUBY - }.should raise_error(SyntaxError, /unexpected|expected a delimiter after the patterns of an `in` clause/) + }.should.raise(SyntaxError, /unexpected|expected a delimiter after the patterns of an `in` clause/) end it "evaluates the case expression once for multiple patterns, caching the result" do @@ -336,7 +336,7 @@ describe "Pattern matching" do case [0, 1] in [0, 1] if false end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) end end @@ -438,7 +438,7 @@ describe "Pattern matching" do in [a, a] end RUBY - }.should raise_error(SyntaxError, /duplicated variable name/) + }.should.raise(SyntaxError, /duplicated variable name/) end it "supports existing variables in a pattern specified with ^ operator" do @@ -474,7 +474,7 @@ describe "Pattern matching" do false end RUBY - }.should raise_error(SyntaxError, /n: no such local variable/) + }.should.raise(SyntaxError, /n: no such local variable/) end end @@ -493,7 +493,7 @@ describe "Pattern matching" do in [0, 0] | [0, a] end RUBY - }.should raise_error(SyntaxError, /illegal variable in alternative pattern/) + }.should.raise(SyntaxError) end it "support underscore prefixed variables in alternation" do @@ -674,7 +674,7 @@ describe "Pattern matching" do in Object[] else end - }.should raise_error(TypeError, /deconstruct must return Array/) + }.should.raise(TypeError, /deconstruct must return Array/) end it "accepts a subclass of Array from #deconstruct" do @@ -870,7 +870,7 @@ describe "Pattern matching" do in {"a" => 1} end RUBY - }.should raise_error(SyntaxError, /unexpected|expected a label as the key in the hash pattern/) + }.should.raise(SyntaxError, /unexpected|expected a label as the key in the hash pattern/) end it "does not support string interpolation in keys" do @@ -880,7 +880,7 @@ describe "Pattern matching" do in {"#{x}": 1} end RUBY - }.should raise_error(SyntaxError, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) + }.should.raise(SyntaxError, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) end it "raise SyntaxError when keys duplicate in pattern" do @@ -890,7 +890,7 @@ describe "Pattern matching" do in {a: 1, b: 2, a: 3} end RUBY - }.should raise_error(SyntaxError, /duplicated key name/) + }.should.raise(SyntaxError, /duplicated key name/) end it "matches an object with #deconstruct_keys method which returns a Hash with equal keys and each value in Hash matches value in pattern" do @@ -969,7 +969,7 @@ describe "Pattern matching" do case obj in Object[a: 1] end - }.should raise_error(TypeError, /deconstruct_keys must return Hash/) + }.should.raise(TypeError, /deconstruct_keys must return Hash/) end it "does not match object if #deconstruct_keys method returns Hash with non-symbol keys" do |
