Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nystrom committed Nov 24, 2024
1 parent 80ce29b commit d4e13e9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/rematch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,23 +505,21 @@ end
(; x, y) => (x, y)
end) == (1, 2)

# Check that field names are bound for `=` and `::` patterns too.
# Check that field names are bound for `::` patterns too.
@test (@match Foo(1,2) begin
(; x=1, y::Int) => (x, y)
(; x::Int, y::Int) => (x, y)
end) == (1,2)

# Check that patterns after `=` also bind.
@test (@match Foo(1,2) begin
(; x=z, y) => (x, y, z)
end) == (1,2,1)
# Check that field names are not bound for `=` patterns too.
err = (VERSION < v"1.11-") ? UndefVarError(:x) : UndefVarError(:x, @__MODULE__)
@test_throws err (@match Foo(1,2) begin
(; x=1, y) => (x, y)
end) == (1,2)

# Check that we don't match if a field does not exist.
# Check that patterns after `=` bind.
@test (@match Foo(1,2) begin
(; x, y, z) => false # No field `z`.
(; x) => true
(; x, y) => false
_ => false
end)
(; x=z, y) => (y, z)
end) == (1,2,1)

# Check that we don't match if a field does not exist.
@test (@match Foo(1,2) begin
Expand Down

0 comments on commit d4e13e9

Please sign in to comment.