@Test
public void checkInliningAppliedCorrectly() throws Exception {

  String program = "struct _GLF_struct_1687 {\n"
      + "    float lerp;\n"
      + "    vec3 _f0;\n"
      + "};\n"
      + "struct _GLF_struct_1698 {\n"
      + "    ivec4 _f0;\n"
      + "    _GLF_struct_1687 _f1;\n"
      + "    vec4 _f2;\n"
      + "    ivec2 _f3;\n"
      + "};\n"
      + "void main() {\n"
      + "  _GLF_struct_1698 " + Constants.STRUCTIFICATION_STRUCT_PREFIX + "_mine = "
              + "_GLF_struct_1698(0, _GLF_struct_1687(1.0, vec3(1.0)), vec4(1.0), ivec2(1));\n"
      + "}\n";
  String programAfter = "struct _GLF_struct_1687 {\n"
      + "    float lerp;\n"
      + "    vec3 _f0;\n"
      + "};\n"
      + "struct _GLF_struct_1698 {\n"
      + "    ivec4 _f0;\n"
      + "    float lerp;\n"
      + "    vec3 _f1_f0;\n"
      + "    vec4 _f2;\n"
      + "    ivec2 _f3;\n"
      + "};\n"
      + "void main() {\n"
      + "  _GLF_struct_1698 " + Constants.STRUCTIFICATION_STRUCT_PREFIX + "_mine = "
              + "_GLF_struct_1698(0, 1.0, vec3(1.0), vec4(1.0), ivec2(1));\n"
      + "}\n";
  TranslationUnit tu = ParseHelper.parse(program);
  assertEquals(1,
      InlineStructifiedFieldReductionOpportunities
          .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
              new ReducerContext(false, ShadingLanguageVersion.ESSL_100,
                  new RandomWrapper(0), new IdGenerator())).size());
  InlineStructifiedFieldReductionOpportunities
      .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
        new ReducerContext(false, ShadingLanguageVersion.ESSL_100,
            new RandomWrapper(0), new IdGenerator())).get(0).applyReduction();
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(programAfter)),
      PrettyPrinterVisitor.prettyPrintAsString(tu));
}