Skip to content

Commit

Permalink
Add tests for AlternationPatternNode
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw committed Sep 16, 2024
1 parent d45c853 commit 73c96c3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/natalie/pattern_matching_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,20 @@ def self.one = 1
[1, 2] => *, ^a
}.should raise_error(NoMatchingPatternError, '[1, 2]: 1 === 2 does not return true')
end

it 'can handle alternation' do
1 => String | Integer
end

it 'can handle more than 2 alternations' do
1 => String | Symbol | Integer
end

it 'can fail with missing alternation' do
-> {
1 => String | Symbol
}.should raise_error(NoMatchingPatternError, '1: Symbol === 1 does not return true')
end
end

describe 'NoMatchingPatternError' do
Expand Down

0 comments on commit 73c96c3

Please sign in to comment.