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

Macro implementations and conformance test fixes #1003

Merged

Conversation

popematt
Copy link
Contributor

@popematt popematt commented Nov 26, 2024

Issue #, if available:

None

Description of changes:

  • Updates ion-java to a commit of ion-tests that includes system macro and other test cases.
  • Implements the make_timestamp, delta, and sum system macros
  • Updates the repeat system macro to be aligned with the specification (i.e. allow a repeat count of 0, and allow repeating an empty stream)
  • Update all system macros to use tagged parameters
  • Conformance runner improvements:
    • Change Annot -> annot (for compliance with the spec)
    • Adds support for mactab fragments
    • Adds support for demangling E-expressions in toplevel fragments

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

}
if (parameterPresence == PresenceBitmap.GROUP) {
} else if (parameterPresence == PresenceBitmap.GROUP) {
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 was a bug I discovered that was causing + cardinality to be read incorrectly.

Comment on lines +1240 to +1242
// Add an empty expression group if nothing present.
int index = expressions.size() + 1;
expressions.add(new Expression.ExpressionGroup(index, index));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ When there's nothing there, and we're expecting a parameter, we need to create a "nothing" expression. (In this case, it's an empty expression group, but I think that there's probably a good justification for introducing a NothingExpression.)

@@ -34,6 +34,8 @@ internal class IonManagedWriter_1_1(
private val onClose: () -> Unit,
) : _Private_IonWriter, MacroAwareIonWriter {

internal fun getRawUserWriter(): IonRawWriter_1_1 = userData
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ Hack so that I can convert mangled e-expressions in a toplevel fragment into serialized data.

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 86.44068% with 16 lines in your changes missing coverage. Please review.

Please upload report for BASE (ion-11-encoding@44da868). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...n/java/com/amazon/ion/impl/macro/MacroEvaluator.kt 86.02% 5 Missing and 8 partials ⚠️
...mazon/ion/impl/IonReaderContinuableCoreBinary.java 0.00% 0 Missing and 1 partial ⚠️
.../main/java/com/amazon/ion/impl/macro/Expression.kt 50.00% 1 Missing ⚠️
...main/java/com/amazon/ion/impl/macro/SystemMacro.kt 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             ion-11-encoding    #1003   +/-   ##
==================================================
  Coverage                   ?   71.07%           
  Complexity                 ?     7213           
==================================================
  Files                      ?      204           
  Lines                      ?    28554           
  Branches                   ?     5116           
==================================================
  Hits                       ?    20294           
  Misses                     ?     6677           
  Partials                   ?     1583           

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

@@ -2348,7 +2348,7 @@ private void uncheckedReadMacroInvocationHeader(IonTypeID valueTid, Marker marke
private boolean uncheckedReadHeader(final int typeIdByte, final boolean isAnnotated, final Marker markerToSet) {
IonTypeID valueTid = typeIds[typeIdByte];
if (!valueTid.isValid) {
throw new IonException("Invalid type ID.");
throw new IonException("Invalid type ID: " + valueTid.theByte);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ Minor improvement for ease of debugging.

Comment on lines -19 to -20
@JvmStatic
fun exactlyOneFlexInt(name: String) = Parameter(name, ParameterEncoding.FlexInt, ParameterCardinality.ExactlyOne)
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 now unused now that all system macros use tagged parameters.

@@ -356,7 +356,7 @@ private fun TestCaseSupport.denotesStruct(expectation: SeqElement, reader: IonRe
private fun TestCaseSupport.denotesSymtok(expectation: AnyElement, actual: SymbolToken) {
when (expectation) {
is TextElement -> assertEquals(expectation.textValue, actual.text, createFailureMessage(expectation))
is IntElement -> assertEquals(expectation.longValue, actual.sid, createFailureMessage(expectation))
is IntElement -> assertEquals(expectation.longValue.toInt(), actual.sid, createFailureMessage(expectation))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ ...because 0 and 0L aren't equal when they are boxed, I guess.

val m = if (isQualifiedSystemMacro) SystemMacro.get(macroRef) else getMacro(macroRef)
val m = if (isQualifiedSystemMacro) SystemMacro.getMacroOrSpecialForm(macroRef) else getMacro(macroRef)
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 fixes a bug that prevented the macro compiler from recognizing special forms.

Comment on lines -23 to +25
additionalSkipFilter: (File, String) -> Boolean = { _, _ -> true }
/** A predicate that returns `true` iff the test case should be skipped. */
additionalSkipFilter: (File, String) -> Boolean = { _, _ -> false }
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 changed this because it was confusing when I went to use it for the incremental reader conformance tests.

@popematt popematt marked this pull request as ready for review December 4, 2024 01:31
@popematt popematt requested a review from tgregg December 4, 2024 01:31
// Write an expression group
writer as IonManagedWriter_1_1
val rawWriter = writer.getRawUserWriter()
rawWriter.stepInExpressionGroup(usingLengthPrefix = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need eventually need a way to exercise delimited expression groups here too...? This question is likely applicable in many places.

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 because this is a toplevel fragment, which is supposed to be encoding-agnostic. Expression groups should have full test coverage from other test cases that use text or binary fragments so that we can precisely control which text tokens or bytes are present in the encoding.

"in binary with a user macro address" in completeTestName -> false

// FIXME: Timestamp should not allow an offset of +/-1440
"the offset argument must be less than 1440" in completeTestName -> false
Copy link
Contributor

Choose a reason for hiding this comment

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

Being able to skip individual tests in a file by name is super nice.

@popematt popematt merged commit 0a17f82 into amazon-ion:ion-11-encoding Dec 4, 2024
23 of 36 checks passed
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