Skip to content

Commit

Permalink
test: error messages for missing arg
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Dec 26, 2024
1 parent 26d9b01 commit df552fd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test_parametric_template_expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ end
)
end

@testitem "check_combiner_applicability errors" begin
using SymbolicRegression

bad_combiner1 = ((; f), x) -> f(x[1])
@test_throws (
"Your template structure's `combine` function must accept\n" *
"\t1. A `NamedTuple` of `ComposableExpression`s (or `ArgumentRecorder`s)\n" *
"\t2. A tuple of `ValidVector`s\n" *
"\t3. A `ParamVector`"
) TemplateStructure{(:f,)}(bad_combiner1; num_parameters=1)
# Your template structure's `combine` function must accept\n\t1. A `NamedTuple` of `ComposableExpression`s (or `ArgumentRecorder`s)\n\t2. A tuple of `ValidVector`s\n\t3. A `ParamVector`

# Test error when combiner doesn't accept parameters when it should
bad_combiner2 = ((; f), (x,), p) -> f(x) # Missing param argument
@test_throws (
"Your template structure's `combine` function must accept\n" *
"\t1. A `NamedTuple` of `ComposableExpression`s (or `ArgumentRecorder`s)\n" *
"\t2. A tuple of `ValidVector`s"
) TemplateStructure{(:f,)}(bad_combiner2)
end

@testitem "basic evaluation" begin
using SymbolicRegression

Expand Down

0 comments on commit df552fd

Please sign in to comment.