Skip to content

Commit fd30157

Browse files
committed
Fix testing of warning messages
1 parent 91138d3 commit fd30157

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

test/test_deprecations.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ tree = cos(2.1 * x1)
88

99
# Also test warnings:
1010
for constructor in (OperatorEnum, GenericOperatorEnum)
11-
operators = constructor(; binary_operators=[+, -, *, /], unary_operators=[cos, sin])
1211
VERSION >= v"1.9" &&
13-
@test_warn "The `tree(X; kws...)` syntax is deprecated" tree([1.0; 2.0;;])
12+
@test_logs (:warn, r"The `tree\(X; kws...\)` syntax is deprecated.*") tree(
13+
[1.0; 2.0;;]
14+
)
1415

1516
constructor == GenericOperatorEnum && continue
1617

1718
tree'([1.0; 2.0;;])
1819
VERSION >= v"1.9" &&
19-
@test_warn "The `tree(X; kws...)` syntax is deprecated" tree'([1.0; 2.0;;])
20+
@test_logs (:warn, r"The `tree'\(X; kws...\)` syntax is deprecated.*") tree'(
21+
[1.0; 2.0;;]
22+
)
2023
end

test/test_evaluation.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ end
170170
return x^2
171171
end for i in 1:num_ops]
172172
operators = if VERSION >= v"1.9"
173-
@test_warn "You have passed over 15 binary" OperatorEnum(;
173+
@test_logs (:warn, r"You have passed over 15 binary.*") OperatorEnum(;
174174
binary_operators, unary_operators
175175
)
176176
else
@@ -183,7 +183,9 @@ end
183183
@test truth tree(X, operators)
184184

185185
VERSION >= v"1.9" &&
186-
@test_warn "You have passed over 15 unary" OperatorEnum(; unary_operators)
186+
@test_logs (:warn, r"You have passed over 15 unary.*") OperatorEnum(;
187+
unary_operators
188+
)
187189

188190
# This OperatorEnum will trigger the fallback code for fast compilation.
189191
many_ops_operators = OperatorEnum(;

0 commit comments

Comments
 (0)