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

Improves the factoring of IonReaderContinuableTopLevelBinaryTest.java. #607

Closed

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Oct 13, 2023

Issue #, if available:

Addresses #428 (along with #604 and #605).

Description of changes:

Implements the technique agreed upon in this template and applied to IonCursorBinaryTest, IonReaderContinuableCoreBinaryTest, and IonReaderContinuableApplicationBinaryTest in #604.

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

@tgregg tgregg requested a review from jobarr-amzn October 13, 2023 02:26
Comment on lines 305 to 313
static ExpectationProvider<IonReaderContinuableTopLevelBinary> next(IonType expectedType) {
return consumer -> consumer.accept(new Expectation<>(
String.format("next(%s)", expectedType),
reader -> assertEquals(expectedType, reader.next()))
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this subsume the type check as well? Should it not always be the case that whatever type is yielded by reader.next() should also be then yielded by reader.getType()? Then you wouldn't have to repeat yourself below with e.g. next(IonType.LIST), type(IonType.LIST), ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll add the reader.getType() assertion here and remove any usages of type(...) that immediately follow a call to next(...). type(...) is still used in several cases where reader.next() is not desired, such as when asserting that stepping into / out of a container clears the type or that parsing a scalar value does not clear the type.

Comment on lines +698 to +704
next(IonType.SYMBOL), stringValue("abc"),
next(IonType.SYMBOL), stringValue("def"),
next(IonType.SYMBOL), stringValue("purple"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use symbolValue(...)? Same elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stringValue and symbolValue test different reader APIs. IonReader.stringValue is applicable to both symbols and strings, so we test it for both. IonReader.symbolValue is applicable only to symbols.

Comment on lines 2614 to 2616
expectOversized(0);
nextExpect(IonType.STRING);
assertSequence(next(IonType.STRING));
expectOversized(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the oversized counter can be decremented? Otherwise, is it just as strong to assert 0 at the end so that you don't have to break this into two sequences?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm guessing I added assertions at several points during development while trying to get this to pass, and it survived the restructuring. I'll simplify into one assertion sequence with a single assertion at the end.

@tgregg tgregg force-pushed the reentrant-reader-base-pr33 branch from c101027 to e01b348 Compare October 17, 2023 23:02
@tgregg tgregg closed this in #615 Oct 18, 2023
@tgregg tgregg deleted the reentrant-reader-base-pr33 branch January 16, 2024 19:29
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