Skip to content

Commit

Permalink
test: Adjust expected failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
saig0 committed Sep 18, 2023
1 parent 925f241 commit 5ae2a19
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,48 @@ class SuppressedFailuresTest extends AnyFlatSpec
it should "report a suppressed failure if input is not comparable with interval" in {
evaluateUnaryTests("[2..5]", "NaN") should reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValString(NaN) with ValNumber(2) and ValNumber(5)"
failureMessage = """Can't compare '"NaN"' with '2' and '5'"""
)
}

it should "report a suppressed failure if values are not comparable" in {
evaluateExpression("true < 2") should reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValBoolean(true) with ValNumber(2)"
failureMessage = "Can't compare 'true' with '2'"
)
}

it should "report a suppressed failure if an addition has incompatible values" in {
evaluateExpression("2 + true") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Number but found 'ValBoolean(true)'"
failureMessage = "Expected number but found 'true'"
)
}

it should "report a suppressed failure if a condition is not a boolean" in {
evaluateExpression("if 5 then 1 else 2") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Boolean but found 'ValNumber(5)'"
failureMessage = "Expected boolean but found '5'"
)

evaluateExpression("true and 2") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Boolean but found 'ValNumber(2)'"
failureMessage = "Expected boolean but found '2'"
)

evaluateExpression("false or 3") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Boolean but found 'ValNumber(3)'"
failureMessage = "Expected boolean but found '3'"
)

evaluateExpression("some x in [false, 2] satisfies x") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Boolean but found 'ValNumber(2)'"
failureMessage = "Expected boolean but found '2'"
)

evaluateExpression("every x in [true, 3] satisfies x") should reportFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Boolean but found 'ValNumber(3)'"
failureMessage = "Expected boolean but found '3'"
)
}

Expand All @@ -107,7 +107,7 @@ class SuppressedFailuresTest extends AnyFlatSpec
),
EvaluationFailure(
failureType = EvaluationFailureType.INVALID_TYPE,
failureMessage = "Expected Number but found 'ValNull'"
failureMessage = "Expected number but found 'null'"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ class ComparisonTypeTest extends AnyFlatSpec
it should "return null if the values have a different type" in {
evaluateExpression("1 = true") should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValNumber(1) with ValBoolean(true)"
failureMessage = "Can't compare '1' with 'true'"
))

evaluateExpression(""" 1 = "a" """) should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValNumber(1) with ValString(a)"
failureMessage = """Can't compare '1' with '"a"'"""
))

evaluateExpression(""" 1 = @"P1D" """) should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValNumber(1) with P1D"
failureMessage = "Can't compare '1' with 'P1D'"
))
}

Expand All @@ -84,12 +84,12 @@ class ComparisonTypeTest extends AnyFlatSpec
it should "return null if the values have a different type" in {
evaluateExpression("1 < true") should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValNumber(1) with ValBoolean(true)"
failureMessage = "Can't compare '1' with 'true'"
))

evaluateExpression(""" 1 > @"P1D" """) should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValNumber(1) with P1D"
failureMessage = "Can't compare '1' with 'P1D'"
))
}

Expand All @@ -113,12 +113,12 @@ class ComparisonTypeTest extends AnyFlatSpec
it should "return null if the values have a different type" in {
evaluateUnaryTests(expression = "1", inputValue = true) should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValBoolean(true) with ValNumber(1)"
failureMessage = "Can't compare 'true' with '1'"
))

evaluateUnaryTests(expression = "1", inputValue = "a") should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValString(a) with ValNumber(1)"
failureMessage = """Can't compare '"a"' with '1'"""
))
}

Expand All @@ -134,12 +134,12 @@ class ComparisonTypeTest extends AnyFlatSpec
it should "return null if the values have a different type" in {
evaluateUnaryTests(expression = "< 1", inputValue = true) should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValBoolean(true) with ValNumber(1)"
failureMessage = "Can't compare 'true' with '1'"
))

evaluateUnaryTests(expression = "> 1", inputValue = "a") should (returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValString(a) with ValNumber(1)"
failureMessage = """Can't compare '"a"' with '1'"""
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DateTimeDurationPropertiesTest
evaluateExpression(""" date("2020-09-30").seconds """) should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NO_PROPERTY_FOUND,
failureMessage = "No property found with name 'seconds' of value 'ValDate(2020-09-30)'. Available properties: 'year', 'month', 'day', 'weekday'"
failureMessage = "No property found with name 'seconds' of value '2020-09-30'. Available properties: 'year', 'month', 'day', 'weekday'"
)
)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ class DateTimeDurationPropertiesTest
evaluateExpression(""" time("11:45:30+02:00").day """) should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NO_PROPERTY_FOUND,
failureMessage = "No property found with name 'day' of value 'ValTime(ZonedTime(11:45:30,+02:00,None))'. Available properties: 'timezone', 'second', 'time offset', 'minute', 'hour'"
failureMessage = "No property found with name 'day' of value '11:45:30+02:00'. Available properties: 'timezone', 'second', 'time offset', 'minute', 'hour'"
)
)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ class DateTimeDurationPropertiesTest
evaluateExpression(""" time("11:45:30").day """) should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NO_PROPERTY_FOUND,
failureMessage = "No property found with name 'day' of value 'ValLocalTime(11:45:30)'. Available properties: 'timezone', 'second', 'time offset', 'minute', 'hour'"
failureMessage = "No property found with name 'day' of value '11:45:30'. Available properties: 'timezone', 'second', 'time offset', 'minute', 'hour'"
)
)
}
Expand Down Expand Up @@ -214,7 +214,7 @@ class DateTimeDurationPropertiesTest
evaluateExpression(""" date and time("2020-09-30T22:50:30+02:00").days """) should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NO_PROPERTY_FOUND,
failureMessage = "No property found with name 'days' of value 'ValDateTime(2020-09-30T22:50:30+02:00)'. Available properties: 'timezone', 'year', 'second', 'month', 'day', 'time offset', 'weekday', 'minute', 'hour'"
failureMessage = "No property found with name 'days' of value '2020-09-30T22:50:30+02:00'. Available properties: 'timezone', 'year', 'second', 'month', 'day', 'time offset', 'weekday', 'minute', 'hour'"
)
)
}
Expand Down Expand Up @@ -275,7 +275,7 @@ class DateTimeDurationPropertiesTest
evaluateExpression(""" date and time("2020-09-30T22:50:30").days """) should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NO_PROPERTY_FOUND,
failureMessage = "No property found with name 'days' of value 'ValLocalDateTime(2020-09-30T22:50:30)'. Available properties: 'timezone', 'year', 'second', 'month', 'day', 'time offset', 'weekday', 'minute', 'hour'"
failureMessage = "No property found with name 'days' of value '2020-09-30T22:50:30'. Available properties: 'timezone', 'year', 'second', 'month', 'day', 'time offset', 'weekday', 'minute', 'hour'"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class InterpreterContextExpressionTest
evaluateExpression("{} = 1") should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValContext() with ValNumber(1)"
failureMessage = "Can't compare '{}' with '1'"
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class InterpreterFunctionTest
returnNull() and
reportFailure(
failureType = EvaluationFailureType.FUNCTION_INVOCATION_FAILURE,
failureMessage = "Failed to invoke function 'number': Illegal arguments: List(ValNull)")
failureMessage = "Failed to invoke function 'number': Illegal arguments: 'null'")
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class InterpreterListExpressionTest
evaluateExpression("[] = 1") should (
returnNull() and reportFailure(
failureType = EvaluationFailureType.NOT_COMPARABLE,
failureMessage = "Can't compare ValList(List()) with ValNumber(1)"
failureMessage = "Can't compare '[]' with '1'"
))
}

Expand Down

0 comments on commit 5ae2a19

Please sign in to comment.