/daikon-pedrovgs-algorithms

Using Daikon on pedrovgs/Algorithms

Primary LanguageJavaApache License 2.0Apache-2.0

Using Daikon on pedrovgs/Algorithms

# compile with maven
mvn package
# find all the test classes using:
bun findclasses.js
# from this, manually remove SortingAlgorithmTest because it is an abstract class (mvn test does not execute it either)

# make sure the hamcrest and junit .jars are in the classpath
# the following command will produce a file called `JUnitCore.decls-DynComp`
# NOTE: all of the sorting algorithm tests are removed from this command because Daikon gives:
#     "IllegalArgumentException: Test class can only have one constructor"
# NOTE: the ConstantComplexityOrderStack test has been removed because it triggers an internal issue within Daikon:
#     Unexpected error processing... ConstantComplexityOrderStack$Stack2.pop... Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
java -cp ./target/classes:./target/test-classes:./junit-4.13.1.jar:./hamcrest-core-1.3.jar:$DAIKONDIR/daikon.jar daikon.DynComp --ppt-omit-pattern='org.junit|junit.framework' org.junit.runner.JUnitCore com.github.pedrovgs.problem55.RewriteRowAndColumnsWithZerosTest com.github.pedrovgs.problem52.ReplaceSpacesTest com.github.pedrovgs.problem64.GetTheElementInTheMiddleOfTheListTest com.github.pedrovgs.problem37.PathCalculatorTest com.github.pedrovgs.problem30.ScientificNotationTest com.github.pedrovgs.problem39.MultiplyArrayElementsTest com.github.pedrovgs.problem62.PalindromeListTest com.github.pedrovgs.problem65.IsTreeBalancedTest com.github.pedrovgs.problem53.CompressStringTest com.github.pedrovgs.problem54.RotateMatrixTest com.github.pedrovgs.problem38.PathToEveryLeafTest com.github.pedrovgs.problem31.FindLongestConsecutiveSequenceTest com.github.pedrovgs.problem36.AvlTreeMedianTest com.github.pedrovgs.problem14.BinaryTreePreOrderTest com.github.pedrovgs.problem13.BinaryTreeByLevelTest com.github.pedrovgs.problem25.AnagramsTest com.github.pedrovgs.problem22.ReverseLinkedListTest com.github.pedrovgs.problem49.CombinationsOfChangeTest com.github.pedrovgs.problem1.BitsCounterTest com.github.pedrovgs.problem6.MergeSortedArraysTest com.github.pedrovgs.problem71.ReverseBinaryNumberTest com.github.pedrovgs.problem78.AutoBoxingTrickTest com.github.pedrovgs.problem47.ReturnChangeTest com.github.pedrovgs.problem8.SplitArrayTest com.github.pedrovgs.problem40.MoveElementsToPositionsTest com.github.pedrovgs.problem23.RemoveCommentsTest com.github.pedrovgs.problem24.SortedArrayToBSTTest com.github.pedrovgs.problem12.MoveZerosInArrayTest com.github.pedrovgs.problem15.BinaryTreeInOrderTest com.github.pedrovgs.problem9.FactorialTest com.github.pedrovgs.problem41.GoThroughMatrixInSpiralTest com.github.pedrovgs.problem46.BinaryTreeSerializationTest com.github.pedrovgs.problem7.FibonacciNumbersTest com.github.pedrovgs.problem70.ReverseOrderOfBinaryNumberTest com.github.pedrovgs.problem48.WordSearchTest com.github.pedrovgs.problem33.SimpleRegularExpressionTest com.github.pedrovgs.problem34.DotRegularExpressionTest com.github.pedrovgs.problem51.ReverseStringTest com.github.pedrovgs.problem56.IsRotationUsingIsSubstringTest com.github.pedrovgs.problem69.BitsToTransformTest com.github.pedrovgs.problem60.PartitionListTest com.github.pedrovgs.problem67.MergeBinaryNumbersTest com.github.pedrovgs.problem58.FindKthElementTest com.github.pedrovgs.problem35.AsteriskRegularExpressionTest com.github.pedrovgs.problem32.ContainsTest com.github.pedrovgs.problem66.TreeToListByLevelTest com.github.pedrovgs.problem59.DeleteListNodeTest com.github.pedrovgs.problem61.SumListsTest com.github.pedrovgs.problem57.RemoveListDuplicatedElementsTest com.github.pedrovgs.problem68.IsEvenTest com.github.pedrovgs.problem50.UniqueCharsTest com.github.pedrovgs.problem5.DivideUsingSubtractionTest com.github.pedrovgs.problem72.FindTheMissingNumberTest com.github.pedrovgs.problem2.VectorScalarProductTest com.github.pedrovgs.problem43.CombinationOfIntegersTest com.github.pedrovgs.problem44.FindMinNumberAtPositionTest com.github.pedrovgs.problem10.RemoveDuplicatesTest com.github.pedrovgs.problem17.BinaryTreeEqualsTest com.github.pedrovgs.problem28.FindSumsTest com.github.pedrovgs.problem21.LowestCommonAncestorTest com.github.pedrovgs.problem26.PalindromesTest com.github.pedrovgs.problem19.BinaryTreeDepthTest com.github.pedrovgs.problem45.FindNthMostRepeatedElementTest com.github.pedrovgs.problem42.FloodFillTest com.github.pedrovgs.problem3.SumBinaryNumberTest com.github.pedrovgs.problem4.SquareRootTest com.github.pedrovgs.problem73.SubtractAddingTest com.github.pedrovgs.problem27.ReverseSentenceTest com.github.pedrovgs.problem18.IsBSTTest com.github.pedrovgs.problem20.MultiplicationWithoutMultiplyTest com.github.pedrovgs.problem16.BinaryTreePostOrderTest com.github.pedrovgs.problem29.AreAnagramsTest com.github.pedrovgs.problem11.IntToStringTest

# then run Daikon with the command below
# NOTE: this might give you many warnings along the lines of: "Chicory warning: classfile version is out of date and may not be processed correctly,"
#   depending on the JUnit jar that is used. Because we ignore all JUnit output anyway, it is safe to ignore these warnings.
# NOTE: you will also see a warning that starts with "No return from procedure observed 340 times. Unmatched entries are ignored!"
#   this is because Daikon will not analyze a method if an exception is thrown every time it is run. that happens in many validation tests
java -cp ./target/classes:./target/test-classes:./junit-4.13.1.jar:./hamcrest-core-1.3.jar:$DAIKONDIR/daikon.jar daikon.Chicory --ppt-omit-pattern='org.junit|junit.framework' --daikon --comparability-file=JUnitCore.decls-DynComp org.junit.runner.JUnitCore com.github.pedrovgs.problem55.RewriteRowAndColumnsWithZerosTest com.github.pedrovgs.problem52.ReplaceSpacesTest com.github.pedrovgs.problem64.GetTheElementInTheMiddleOfTheListTest com.github.pedrovgs.problem63.ConstantComplexityOrderStackTest com.github.pedrovgs.problem37.PathCalculatorTest com.github.pedrovgs.problem30.ScientificNotationTest com.github.pedrovgs.problem39.MultiplyArrayElementsTest com.github.pedrovgs.problem62.PalindromeListTest com.github.pedrovgs.problem65.IsTreeBalancedTest com.github.pedrovgs.problem53.CompressStringTest com.github.pedrovgs.problem54.RotateMatrixTest com.github.pedrovgs.problem38.PathToEveryLeafTest com.github.pedrovgs.problem31.FindLongestConsecutiveSequenceTest com.github.pedrovgs.problem36.AvlTreeMedianTest com.github.pedrovgs.problem14.BinaryTreePreOrderTest com.github.pedrovgs.problem13.BinaryTreeByLevelTest com.github.pedrovgs.problem25.AnagramsTest com.github.pedrovgs.problem22.ReverseLinkedListTest com.github.pedrovgs.problem49.CombinationsOfChangeTest com.github.pedrovgs.problem1.BitsCounterTest com.github.pedrovgs.problem6.MergeSortedArraysTest com.github.pedrovgs.problem71.ReverseBinaryNumberTest com.github.pedrovgs.problem78.AutoBoxingTrickTest com.github.pedrovgs.problem47.ReturnChangeTest com.github.pedrovgs.problem8.SplitArrayTest com.github.pedrovgs.problem40.MoveElementsToPositionsTest com.github.pedrovgs.problem23.RemoveCommentsTest com.github.pedrovgs.problem24.SortedArrayToBSTTest com.github.pedrovgs.problem12.MoveZerosInArrayTest com.github.pedrovgs.problem15.BinaryTreeInOrderTest com.github.pedrovgs.problem9.FactorialTest com.github.pedrovgs.problem41.GoThroughMatrixInSpiralTest com.github.pedrovgs.problem46.BinaryTreeSerializationTest com.github.pedrovgs.problem7.FibonacciNumbersTest com.github.pedrovgs.problem70.ReverseOrderOfBinaryNumberTest com.github.pedrovgs.problem48.WordSearchTest com.github.pedrovgs.problem33.SimpleRegularExpressionTest com.github.pedrovgs.problem34.DotRegularExpressionTest com.github.pedrovgs.problem51.ReverseStringTest com.github.pedrovgs.problem56.IsRotationUsingIsSubstringTest com.github.pedrovgs.problem69.BitsToTransformTest com.github.pedrovgs.problem60.PartitionListTest com.github.pedrovgs.problem67.MergeBinaryNumbersTest com.github.pedrovgs.problem58.FindKthElementTest com.github.pedrovgs.problem35.AsteriskRegularExpressionTest com.github.pedrovgs.problem32.ContainsTest com.github.pedrovgs.problem66.TreeToListByLevelTest com.github.pedrovgs.problem59.DeleteListNodeTest com.github.pedrovgs.problem61.SumListsTest com.github.pedrovgs.problem57.RemoveListDuplicatedElementsTest com.github.pedrovgs.problem68.IsEvenTest com.github.pedrovgs.problem50.UniqueCharsTest com.github.pedrovgs.problem5.DivideUsingSubtractionTest com.github.pedrovgs.problem72.FindTheMissingNumberTest com.github.pedrovgs.problem2.VectorScalarProductTest com.github.pedrovgs.problem43.CombinationOfIntegersTest com.github.pedrovgs.problem44.FindMinNumberAtPositionTest com.github.pedrovgs.problem10.RemoveDuplicatesTest com.github.pedrovgs.problem17.BinaryTreeEqualsTest com.github.pedrovgs.problem28.FindSumsTest com.github.pedrovgs.problem21.LowestCommonAncestorTest com.github.pedrovgs.problem26.PalindromesTest com.github.pedrovgs.problem19.BinaryTreeDepthTest com.github.pedrovgs.problem45.FindNthMostRepeatedElementTest com.github.pedrovgs.problem42.FloodFillTest com.github.pedrovgs.problem3.SumBinaryNumberTest com.github.pedrovgs.problem4.SquareRootTest com.github.pedrovgs.problem73.SubtractAddingTest com.github.pedrovgs.problem27.ReverseSentenceTest com.github.pedrovgs.problem18.IsBSTTest com.github.pedrovgs.problem20.MultiplicationWithoutMultiplyTest com.github.pedrovgs.problem16.BinaryTreePostOrderTest com.github.pedrovgs.problem29.AreAnagramsTest com.github.pedrovgs.problem11.IntToStringTest

View the output of the last command here.

After running these commands, you will have a (misleadingly-named) JUnitCore.inv.gz file containing all of the invariants found on the source code. After un-gzipping, the file JUnitCore.inv will be a serialized form of the daikon.PptMap class.

gunzip JUnitCore.inv.gz
javac -cp .:$DAIKONDIR/daikon.jar ReadDaikonInvariants.java
java -cp .:$DAIKONDIR/daikon.jar ReadDaikonInvariants JUnitCore.inv