JuliaData / YAML.jl

Parse yer YAMLs
Other
131 stars 46 forks source link

A test `windows_newlines` seems wrong #207

Open Paalon opened 4 months ago

Paalon commented 4 months ago

From #188. I found prefix(::BufferedInput, ::Integer) has a bug and if I fixed it, the test windows_newlines fails. Also, better implementation in #188's TODO fails at the same test. I think the test windows_newlines is something wrong.

Paalon commented 4 months ago

The content:

julia> str = read("test/windows_newlines.data", String)
"hello:\r\0\r"
Paalon commented 4 months ago

Loading result of windows_newlines from http://ben-kiki.org/ypaste/cgi-bin/ypaste.pl

スクリーンショット 2024-06-17 18 54 00

Paalon commented 4 months ago

So the test should be fixed.

Paalon commented 4 months ago

I don't know why only 2 tests are failed. スクリーンショット 2024-06-17 19 07 22

Paalon commented 4 months ago

It's strange to use hello:\r\0\r to test for Windows. It should be hello:\r\n\r.

Paalon commented 4 months ago

I asked this in YAML community, and the file hello:\r\0\r is malformed. We should fail this even for load_all_file and load_file and load but only load_all fails. Hmm, why?

GunnarFarneback commented 4 months ago

This test file was added when #17 was fixed. I think it was just supposed to be hello:\r\n but ended up differently.

Paalon commented 4 months ago

211 fixes this.

GunnarFarneback commented 4 months ago

We should fail this even for load_all_file and load_file and load but only load_all fails. Hmm, why?

It's probably incorrect, but \0 is basically parsed like \n..., so this document is like hello:\r\n...\r. load_all fails because the second document has no content, which is known to be handled badly. load_file and load work because they stop after the first document. load_all_file works thanks to the bug pointed out in #120. YAMLDocIterator loads the first document on construction, and the second document when the first is retrieved. Due to the input file being prematurely closed, it never tries to load the second document as the closed input signals eof.

kescobo commented 4 months ago

is this closed by #218 ?