TypeShed { public static ClassSymbol typeShedClass(String fullyQualifiedName) { Symbol symbol = builtinSymbols().get(fullyQualifiedName); if (symbol == null) { throw new IllegalArgumentException("No TypeShed symbol found for name: " + fullyQualifiedName); } if (symbol.kind() != Symbol.Kind.CLASS) { throw new IllegalArgumentException("TypeShed symbol " + fullyQualifiedName + " is not a class"); } return (ClassSymbol) symbol; } private  TypeShed(); static Map<String, Symbol> builtinSymbols(); static Set<Symbol> symbolsForModule(String moduleName); @CheckForNull static Symbol symbolWithFQN(String stdLibModuleName, String fullyQualifiedName); static ClassSymbol typeShedClass(String fullyQualifiedName); static Collection<Symbol> stubFilesSymbols();  }
@Test public void classes() { ClassSymbol intClass = TypeShed.typeShedClass("int"); assertThat(intClass.superClasses()).isEmpty(); assertThat(intClass.hasUnresolvedTypeHierarchy()).isFalse(); assertThat(intClass.usages()).isEmpty(); assertThat(intClass.declaredMembers()).allMatch(member -> member.usages().isEmpty()); assertThat(TypeShed.typeShedClass("bool").superClasses()).containsExactly(intClass); }
@Test public void str() { ClassSymbol strClass = TypeShed.typeShedClass("str"); assertThat(strClass.hasUnresolvedTypeHierarchy()).isFalse(); assertThat(strClass.superClasses()).extracting(Symbol::kind, Symbol::name).containsExactlyInAnyOrder(tuple(Kind.CLASS, "object"), tuple(Kind.AMBIGUOUS, "Sequence")); }
@Test(expected = IllegalArgumentException.class) public void not_a_class() { TypeShed.typeShedClass("repr"); }
@Test(expected = IllegalArgumentException.class) public void unknown_name() { TypeShed.typeShedClass("xxx"); }
@Test public void none_type() { ClassSymbol noneType = TypeShed.typeShedClass("NoneType"); assertThat(noneType.superClasses()).isEmpty(); }