Skip to content

Commit

Permalink
CAST: Improve the CAST assertion assertEval (#523)
Browse files Browse the repository at this point in the history
Improve the CAST assertion assertEval with removing a redundant
assertion for permissive mode since we already run tests for this
mode as part of the overall process.

Issue #, if available: 519

Description of changes: Parameterize the error message.
  • Loading branch information
am357 authored Feb 9, 2022
1 parent 9af595e commit 271158d
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lang/test/org/partiql/lang/eval/EvaluatorTestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,9 @@ abstract class EvaluatorTestBase : TestBase() {
val originalExprNode = parser.parseExprNode(source)

fun evalAndAssert(exprNodeToEvaluate: ExprNode, message: String) {
// LEGACY mode
val result = eval(exprNodeToEvaluate, compileOptions, session, compilerPipelineBuilderBlock)
AssertExprValue(result, message = "(LEGACY mode) Evaluated '$source' with evaluator ($message)")
.apply { assertIonValue(expectedIon) }.run(block)
// TODO this should not be here--this should be explicit in the test case
// PERMISSIVE mode
val resultForPermissiveMode = eval(
exprNodeToEvaluate,
CompileOptions.builder(compileOptions).typingMode(TypingMode.PERMISSIVE).build(),
session,
compilerPipelineBuilderBlock
)
AssertExprValue(resultForPermissiveMode, message = "(PERMISSIVE mode) Evaluated '$source' with evaluator ($message)")
.apply { assertIonValue(expectedIon) }.run(block)
AssertExprValue(eval(exprNodeToEvaluate, compileOptions, session, compilerPipelineBuilderBlock),
message = "${compileOptions.typedOpBehavior} CAST in ${compileOptions.typingMode} typing mode, " +
"evaluated '$source' with evaluator ($message)").apply { assertIonValue(expectedIon) }.run(block)
}

// Evaluate the ExprNodes originally obtained from the parser
Expand Down

0 comments on commit 271158d

Please sign in to comment.