@Test
public void testUpdateTopLevelDeclaration() throws Exception {

  final String shader =
      "uniform float a[2];"
          + "void main()"
          + "{"
          + "  float b = a[0];"
          + "}";
  final TranslationUnit translationUnit = ParseHelper.parse(shader, ShaderKind.FRAGMENT);
  final VariablesDeclaration variablesDecl = translationUnit.getUniformDeclaration("a");
  assertEquals(variablesDecl.getDeclInfos().get(0).getName(), "a");
  assertTrue(variablesDecl.getDeclInfos().get(0).hasArrayInfo());
  assertEquals(variablesDecl.getDeclInfos().get(0).getArrayInfo().getConstantSize(),
      Integer.valueOf(2));
  assertEquals(((IntConstantExpr)variablesDecl.getDeclInfos().get(0).getArrayInfo()
          .getSizeExpr()).getNumericValue(), 2);
  // Increases the size of the array by one and checks that the new size was recorded
  // correctly.
  final ArrayInfo arrayInfo = new ArrayInfo(new IntConstantExpr("3"));
  arrayInfo.setConstantSizeExpr(3);
  final VariableDeclInfo variableDeclInfo = new VariableDeclInfo("a",
        arrayInfo, null);
  final VariablesDeclaration newVariablesDeclaration = new VariablesDeclaration(
      new QualifiedType(BasicType.INT, Arrays.asList(TypeQualifier.UNIFORM)), variableDeclInfo
  );
  translationUnit.updateTopLevelDeclaration(newVariablesDeclaration, variablesDecl);
  final VariablesDeclaration variablesDecl2 =
      translationUnit.getUniformDeclaration("a");
  assertEquals(variablesDecl2.getDeclInfos().get(0).getName(), "a");
  assertTrue(variablesDecl2.getDeclInfos().get(0).hasArrayInfo());
  assertEquals(variablesDecl2.getDeclInfos().get(0).getArrayInfo().getConstantSize(),
      Integer.valueOf(3));
  assertEquals(((IntConstantExpr)variablesDecl2.getDeclInfos().get(0).getArrayInfo()
      .getSizeExpr()).getNumericValue(), 3);
}