Skip to content

Commit

Permalink
ErrorMessagesSpec: make failures easier to read
Browse files Browse the repository at this point in the history
Old output of `sbt test`:

```
ErrorMessagesSpec:
- attr_invalid_switch_inner *** FAILED ***
  attr_invalid_switch_inner.ksy: /seq/1/size:
  	error: invalid type: expected integer, got CalcBooleanType

  attr_invalid_switch_inner.ksy: /seq/1/size:
  	error: invalid type: expected integer, got CalcBooleanType
   did not equal attr_invalid_switch_inner.ksy: /seq/1/size:
  	error: invalid type: expected integer, got CalcBooleanType (SimpleMatchers.scala:34)
```

New output of `sbt test`:

```
ErrorMessagesSpec:
- attr_invalid_switch_inner *** FAILED ***
  [attr_invalid_switch_inner.ksy: /seq/1/size:
         error: invalid type: expected integer, got CalcBooleanType

  attr_invalid_switch_inner.ksy: /seq/1/size:
         error: invalid type: expected integer, got CalcBooleanType
  ]
    did not equal
  [attr_invalid_switch_inner.ksy: /seq/1/size:
         error: invalid type: expected integer, got CalcBooleanType
  ] (SimpleMatchers.scala:34)
```
  • Loading branch information
generalmimon committed Mar 22, 2024
1 parent e31f147 commit f93fa66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jvm/src/test/scala/io/kaitai/struct/SimpleMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait SimpleMatchers {
def shouldEqualPlainly(right: Any)(implicit equality: Equality[T]): Assertion =
if (!equality.areEqual(leftSideValue, right)) {
throw new exceptions.TestFailedException(
(e: exceptions.StackDepthException) => Some(s"""${leftSideValue} did not equal ${right}"""),
(e: exceptions.StackDepthException) => Some(s"""[${leftSideValue}]\n did not equal\n[${right}]"""),
None,
Position.here
)
Expand Down

0 comments on commit f93fa66

Please sign in to comment.