Ejemplo n.º 1
0
 /** Verify fields are released in a dealloc for reference counted code. */
 public void testFieldReleaseReferenceCounting() throws IOException {
   Options.setMemoryManagementOption(Options.MemoryManagementOption.REFERENCE_COUNTING);
   String translation =
       translateSourceFile("class Test { Object o; Runnable r; }", "Test", "Test.m");
   assertTranslatedLines(
       translation,
       "- (void)dealloc {",
       "RELEASE_(o_);",
       "RELEASE_(r_);",
       "[super dealloc];",
       "}");
 }
Ejemplo n.º 2
0
 /** Verify fields are not released for ARC code when a finalize() method is defined. */
 public void testFieldReleaseFinalizeARC() throws IOException {
   Options.setMemoryManagementOption(Options.MemoryManagementOption.ARC);
   String translation =
       translateSourceFile(
           "class Test { Object o; Runnable r;"
               + "public void finalize() throws Throwable { System.out.println(this); }}",
           "Test",
           "Test.m");
   assertTranslatedLines(
       translation,
       "- (void)dealloc {",
       "[((JavaIoPrintStream *) nil_chk(JreLoadStatic(JavaLangSystem, out_))) "
           + "printlnWithId:self];",
       "}");
 }
Ejemplo n.º 3
0
 /** Verify fields are not released for ARC code, and a dealloc method is not created. */
 public void testFieldReleaseARC() throws IOException {
   Options.setMemoryManagementOption(Options.MemoryManagementOption.ARC);
   String translation =
       translateSourceFile("class Test { Object o; Runnable r; }", "Test", "Test.m");
   assertNotInTranslation(translation, "dealloc");
 }