@Test
public void testInliningInDeadCodeWithPreserveSemantics() throws Exception {

  // We do want to be able to inline an initializer if we are in dead code, when preserving
  // semantics
  final String program = "void main() {\n"
      + "  if(" + Constants.GLF_DEAD + "(" + Constants.GLF_FALSE + "(false, false))) {\n"
      + "    int do_inline_me = 5 + 2;\n"
      + "    do_inline_me * do_inline_me;\n"
      + "  }\n"
      + "}\n";
  final String expected = "void main() {\n"
      + "  if(" + Constants.GLF_DEAD + "(" + Constants.GLF_FALSE + "(false, false))) {\n"
      + "    int do_inline_me = 5 + 2;\n"
      + "    (5 + 2) * (5 + 2);\n"
      + "  }\n"
      + "}\n";
  final TranslationUnit tu = ParseHelper.parse(program);
  final List<SimplifyExprReductionOpportunity> ops = InlineInitializerReductionOpportunities
          .findOpportunities(MakeShaderJobFromFragmentShader.make(tu),
              new ReducerContext(false,
          ShadingLanguageVersion.ESSL_100, new RandomWrapper(0), new IdGenerator()));
  assertEquals(2, ops.size());
  ops.get(0).applyReduction();
  ops.get(1).applyReduction();
  CompareAsts.assertEqualAsts(expected, tu);
}