Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure of NST JSONTestSuite optional tests #267

Open
samoconnor opened this issue Nov 5, 2018 · 0 comments
Open

Failure of NST JSONTestSuite optional tests #267

samoconnor opened this issue Nov 5, 2018 · 0 comments

Comments

@samoconnor
Copy link

I've modified the LazyJSON tests so that they also apply the NST JSONTestSuite to JSON.jl and JSON2.jl: https://github.com/samoconnor/LazyJSON.jl/blob/master/test/runtests.jl#L360-L362

The JSONTestSuite defines these tests as class "i" which means that parsers may choose to reject them as invalid. As it stands JSON.jl throws an error for these tests, which is an acceptable result. However, it might be better to support these inputs.

using JSON
using LazyJSON
using Test

for (name, jparse) in [("LazyJSON", x->LazyJSON.value(x; lazy=false)), ("JSON", x->JSON.parse(x))]

    @testset "$name" begin

    # See https://github.com/nst/JSONTestSuite

    @test jparse("[123.456e-789]") == Any[BigFloat("1.23456e-787")] # i_number_double_huge_neg_exp.json
    @test jparse("[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]") == Any[Inf] # i_number_huge_exp.json
    @test jparse("[-1e+9999]") == Any[BigFloat("-1.0e+9999")]
    @test jparse("[1.5e+9999]") == Any[BigFloat("1.5e+9999")]
    @test jparse("[-123123e100000]") == Any[BigFloat("-123123e100000")]
    @test jparse("[123123e100000]") == Any[BigFloat("123123e100000")]
    @test jparse("[123e-10000000]") == Any[BigFloat("123e-10000000")]
    @test jparse("{\"\\uDFAA\":0}") == Dict("\udfaa"=>0) # i_object_key_lone_2nd_surrogate.json
    @test jparse("[\"\\uDADA\"]") == Any["\udada"] # i_string_1st_surrogate_but_2nd_missing.json
    @test jparse("[\"\\uD800\\n\"]") == Any["\ud800\n"] # i_string_incomplete_surrogate_and_escape_valid.json
    @test jparse("[\"\\uDd1ea\"]") == Any["\udd1ea"] # i_string_incomplete_surrogate_pair.json
    @test jparse("[\"\\ud800\"]") == Any["\ud800"] # i_string_invalid_lonely_surrogate.json
    @test jparse("[\"\\ud800abc\"]") == Any["\ud800abc"] # i_string_invalid_surrogate.json
    @test jparse("[\"\\uDFAA\"]") == Any["\udfaa"] # i_string_lone_second_surrogate.json

    end
end
Test Summary: | Pass  Total
LazyJSON      |   14     14

Test Summary: | Error  Total
JSON          |    14     14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant