use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testOverridingSystemSymbolId.
/**
* Attempts to override system symbols are ignored.
*/
@Test
public void testOverridingSystemSymbolId() {
String importingText = LocalSymbolTablePrefix + "{" + " symbols:[ '''" + NAME + "''' ]," + "}\n" + "null";
Iterator<IonValue> scanner = system().iterate(importingText);
IonValue v = scanner.next();
SymbolTable symtab = v.getSymbolTable();
assertTrue(symtab.isLocalTable());
checkSymbol(NAME, NAME_SID, symtab);
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testLocalSymbolTableMultiAppend.
@Test
public void testLocalSymbolTableMultiAppend() {
String text = LocalSymbolTablePrefix + "{" + " symbols:[ \"s1\", \"s2\"]" + "}\n" + LocalSymbolTablePrefix + "{" + " imports:" + ION_SYMBOL_TABLE + "," + " symbols:[ \"s3\"]" + "}\n" + LocalSymbolTablePrefix + "{" + " imports:" + ION_SYMBOL_TABLE + "," + " symbols:[\"s4\", \"s5\"]" + "}\n" + LocalSymbolTablePrefix + "{" + " imports:" + ION_SYMBOL_TABLE + "," + " symbols:[\"s6\"]" + "}\n" + "null";
SymbolTable symbolTable = oneValue(text).getSymbolTable();
checkLocalTable(symbolTable);
// table contains all symbols and SIDs are in correct order
checkSymbol("s1", systemMaxId() + 1, symbolTable);
checkSymbol("s2", systemMaxId() + 2, symbolTable);
checkSymbol("s3", systemMaxId() + 3, symbolTable);
checkSymbol("s4", systemMaxId() + 4, symbolTable);
checkSymbol("s5", systemMaxId() + 5, symbolTable);
checkSymbol("s6", systemMaxId() + 6, symbolTable);
checkUnknownSymbol("unknown", UNKNOWN_SYMBOL_ID, symbolTable);
checkUnknownSymbol(33, symbolTable);
}
use of com.amazon.ion.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method testImportsFollowSymbols.
@Test
public void testImportsFollowSymbols() {
registerImportedV1();
final int import1id = systemMaxId() + 1;
final int local1id = systemMaxId() + IMPORTED_1_MAX_ID + 1;
final int local2id = local1id + 1;
String importingText = "$ion_1_0 " + LocalSymbolTablePrefix + "{" + " symbols:[ '''local1''' ]," + " imports:[{name:'''imported''', version:1, max_id:2}]," + "}\n" + // This symbol is added to end of locals
"local2\n" + "local1\n" + "'imported 1'";
Iterator<IonValue> scanner = system().iterate(importingText);
IonValue value = scanner.next();
SymbolTable symtab = value.getSymbolTable();
checkLocalTable(symtab);
checkSymbol("local2", value);
value = scanner.next();
checkSymbol("local1", local1id, value);
value = scanner.next();
checkSymbol("imported 1", import1id, value);
}
use of com.amazon.ion.SymbolTable 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.SymbolTable in project ion-java by amzn.
the class SymbolTableTest method registerImportedV1.
public SymbolTable registerImportedV1() {
SymbolTable shared = registerSharedSymtab(IMPORTED_1_SERIALIZED);
assertEquals(IMPORTED_1_MAX_ID, shared.getMaxId());
SymbolTable importedTable = system().getCatalog().getTable("imported", 1);
assertSame(shared, importedTable);
return importedTable;
}
Aggregations