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

Adds impl of IonSchemaReaderV2_0 and ion-schema-tests for readers #259

Merged
merged 1 commit into from
May 17, 2023

Conversation

popematt
Copy link
Contributor

Issue #, if available:

#256

Description of changes:

Adds initial, partial implementation of TypeReaderV2_0 and IonSchemaReaderV2_0, but more importantly, it sets up a test runner that can leverage ion-schema-tests for the reader implementation.

Related PRs in ion-schema, ion-schema-tests, ion-schema-schemas:

None.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@popematt popematt requested a review from jobarr-amzn May 17, 2023 18:32
@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Patch coverage: 66.66% and project coverage change: +0.72 🎉

Comparison is base (2725905) 82.02% compared to head (a3ebf57) 82.75%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #259      +/-   ##
============================================
+ Coverage     82.02%   82.75%   +0.72%     
- Complexity      717      791      +74     
============================================
  Files           104      116      +12     
  Lines          2632     3016     +384     
  Branches        524      595      +71     
============================================
+ Hits           2159     2496     +337     
- Misses          350      363      +13     
- Partials        123      157      +34     
Impacted Files Coverage Δ
...om/amazon/ionschema/internal/util/Preconditions.kt 9.09% <0.00%> (-1.17%) ⬇️
...com/amazon/ionschema/reader/IonSchemaReaderV2_0.kt 33.33% <33.33%> (ø)
...amazon/ionschema/reader/internal/TypeReaderV2_0.kt 47.61% <47.61%> (ø)
...ma/reader/internal/constraints/FieldNamesReader.kt 100.00% <100.00%> (ø)
.../reader/internal/constraints/Ieee754FloatReader.kt 100.00% <100.00%> (ø)
...nschema/reader/internal/constraints/RegexReader.kt 100.00% <100.00%> (ø)
...otlin/com/amazon/ionschema/reader/internal/util.kt 20.00% <100.00%> (+20.00%) ⬆️

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

private val typeReader = TypeReaderV2_0()

override fun readSchema(document: List<IonValue>, failFast: Boolean): IonSchemaResult<SchemaDocument, List<ReadError>> {
TODO()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ To be clear, this intentionally not a complete implementation yet (in order to keep PR sizes smaller).

@ExperimentalIonSchemaModel
class ReaderTests {

val unimplementedConstraints = listOf(

Choose a reason for hiding this comment

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

Would this be easier as a positive list rather than a negative one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so... this list is going to be shrinking with every PR I send, and will eventually be gone entirely.

val dynamicNodeTestCases = dg.mapNotNull { ion ->
// The reader is a little more sophisticated than ISL for ISL, but it cannot detect problems with
// duplicate type names or imports.
if (ion !is IonStruct || !ion.islForIslCanValidate()) return@mapNotNull null

Choose a reason for hiding this comment

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

The islForIslCanValidate() extension function feels strange to me? I'm getting unpleasant flashbacks of Ruby monkey-patching. I understand that Kotlin extensions are much better than monkey-patching etc. etc.

Looking at the definition of the method though, it makes sense... 🤷 . Nothing to do here.

@popematt popematt merged commit 3874427 into amazon-ion:master May 17, 2023
@popematt popematt deleted the read-impl-type branch May 17, 2023 22:57
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

Successfully merging this pull request may close these issues.

2 participants