Commit 2a26c32
Improved error message for one assert function
> What's the problem?
If the user makes a mistake in the `assert_error_msg_content_equals`:
t.assert_error_msg_content_equals("bad", error, "foo:1: bar")
where:
"bad" - expected error message
error - built-in function (there may be another function here)
"foo:1: bar" - argument for the function
then the following error will be returned:
Error message expected: "bad"
Error message received: "foo:1: bar"
The user thinks that a comparison is being made between `foo:1: bar` and
`bad` strings. He notices this error and at the same time can write the
following:
t.assert_error_msg_content_equals("foo:1: bar", error, "foo:1: bar")
Now he will get the following error:
Error message expected: "foo:1: bar"
Error message received: "foo:1: bar"
It seems that the function doesn't work cause these strings are equal.
In fact, a comparison will be performed between `foo:1: bar` (expected)
and `bar` (actual, because `foo:1:` will be dropped from the error
message by regex).
The next use of the function will be correct:
t.assert_error_msg_content_equals("bar", error, "foo:1: bar")
> What's the solution?
It is necessary to save the result of conversion after the `gsub`. So
this way the user will see the actual strings that are being compared:
t.assert_error_msg_content_equals("bad", error, "foo:1: bar")
Error message expected: "bad"
Error message received: "bar"
Close #3161 parent 9c7710e commit 2a26c32
2 files changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
| 475 | + | |
| 476 | + | |
476 | 477 | | |
477 | 478 | | |
478 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments