-
Notifications
You must be signed in to change notification settings - Fork 110
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
Support for macro table appends in binary 1.1 reader #978
Labels
Comments
Partially fixed by #976, but now this test fails: @ParameterizedTest(name = "{0},{1}")
@MethodSource("allCombinations")
public void macroAppendWithoutMacros(InputType inputType, StreamType streamType) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IonRawWriter_1_1 writer = streamType.newWriter(out);
writer.writeIVM();
SortedMap<String, Macro> macroTable = new TreeMap<>();
macroTable.put("foo", new TemplateMacro(
Collections.singletonList(new Macro.Parameter("foo", Macro.ParameterEncoding.Tagged, Macro.ParameterCardinality.ExactlyOne)),
Collections.singletonList(new Expression.VariableRef(0))
));
Map<String, Integer> symbols = Collections.emptyMap();
// $ion_encoding::(
// ( macro_table (macro foo (x) (%x) ) )
// )
startEncodingDirective(writer); {
startMacroTable(writer); {
startMacro(writer, symbols, "foo"); {
writeMacroSignature(writer, symbols, "x");
writeVariableExpansion(writer, symbols, "x");
} endMacro(writer);
} endMacroTable(writer);
} endEncodingDirective(writer);
// $ion_encoding::(
// ( macro_table $ion_encoding )
// ( symbol_table ["bar"])
// )
startEncodingDirective(writer); {
startMacroTable(writer); {
writer.writeSymbol(SystemSymbols_1_1.ION_ENCODING);
} endMacroTable(writer);
writeEncodingDirectiveSymbolTable(writer, true, "bar");
} endEncodingDirective(writer);
// (:0 $1) i.e. (:foo bar)
writer.stepInEExp(0, true, macroTable.get("foo")); {
writer.writeSymbol(1);
} writer.stepOut();
byte[] data = getBytes(writer, out);
try (IonReader reader = inputType.newReader(data)) {
assertEquals(IonType.SYMBOL, reader.next());
assertEquals("bar", reader.stringValue());
}
} |
The problem comes from this line, where |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This test case fails when added to EncodingDirectiveCompilationTest:
This is equivalent to:
The text was updated successfully, but these errors were encountered: