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

toJSON and fromJSON were deprecated and replaced by asJSON and parseJSON but the new functions do not pass the tests. #2086

Open
jurgenvinju opened this issue Nov 23, 2024 · 0 comments
Assignees
Labels

Comments

@jurgenvinju
Copy link
Member

Describe the bug

If we replace:

bool writeRead(type[&T] returnType, &T dt) {
    if (!jsonFeaturesSupported(dt)) {
        return true;
    }
    json = toJSON(dt);
    return fromJSON(returnType, json) == dt;
}

by the newer:

bool writeRead(type[&T] returnType, &T dt) {
    if (!jsonFeaturesSupported(dt)) {
        return true;
    }
    json = asJSON(dt);
    return parseJSON(returnType, json) == dt;
}

We get this:

rascal>:test
Running tests for lang::rascal::tests::library::lang::json::JSONIOTests
Warning: selecting arbitrary constructor for Enum                                           
- testing 6/22 failure: jsonWithNode1 @ |file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc|(1516,57,<47,0>,<47,57>)
Test lang::rascal::tests::library::lang::json::JSONIOTests::jsonWithNode1 failed due to
        test returned false

Actual parameters:
        node =>"4"("uO","UeJG")


- testing 11/22 failure: jsonRandom1 @ |file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc|(1696,56,<52,0>,<52,56>)
Test lang::rascal::tests::library::lang::json::JSONIOTests::jsonRandom1 failed due to
        test returned false

Actual parameters:
        value =><"">


- testing 15/22 error: jsonWithDatetime1 @ |file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc|(1243,68,<43,0>,<43,68>)
        /Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/json/IO.rsc:73,0: IO("Dates as strings not yet implemented: yyyy-MM-dd\'T\'HH:mm:ssZZZZZ")
        at *** somewhere ***(|file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/json/IO.rsc|(4673,442,<73,0>,<78,240>))
        at asJSON(|file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/json/IO.rsc|(5108,5,<78,233>,<78,238>))
        at jsonWithDatetime1(|file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc|(1243,68,<43,0>,<43,68>))
        at $shell$(|main://$shell$|)
\ testing 21/22 failure: jsonWithNum1 @ |file:///Users/jurgenv/git/rascal/src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc|(1080,53,<39,0>,<39,53>)
Test lang::rascal::tests::library::lang::json::JSONIOTests::jsonWithNum1 failed due to
        test returned false

Actual parameters:
        num =>0.0


Test report for lang::rascal::tests::library::lang::json::JSONIOTests
        18/22 tests succeeded
        3/22 tests failed
        1/22 tests threw exceptions
bool: false
@jurgenvinju jurgenvinju self-assigned this Nov 23, 2024
@jurgenvinju jurgenvinju changed the title toJSON and fromJSON were deprecated and replaced by asJSON and parseJSON but the new functions to not pass the tests. toJSON and fromJSON were deprecated and replaced by asJSON and parseJSON but the new functions do not pass the tests. Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant