Closed UlyssesZh closed 10 months ago
@UlyssesZh Thanks for reporting this issue, I am finishing my vacation and I will get back to this next week!
Sorry for the late response!
@UlyssesZh I think the problem is that you are using puts
, because TomlRB.dump
is working as expected.
Check the PR I opened above, and see the tests passing.
Please let me know if I'm missing something, or provide more information about your environment (gem version, ruby version, os, etc.)
The test is wrong.
When the hash key is '\t'
, it means that it is literally a backslash and a t
. This corresponds to "\\t"
as written in TOML. However, in the percent string you wrote "\\t"
, which is actually "\t"
(because percent string can escape). You should modify the test to "\\\\t"
.
Written | Literal result |
---|---|
'\t' |
\t |
"\\t" |
\t |
%("\\t") |
"\t" |
%("\\\\t") |
"\\t" |
Look at (4,2) and (2,1). They are the same, so in the test you should write (4,1).
Or, you may just use single quote instead of percent string if you are unsure how it escapes.
Also, there is nothing wrong in using puts
because it prints a string just as how it will be written in a file. If the result of puts
is wrong, then the result when the TOML is written in a file is wrong.
Expected:
Got: