Skip to content

Commit

Permalink
tests: use value and the .len field, for the left/right values, sho…
Browse files Browse the repository at this point in the history
…wn in failing assertions (#22393)
  • Loading branch information
spytheman authored Oct 2, 2024
1 parent 2b546c4 commit dafca93
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions vlib/v/preludes/test_runner_normal.v
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ fn (mut runner NormalTestRunner) assert_fail(i &VAssertMetaInfo) {
}
eprintln('${final_filepath} ${final_funcname}')
if i.op.len > 0 && i.op != 'call' {
mut lvtitle := ' Left value:'
mut rvtitle := ' Right value:'
mut slvalue := '${i.lvalue}'
mut srvalue := '${i.rvalue}'
mut lvtitle := ' Left value (len: ${i.lvalue.len}):'
mut rvtitle := ' Right value (len: ${i.rvalue.len}):'
mut slvalue := '`${i.lvalue}`'
mut srvalue := '`${i.rvalue}`'
// Do not print duplicate values to avoid confusion. In mosts tests the developer does
// `assert foo() == [1, 2, 3]`
// There's no need to print "[1, 2, 3]" again (left: [1,2,3,4] right:[1,2,3])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vlib/v/tests/skip_unused/assert_with_extra_message_works_test.vv:7: fn test_interpolation_with_assert_that_has_extra_message
> assert 'abc$i' != 'abc77', my_failure_message(i)
Left value: abc77
Right value: abc77
Left value (len: 5): `abc77`
Right value (len: 5): `abc77`
Message: the assert failed :-|, i: 77

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vlib/v/tests/skip_unused/assert_with_extra_message_works_test.vv:7: fn test_interpolation_with_assert_that_has_extra_message
> assert 'abc$i' != 'abc77', my_failure_message(i)
Left value: abc77
Right value: abc77
Left value (len: 5): `abc77`
Right value (len: 5): `abc77`
Message: the assert failed :-|, i: 77

4 changes: 2 additions & 2 deletions vlib/v/tests/skip_unused/assert_works_test.run.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vlib/v/tests/skip_unused/assert_works_test.vv:2: fn test_abc
> assert 'abc' == 'xyz'
Left value: abc
Right value: xyz
Left value (len: 3): `abc`
Right value (len: 3): `xyz`

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vlib/v/tests/skip_unused/assert_works_test.vv:2: fn test_abc
> assert 'abc' == 'xyz'
Left value: abc
Right value: xyz
Left value (len: 3): `abc`
Right value (len: 3): `xyz`

0 comments on commit dafca93

Please sign in to comment.