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

Upgrading JSON IO tests to the new API, and removing the deprecated API #2104

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Dec 18, 2024

  • roundtripping tests now use the new functions asJSON, parseJSON, readJSON and writeJSON
  • implemented roundtripping of datetime values by reusing features from the DateTime module
  • removed old toJSON and fromJSON functions (had been deprecated for 8 years) from lang::json::IO and removed their respective implementation classes in lang/json/io/internal
  • fixed roundtripping of rational numbers by encoding them as arrays of 2 integers
  • fixed roundtripping of node values by encoding their name as a _name field of the object.
  • fixed roundtripping with num
  • fixed roundtripping of sets, maps and tuples when the expected type is value by normalizing the expected values to the defaults that are chosen when no more specific type is requested
  • added syntax for empty tuple expressions and empty tuple patterns because empty tuples are generated by QuickCheck
  • nodes with field names that can't become (or could never have been) typescript or javascript object names are read back as maps
  • normalization for all ambiguous JSON objects is complete: maps, objects, sets, lists. This makes it easy to test the asJSON/parseJSON pair for abstract expected types like num, value and node
  • added documentation on the bi-directionality of asJSON, parseJSON and readJSON, writeJSON
  • all tests succeed

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 71.73913% with 13 lines in your changes missing coverage. Please review.

Project coverage is 49%. Comparing base (cfc601c) to head (dea3dd5).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...interpreter/utils/IUPTRAstToSymbolConstructor.java 0% 7 Missing ⚠️
...pl/library/lang/json/internal/JsonValueReader.java 81% 1 Missing and 2 partials ⚠️
...pl/library/lang/json/internal/JsonValueWriter.java 85% 2 Missing ⚠️
src/org/rascalmpl/ast/Expression.java 83% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##              main   #2104    +/-   ##
========================================
  Coverage       49%     49%            
+ Complexity    6336    6233   -103     
========================================
  Files          667     663     -4     
  Lines        59836   59177   -659     
  Branches      8692    8615    -77     
========================================
- Hits         29718   29469   -249     
+ Misses       27868   27480   -388     
+ Partials      2250    2228    -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have a few small concerns, but I'm very happy to see a whole bunch of old code get cleaned up 👍🏼

@@ -96,8 +96,17 @@ dup([3, 1, 5, 3, 1, 7, 1, 2]);
list[&T] dup(list[&T] lst)
= ([] | (ix in it) ? it : it + [ix] | &T ix <- lst);

@deprecated{Use a list index instead}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it undeprecated? don't we want to reduce the API size?

Copy link
Member Author

@jurgenvinju jurgenvinju Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I received feedback that people want to keep this function. I was trying to make this PR have fewer warnings in the stdlib so that's why this snuck in there.

It's still strange to me that the declaration of a deprecated function leads to a warning on the declaration side btw. There is nothing wrong with a deprecated declaration. It's the uses which need a warning.

src/org/rascalmpl/library/List.rsc Show resolved Hide resolved
}
else {
throw new IOException("Dates as strings not yet implemented: " + format.get().toPattern());
try {
com.ibm.icu.text.SimpleDateFormat sd = format.get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not use java time for this? since java8 it's been really a nice API, and I would love to reduce our dependency on icu for date time stuff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but this semantics has to remain consistent with the DateTime module for now. When we move to java time, we move it all. There are so many subtleties in this stuff that I don't want to multiply the confusion.

@jurgenvinju
Copy link
Member Author

I want to increase the test coverage a bit before merging this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants