@Test
public void testBasicBehaviour() throws Exception {

  final String original =
      "void f() {\n"
          + "    vec2 GLF_merged2_0_1_1_1_1_1bc;\n"
          + "    float b, c;\n"
          + "    b = 2;\n"
          + "    GLF_merged2_0_1_1_1_1_1bc.x = b;\n"
          + "    c = 3;\n"
          + "    GLF_merged2_0_1_1_1_1_1bc.y = c;\n"
          + "    GLF_merged2_0_1_1_1_1_1bc.x = GLF_merged2_0_1_1_1_1_1bc.x + "
          + "GLF_merged2_0_1_1_1_1_1bc.y;\n"
          + "}\n";
  final String expected1 =
      "void f() {\n"
          + "    vec2 GLF_merged2_0_1_1_1_1_1bc;\n"
          + "    float b, c;\n"
          + "    b = 2;\n"
          + "    b = b;\n"
          + "    c = 3;\n"
          + "    GLF_merged2_0_1_1_1_1_1bc.y = c;\n"
          + "    b = b + GLF_merged2_0_1_1_1_1_1bc.y;\n"
          + "}\n";
  final String expected2 =
      "void f() {\n"
          + "    vec2 GLF_merged2_0_1_1_1_1_1bc;\n"
          + "    float b, c;\n"
          + "    b = 2;\n"
          + "    b = b;\n"
          + "    c = 3;\n"
          + "    c = c;\n"
          + "    b = b + c;\n"
          + "}\n";
  final TranslationUnit tu = ParseHelper.parse(original);
  List<VectorizationReductionOpportunity> ops = VectorizationReductionOpportunities
      .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
          new ReducerContext(false, ShadingLanguageVersion.GLSL_440,
              new ZeroCannedRandom(), new IdGenerator()));
  assertEquals(2, ops.size());
  ops.stream().filter(item -> item.getComponentName().equals("b")).findAny().get()
      .applyReduction();
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected1)),
      PrettyPrinterVisitor.prettyPrintAsString(tu));
  ops = VectorizationReductionOpportunities
          .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
              new ReducerContext(false, ShadingLanguageVersion.GLSL_440,
      new ZeroCannedRandom(), new IdGenerator()));
  assertEquals(1, ops.size());
  ops.stream().filter(item -> item.getComponentName().equals("c")).findAny().get()
      .applyReduction();
  assertEquals(PrettyPrinterVisitor.prettyPrintAsString(ParseHelper.parse(expected2)),
      PrettyPrinterVisitor.prettyPrintAsString(tu));
}