Skip to content

Commit

Permalink
Ensures that spans are treated as if they are at the top level even w…
Browse files Browse the repository at this point in the history
…hen hoisted from below the top level.
  • Loading branch information
tgregg committed Nov 3, 2023
1 parent 4099a5b commit 38c636a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/com/amazon/ion/impl/IonCursorBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,9 @@ void slice(long offset, long limit, String ionVersionId) {
valueMarker.endIndex = -1;
event = Event.NEEDS_DATA;
valueTid = null;
containerIndex = -1; // Slices are treated as if they were at the top level.
// Slices are treated as if they were at the top level.
parent = null;
containerIndex = -1;
if (SystemSymbols.ION_1_0.equals(ionVersionId)) {
typeIds = IonTypeID.TYPE_IDS_1_0;
majorVersion = 1;
Expand Down
23 changes: 23 additions & 0 deletions test/com/amazon/ion/streaming/SeekableReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,29 @@ public void testHoistingAnnotatedContainedValue()
expectTopEof();
}

@Test
public void testHoistingNestedContainerWithoutSteppingOutOfParent()
{
read("{first: {foo: bar}, second: a::{baz: zar}, third: 123}");
in.next();
in.stepIn();
in.next();
in.next();
Span span = sr.currentSpan();
in.next();
// Note: we do not step out of the struct.

hoist(span);
assertSame(IonType.STRUCT, in.next());
expectTopLevel();
Assert.assertArrayEquals(new String[]{"a"}, in.getTypeAnnotations());
in.stepIn();
in.next();
assertEquals("zar", in.stringValue());
in.stepOut();
expectTopEof();
}

@Test
public void testHoistingAcrossSymbolTableBoundary()
throws IOException
Expand Down

0 comments on commit 38c636a

Please sign in to comment.