Echtzeitsysteme / java-refactoring-ttc

Object-oriented Refactoring of Java Programs using Graph Transformation (TTC'2015)
0 stars 0 forks source link

Wrong assertion in hidden_pum2_2 #29

Closed tsdh closed 9 years ago

tsdh commented 9 years ago

This refactoring tries applyPullUpMethod(hidden.program.two.ParentClass, second) which is not applicable because not all ParentClass subclasses have a second() method. Consequently, my transformation does nothing. But still I get an assertion failure.

Executing hidden test case: "hidden_pum2_2"
    Description:
        Do method calls confuse your solution?

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        k=3
        k=3

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
createProgramGraph(/tmp/tmp_ttc/hiddenProgram2)
Parsing file /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ParentClass.java... Done
Parsing file /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass3.java... Done
Parsing file /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass2.java... Done
Parsing file /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass1.java... Done
Base-package is hidden
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
applyPullUpMethod(hidden.program.two.ParentClass, second)
The pull-up-method rule didn't match!
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
Deleting folder /home/horn/tmp/JR/not_executable_pum2_2-before
Copying /tmp/tmp_ttc/hiddenProgram2 to /home/horn/tmp/JR/not_executable_pum2_2-before
synchronizeChanges(): 0 changes to be applied
Saving resource to /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ParentClass.java
Saving resource to /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass3.java
Saving resource to /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass2.java
Saving resource to /tmp/tmp_ttc/hiddenProgram2/src/hidden/program/two/ChildClass1.java
Deleting folder /home/horn/tmp/JR/not_executable_pum2_2-after
Copying /tmp/tmp_ttc/hiddenProgram2 to /home/horn/tmp/JR/not_executable_pum2_2-after
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

FAILURE: Containment of element expected but is not contained. (false-negative)

    Output of execution after refactoring:
        k=3
        k=3

SUCCESS: Output before and after refactoring are equal.

I've checked, and there are no changes between the original sources and the sources after the transformation (except for whitespaces).

SvenPeldszus commented 9 years ago

I've checked the assertions and if there appears an failure I would expect a false-positive and not a false-negative.

I've removed this critical check and will look if ARTE prints the wrong message at this point.

tsdh commented 9 years ago

@SvenPeldszus By the way, I get this FAILURE: Containment of element expected but is not contained. (false-negative) failure also with hidden_csc3_1a and hidden_csc3_1 so probably there's something wrong with this containment-check in general.

SvenPeldszus commented 9 years ago

Ok, there was really a small bug in the containment check. However this bug only resulted in alway printing the message FAILURE: Containment of element expected but is not contained. (false-negative) even if a false positive occurred.

In hidden_pum2_2 the failure was due to a accidental missing "not".

The cases hidden_csc3_1a and hidden_csc3_1 should be correct. These two cases are somehow tricky and are containing chains of refactorings.

tsdh commented 9 years ago

hidden_pum2_2 now succeeds.

hidden_csc3_1a and hidden_csc3_1 still fail with FAILURE: Containment of element forbidden but is contained in class. (false-positive). Both test cases perform applyCreateSuperClass([hidden.program.three.ChildClass1, hidden.program.three.ChildClass2], hidden.program.three.NewParent) followed by applyPullUpMethod(hidden.program.three.NewParent, method). After synchronization, NewParent contains the method(). So that looks good to me. Why does it fail?

BTW, it seems hidden_csc3_1a and hidden_csc3_1 are almost identical. The same refactorings are applied to the very same sources. The only difference seems to be that hidden_csc3_1a has one more This static check whether a class contains a specific method or field was successful. assertion.

SvenPeldszus commented 9 years ago

In the final outcome they are both identical. They differ in the way how the refactorings are applied.

Do you always sync with the source code?

tsdh commented 9 years ago

I do that whenever synchronizeChanges() is called. Ah, the difference is that hidden_csc3_1a synchronizes after each refactoring while hidden_csc3_1 synchronizes only after the second one. Ok, no problem. But still I don't get why I get the failures.

Here's the complete output.

Executing hidden test case: "hidden_csc3_1a"
    Description:
        Is the PG after a refactoring still consistent?.

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        Hello World
        Hello World

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
createProgramGraph(/tmp/tmp_ttc/hiddenProgram3)
Parsing file /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass2.java... Done
Parsing file /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass1.java... Done
Base-package is hidden
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Extract Superclass Refactoring ssssssssssss
applyCreateSuperClass([hidden.program.three.ChildClass1, hidden.program.three.ChildClass2], hidden.program.three.NewParent)
Creating new superclass hidden.program.three.NewParent with no parent
The create-superclass rule did match!
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
Deleting folder /home/horn/tmp/JR/executable_exs_1-before
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_exs_1-before
synchronizeChanges(): 1 changes to be applied
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass2.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass1.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/NewParent.java
Deleting folder /home/horn/tmp/JR/executable_exs_1-after
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_exs_1-after
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.
ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
applyPullUpMethod(hidden.program.three.NewParent, method)
Pulling up method to hidden.program.three.NewParent
The pull-up-method rule did match!
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
Deleting folder /home/horn/tmp/JR/executable_pum_1-before
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_pum_1-before
synchronizeChanges(): 1 changes to be applied
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass2.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass1.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/NewParent.java
Deleting folder /home/horn/tmp/JR/executable_pum_1-after
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_pum_1-after
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

FAILURE: Containment of element forbidden but is contained in class. (false-positive)

    Output of execution after refactoring:
        Hello World
        Hello World

SUCCESS: Output before and after refactoring are equal.

--------------------------------------------------------------------
FAILURE: Test case "hidden_csc3_1a" has not been executed successfully.
The solution needed 0.092 seconds for execution. 
--------------------------------------------------------------------

Executing hidden test case: "hidden_csc3_1"
    Description:
        How good is the propagation of multiple changes?

SUCCESS: The java program has been compiled.

    Output of execution before refactoring:
        Hello World
        Hello World

sssssssssssssss Triggering Program Graph Generation ssssssssssssssss
createProgramGraph(/tmp/tmp_ttc/hiddenProgram3)
Parsing file /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass2.java... Done
Parsing file /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass1.java... Done
Base-package is hidden
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Extract Superclass Refactoring ssssssssssss
applyCreateSuperClass([hidden.program.three.ChildClass1, hidden.program.three.ChildClass2], hidden.program.three.NewParent)
Creating new superclass hidden.program.three.NewParent with no parent
The create-superclass rule did match!
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

SUCCESS: This static check whether a class contains a specific method or field was successful.
SUCCESS: This static check whether a class contains a specific method or field was successful.
ssssssssssssss  Triggering Pull-Up Method Refactoring ssssssssssssss
applyPullUpMethod(hidden.program.three.NewParent, method)
Pulling up method to hidden.program.three.NewParent
The pull-up-method rule did match!
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

ssssssssssss  Triggering Synchronization with Java Code ssssssssssss
Deleting folder /home/horn/tmp/JR/executable_pum_1-before
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_pum_1-before
synchronizeChanges(): 2 changes to be applied
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass2.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/ChildClass1.java
Saving resource to /tmp/tmp_ttc/hiddenProgram3/src/hidden/program/three/NewParent.java
Deleting folder /home/horn/tmp/JR/executable_pum_1-after
Copying /tmp/tmp_ttc/hiddenProgram3 to /home/horn/tmp/JR/executable_pum_1-after
ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

FAILURE: Containment of element forbidden but is contained in class. (false-positive)

    Output of execution after refactoring:
        Hello World
        Hello World

SUCCESS: Output before and after refactoring are equal.

--------------------------------------------------------------------
FAILURE: Test case "hidden_csc3_1" has not been executed successfully.
The solution needed 0.023 seconds for execution. 
--------------------------------------------------------------------
SvenPeldszus commented 9 years ago

Can I still build from the repository you shared or is this not up to date?

tsdh commented 9 years ago

It is up to date. But it currently expects you to have a directory /home/horn/tmp/ where it copies the sources to before and after synchronizeChanges() is called. If you want, I can comment that out.

tsdh commented 9 years ago

Done

SvenPeldszus commented 9 years ago

Ok, I've fixed the bug. in one case the check for compiler created methods was missing.

All tests are successful with your solution.

tsdh commented 9 years ago

Ok, works now.