Skip to content

Test expressions across modules, fix two error messages - #64

Merged
tkittel merged 1 commit into
mctools:mainfrom
tkittel:expression-tests
Nov 8, 2026
Merged

tkittel merged 1 commit into
mctools:mainfrom
tkittel:expression-tests

Conversation

@tkittel

@tkittel tkittel commented Nov 7, 2026

Copy link
Copy Markdown
Member

Adds the test G4MCPLTests/testexpressions, which gives valid and invalid
expressions to all places in dgcode where users can provide them:

  • MCPLGen (input_filter)
  • MCPLWriter (--mcpl, with "where" and "withflags")
  • the heat map writer (--heatmap, quantity and "where")
  • the sb_mcplextra_filterfile and sb_mcplextra_filterview commands

Valid expressions cover bool, integer, floating point and string values.
Invalid expressions cover syntax errors, unknown variables and domain
errors (e.g. division by zero), and must give a clean error message rather
than a crash.

The expressions are parsed in the ExprParser libraries, but the errors are
caught in Python modules. The test therefore checks that the ExprParser
exceptions can be caught across modules, which is what failed on Intel
macOS, where type information is compared by address. The Intel macOS CI
job now runs this test.

The test found two small bugs, which are also fixed:

  • The error message for an invalid quantity expression of the heat map
    writer showed the filter expression instead of the quantity expression.
  • Typo in the MCPLWriter error message for invalid user flag expressions.

assisted-by: claude

New test G4MCPLTests/testexpressions: valid expressions of various value types
(bool, integer, floating point, string) and invalid ones (syntax errors,
unknown variables, domain errors) given to MCPLGen, MCPLWriter (--mcpl), the
heat map writer (--heatmap) and the sb_mcplextra_filterfile and
sb_mcplextra_filterview commands. The expressions are parsed in the ExprParser
libraries, but used in Python modules, so this tests that the ExprParser
exceptions can be caught across modules, also on Intel macOS (where type
information is compared by address), rather than crashing.

Also fix the error message for invalid quantity expressions of the heat map
writer (it showed the filter expression), and a typo in the error message for
invalid user flag expressions of MCPLWriter.

Assisted-by: Claude
@tkittel
tkittel merged commit 019c806 into mctools:main Nov 8, 2026
24 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant