@Test
public void testReplaceSimpleInt() throws Exception {

  final String vertexShader = "void main() { "
      + "int a = 1;}";
  final String vertexShaderReplaced = "uniform int _GLF_uniform_int_values[2];"
      + "void main()"
      + "{"
      + "  int a = _GLF_uniform_int_values[0];"
      + "}";
  final String fragmentShader = "void main() { "
      + "int a = 2;}";
  final String fragmentShaderReplaced = "uniform int _GLF_uniform_int_values[2];"
      + "void main()"
      + "{"
      + "  int a = _GLF_uniform_int_values[1];"
      + "}";
  final List<TranslationUnit> shaders = new ArrayList<>();
  shaders.add(ParseHelper.parse(vertexShader, ShaderKind.VERTEX));
  shaders.add(ParseHelper.parse(fragmentShader, ShaderKind.FRAGMENT));
  final PipelineInfo pipelineInfo = new PipelineInfo();
  final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(),
      pipelineInfo, shaders);
  assertEquals(0, pipelineInfo.getNumUniforms());
  final List<LiteralToUniformReductionOpportunity> ops =
      LiteralToUniformReductionOpportunities
      .findOpportunities(shaderJob,
          new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0),
              new IdGenerator()));
  assertEquals("There should be two opportunities", 2, ops.size());
  assertEquals(0, pipelineInfo.getNumUniforms());
  ops.forEach(AbstractReductionOpportunity::applyReduction);
  CompareAsts.assertEqualAsts(fragmentShaderReplaced, shaderJob.getFragmentShader().get());
  CompareAsts.assertEqualAsts(vertexShaderReplaced, shaderJob.getVertexShader().get());
  assertTrue(shaderJob.getPipelineInfo().hasUniform(Constants.INT_LITERAL_UNIFORM_VALUES));
  assertEquals(1, pipelineInfo.getNumUniforms());
  // Check that the uniforms won't be recursively replaced in the next pass.
  final List<LiteralToUniformReductionOpportunity> ops2 =
      LiteralToUniformReductionOpportunities
          .findOpportunities(shaderJob,
              new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0),
                  new IdGenerator()));
  assertEquals("There should be no opportunities", 0, ops2.size());
}