@Test
public void testRemoveUnusedNameShadowing() throws Exception {

  // Checks for the case where a uniform declared in the pipeline state is not used, but another
  // variable shadows its name.
  final String minimalShader = "void main() { int shadow; }";
  final PipelineInfo pipelineInfo = new PipelineInfo();
  pipelineInfo.addUniform("shadow", BasicType.FLOAT, Optional.empty(),
      Collections.singletonList(10.0));
  final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(),
      pipelineInfo, ParseHelper.parse(minimalShader));
  // The pipeline info has an unused uniform named 'shadow', and the shader declares an unrelated
  // variable called 'shadow'.  We would like the uniform to be removed from the pipeline info,
  // as it is not used.
  assertEquals(1, shaderJob.getPipelineInfo().getNumUniforms());
  // There should be exactly one opportunity to remove a piece of unused pipeline state.
  List<RemoveRedundantUniformMetadataReductionOpportunity> ops =
      RemoveRedundantUniformMetadataReductionOpportunities
          .findOpportunities(shaderJob,
              new ReducerContext(false, ShadingLanguageVersion.ESSL_100,
                  new RandomWrapper(0),
              new IdGenerator()));
  assertEquals(1, ops.size());
  ops.get(0).applyReduction();
  // Check that after applying the reduction opportunity there are no uniforms in the pipeline
  // state and that the shader has not changed.
  CompareAsts.assertEqualAsts(minimalShader, shaderJob.getFragmentShader().get());
  assertEquals(0, shaderJob.getPipelineInfo().getNumUniforms());
}