Fuzzer { public Expr fuzzExpr(Type targetType, boolean isLValue, boolean constContext, final int depth) { int maxTries = 50; for (int i = 0; i < maxTries; i++) { try { return makeExpr(targetType, isLValue, constContext, depth); } catch (FuzzedIntoACornerException exception) { continue; } } throw new FuzzedIntoACornerException(); } Fuzzer(FuzzingContext fuzzingContext,
        ShadingLanguageVersion shadingLanguageVersion,
        IRandom generator,
        GenerationParams generationParams,
        String fuzzedDeclarationPrefix);  Fuzzer(FuzzingContext fuzzingContext,
        ShadingLanguageVersion shadingLanguageVersion,
        IRandom generator,
        GenerationParams generationParams); Expr fuzzExpr(Type targetType, boolean isLValue, boolean constContext,
        final int depth); static boolean isTooDeep(int depth, GenerationParams generationParams, IRandom generator); static Stream<IExprTemplate> availableTemplatesFromScope(
      ShadingLanguageVersion shadingLanguageVersion,
      ShaderKind shaderKind,
      Scope scope); TranslationUnit fuzzTranslationUnit(); Stmt fuzzStmt(); static void main(String[] args);  }
@Test public void testStructExprFuzzing() throws Exception { final String shader = "" + "struct A {" + " int f1;" + " int f2;" + "};\n" + "struct B {" + " A f1;" + " A f2;" + "};" + "void main() {" + " int doitWhenYouReachMyUse;" + " doitWhenYouReachMyUse;" + "}"; TranslationUnit tu = ParseHelper.parse(shader); new ScopeTrackingVisitor() { @Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { super.visitVariableIdentifierExpr(variableIdentifierExpr); if (variableIdentifierExpr.getName().equals("doitWhenYouReachMyUse")) { Expr expr = new Fuzzer(new FuzzingContext(getCurrentScope()), ShadingLanguageVersion.ESSL_100, new ZeroCannedRandom(), GenerationParams.normal(ShaderKind.FRAGMENT, true), "prefix") .fuzzExpr(new StructNameType("B"), false, false, 0); assertTrue(expr instanceof TypeConstructorExpr); final TypeConstructorExpr outer = (TypeConstructorExpr) expr; assertEquals("B", outer.getTypename()); assertTrue(outer.getArg(0) instanceof TypeConstructorExpr); assertTrue(outer.getArg(1) instanceof TypeConstructorExpr); final TypeConstructorExpr inner0 = (TypeConstructorExpr) outer.getArg(0); final TypeConstructorExpr inner1 = (TypeConstructorExpr) outer.getArg(1); assertEquals("A", inner0.getTypename()); assertEquals("A", inner1.getTypename()); } } }.visit(tu); }