From d4e13e9b42cec0c698cfc346b46e1067dd3a5323 Mon Sep 17 00:00:00 2001 From: Nate Nystrom Date: Sun, 24 Nov 2024 17:07:16 +0100 Subject: [PATCH] fix tests --- test/rematch.jl | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/rematch.jl b/test/rematch.jl index 92b4279..a018225 100644 --- a/test/rematch.jl +++ b/test/rematch.jl @@ -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