String src = index(
"test.py",
"x = (2,)",
"y = [x]",
"x = y");
NType xtype = idx.lookupQnameType("test.x");
assertTrue(xtype instanceof NUnionType);
// Jump through some hoops to allow for either order in the union.
Set<NType> types = xtype.asUnionType().getTypes();
assertEquals(2, types.size());
NType[] array = types.toArray(new NType[2]);
boolean array0List = array[0] instanceof NListType;
boolean array1List = array[1] instanceof NListType;
assertTrue(array0List || array1List);
int other = array0List ? 1 : 0;
assertTrue("Expected tuple: " + array[other], array[other].isTupleType());
assertEquals(1, array[other].asTupleType().getElementTypes().size());
assertEquals(idx.builtins.BaseNum, array[other].asTupleType().getElementTypes().get(0));
String s = xtype.toString();
int index = s.indexOf("<TupleType=#");
assertTrue(index != -1);
int spot = index + "<TupleType=#".length();
int num = Integer.parseInt(s.substring(spot, spot+1));