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

Ensures macros can be evaluated from both byte array and InputStream sources. #956

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Oct 3, 2024

Description of changes:
RC2 focused on byte array inputs. This PR adds testing for InputStream inputs (which are handled slightly differently in some cases by the binary reader), and includes a fix to IonCursorBinary to make the tests pass.

Before this fix, some of the tests would fail because the cursor's checkpoint was not advanced after reading a macro invocation header, causing the header to be read repetitively.

This PR also includes some minor cleanups that somehow didn't make it into the final revision of my previous PR.

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

@tgregg tgregg requested review from jobarr-amzn and popematt October 3, 2024 22:52
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 attempted to add the changes in this file to #954; I think I forgot to commit the additional changes after the file move was automatically staged by Git.

@@ -2497,6 +2497,7 @@ private boolean slowReadMacroInvocationHeader(IonTypeID valueTid, Marker markerT
macroInvocationId = valueTid.macroId;
}
setUserMacroInvocationMarker(valueTid, markerToSet, -1);
setCheckpoint(CheckpointLocation.BEFORE_UNANNOTATED_TYPE_ID);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix that allows InputStreams to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More changes related to the move of EncodingDirectiveReader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive-by change, see #953 (comment)

public void structAsParameter() throws Exception {
@ParameterizedTest
@EnumSource(InputType.class)
public void structAsParameter(InputType inputType) throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an example of a test that failed for InputType.INPUT_STREAM before the fix in IonCursorBinary.

@tgregg tgregg merged commit b8d9476 into ion-11-encoding Oct 3, 2024
17 checks passed
@tgregg tgregg deleted the ion-11-encoding-test-input-types branch October 3, 2024 23:29
Comment on lines +13 to 19
* Reads encoding directives from the given [IonReader]. This performs a similar function to
* IonReaderContinuableCoreBinary.EncodingDirectiveReader, though that one requires more logic to handle continuable
* input. The two could be unified at the expense of higher complexity than is needed by the non-continuable text
* implementation. If the text reader is replaced with a continuable implementation in the future,
* IonReaderContinuableCoreBinary.EncodingDirectiveReader should be moved to the top level and shared by both readers.
* If that were to happen, this class would no longer be needed.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of comment is so valuable, thanks!

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.

3 participants