use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SymbolTableTest method testOverridingImportedSymbolId.
@Test
public void testOverridingImportedSymbolId() {
SymbolTable importedTable = registerImportedV1();
final int import1id = systemMaxId() + 1;
final int import1DupId = systemMaxId() + importedTable.getMaxId() + 1;
String importingText = "$ion_1_0 " + LocalSymbolTablePrefix + "{" + " imports:[{name:'''imported''', version:1, max_id:2}]," + " symbols:[ '''imported 1''' ]," + "}\n" + "'imported 1'\n" + "$" + import1id;
Iterator<IonValue> scanner = system().iterate(importingText);
IonValue value = scanner.next();
checkSymbol("imported 1", import1id, value);
SymbolTable symtab = value.getSymbolTable();
checkLocalTable(symtab);
checkSymbol("imported 1", import1id, symtab);
checkSymbol("imported 1", import1DupId, /* dupe */
true, symtab);
// Here the input text is $NNN but it comes back correctly.
value = scanner.next();
checkSymbol("imported 1", import1id, value);
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class SymbolTableTest method testImportWithZeroMaxId.
// TODO test getUsedTable(null)
// TODO test getImportedTable(null)
@Test
public void testImportWithZeroMaxId() throws Exception {
registerImportedV1();
String text = LocalSymbolTablePrefix + "{" + " imports:[{name:\"imported\", version:1, max_id:0}]," + " symbols:['''local''']" + "}\n" + "null";
IonValue v = oneValue(text);
SymbolTable symbolTable = v.getSymbolTable();
SymbolTable imported = checkFirstImport("imported", 1, EMPTY_STRING_ARRAY, symbolTable);
assertTrue(imported.isSubstitute());
checkUnknownSymbol("imported 1", 1, imported);
checkSymbol("local", systemMaxId() + 1, symbolTable);
checkUnknownSymbol("imported 1", UNKNOWN_SYMBOL_ID, symbolTable);
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonListSexpLiteSublistTest method sublistListIteratorWithSet.
@Test
public void sublistListIteratorWithSet() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final ListIterator<IonValue> iterator = sublist.listIterator();
iterator.next();
final IonInt newSetValue = SYSTEM.newInt(100);
iterator.set(newSetValue);
assertEquals(newSetValue, sublist.get(0));
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonListSexpLiteSublistTest method sublistSet.
@Test
public void sublistSet() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final IonInt element = SYSTEM.newInt(99);
final IonValue previous = sublist.set(0, element);
assertEquals(2, ((IonInt) previous).intValue());
assertEquals(element, sublist.get(0));
assertEquals(element, sequence.get(2));
}
use of com.amazon.ion.IonValue in project ion-java by amzn.
the class IonListSexpLiteSublistTest method sublistSetOutOfRange.
@Test(expected = IndexOutOfBoundsException.class)
public void sublistSetOutOfRange() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final IonInt element = SYSTEM.newInt(99);
sublist.set(4, element);
}
Aggregations