From 26c0578aeb6250dc02c3c248620db82f0eac0f2b Mon Sep 17 00:00:00 2001 From: Mirco Dotta <mirco.dotta@gmail.com> Date: Wed, 15 Jul 2009 09:26:35 +0000 Subject: [PATCH] deleted Test*.scala. Now we have enough examples in the examples folder to describe how funcheck works --- Test1.scala | 35 ----------------- Test2.scala | 31 --------------- Test3.scala | 20 ---------- Test4.scala | 51 ------------------------- test-leftist | 105 --------------------------------------------------- test-splay | 105 --------------------------------------------------- 6 files changed, 347 deletions(-) delete mode 100644 Test1.scala delete mode 100644 Test2.scala delete mode 100644 Test3.scala delete mode 100644 Test4.scala delete mode 100755 test-leftist delete mode 100755 test-splay diff --git a/Test1.scala b/Test1.scala deleted file mode 100644 index 89b0d32b0..000000000 --- a/Test1.scala +++ /dev/null @@ -1,35 +0,0 @@ -import funcheck.lib.Specs -import funcheck.lib.Specs.generator -import org.scalacheck.{Gen, Arbitrary,Prop} - -object HeapTest extends Application { - sealed abstract class Middle extends Top - case class E() extends Middle - @generator sealed abstract class Top - case class Elem(i: Int, j: Int) - - @generator def create(): E = E() - //@generator def create2(i: Int): Elem = Elem(i) - - def genE = Gen.value(E()) - def genE2 = Gen.value(E()) - - @generator - def genElemSynthetic(a: Int, b: Int) = Elem(a,b) - - def genElem = for { - v2 <- Arbitrary.arbitrary[Int] - v1 <- Arbitrary.arbitrary[Int] - } yield Elem(v2,v2) - - implicit def arbE: Arbitrary[E] = Arbitrary(Gen.oneOf(genE,genE2)) - - Specs.forAll[(Int,Int)]( p => p._1 + p._2 == p._2 + p._1 ) - - //Specs.forAll[Int]( p => p == p) - Prop.forAll((a: Int,b: Int) => a+b == b+a) - Prop.forAll((a: Int,b: Int, c: Int) => a+b+c == b+a+c) - - - Prop.forAll((a: E) => a == a) -} \ No newline at end of file diff --git a/Test2.scala b/Test2.scala deleted file mode 100644 index 667c7e1ae..000000000 --- a/Test2.scala +++ /dev/null @@ -1,31 +0,0 @@ -import funcheck.lib.Specs._ -import org.scalacheck.{Gen, Arbitrary} - -object HeapTest { - @generator - sealed abstract class Tree - case class Leaf() extends Tree - case class Node(left: Tree, right: Tree, v:Int) extends Tree - - @generator def create(left: Tree, right: Tree, v: Int): Node = Node(left,right,v) - - case class Elem (i: Int, j: Int, k: Int) - - def genElem: Gen[Elem] = for { - i <- Arbitrary.arbitrary[Int] - j <- Arbitrary.arbitrary[Int] - k <- Arbitrary.arbitrary[Int] - } yield Elem(i,j,k) - - def genLeaf = Gen.value(Leaf()) - def genTree: Gen[Tree] = Gen.oneOf(genLeaf,genNode) - def genNode = for { - v1 <- Arbitrary.arbitrary[Tree] - v2 <- Arbitrary.arbitrary[Tree] - v3 <- Arbitrary.arbitrary[Int] - } yield Node(v1,v2,v3) - - implicit def arbTree: Arbitrary[Tree] = Arbitrary(genTree) - - -} \ No newline at end of file diff --git a/Test3.scala b/Test3.scala deleted file mode 100644 index 705509819..000000000 --- a/Test3.scala +++ /dev/null @@ -1,20 +0,0 @@ -import funcheck.lib.Specs._ -import org.scalacheck.{Gen, Arbitrary} - -object HeapTest { - - @generator sealed abstract class Tree - case class Node(left: Tree, right: Tree) extends Tree - case class Leaf() extends Tree - - def genLeaf: Gen[Leaf] = Gen.value[Leaf](Leaf()) - - def genNode: Gen[Node] = for { - v1 <- Arbitrary.arbitrary[Tree] - v2 <- Arbitrary.arbitrary[Tree] - } yield Node(v1,v2) - - implicit def arbTree: Arbitrary[Tree] = Arbitrary(genTree) - def genTree: Gen[Tree] = Gen.oneOf(genLeaf,genNode) - -} \ No newline at end of file diff --git a/Test4.scala b/Test4.scala deleted file mode 100644 index 32789c7de..000000000 --- a/Test4.scala +++ /dev/null @@ -1,51 +0,0 @@ - - -object HeapTest extends Application { - - /* - import org.scalacheck.Prop - import org.scalacheck.Prop._ - forAll{(l1: List[Int], l2: List[Int]) => (l1 ++ l2).size == l1.size + l2.size} - */ - - - //import funcheck.lib.Specs._ -// import org.scalacheck.Prop._ -// import org.scalacheck.Test.check -// val prop = forAll{ p: Int => forAll{ v: Int => v + p == p + v}} -// check(prop) - - //import org.scalacheck.Prop._ - import funcheck.lib.Specs._ - forAll{ p: Int => forAll{ v: Int => v + p == p + v}} -// forAll[(Int,Int)]{it=> true} -// forAll{it: List[Int] => true} - - - //forAll[(Array[Int], Array[Int])]{ lists => (lists._1 ++ lists._2).size == lists._1.size + lists._2.size} - - - //val p = 3 - -// import org.scalacheck.Prop._ -// import org.scalacheck.ConsoleReporter.testStatsEx -// import org.scalacheck.Test.check - - //p >= 0 ==> p > 0 - - - //forAll{ p: Int => p > 1 ==> p >= 0} - -// val prop = forAll{ p: Int => p > 1 ==> p >= 0} -// testStatsEx(check(prop)) - //Prop.forAll{ p: Int => Prop.==>(p >= 0, p > 0)} - - //works -// forAll[Int]( p => forAll[Int]( v => v + p == p + v)) -// forAll[(Int,Int)]( p => p._1 + p._2 == p._2 + p._1) - - //fails! -// forAll[Int]( p => p == 0) - - -} \ No newline at end of file diff --git a/test-leftist b/test-leftist deleted file mode 100755 index 64a0291a9..000000000 --- a/test-leftist +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -echo -echo "********************************************************************************" -echo "** COMPILE AND RUN EXAMPLES **" -echo "********************************************************************************" -echo - -echo -echo "********************************************************************************" -echo "Compile and Build the distribution using ANT" -echo "********************************************************************************" -echo - -# first clean -#ant clean -# and build the distribution -ant dist - -# Note: -# When the distribution is builded the script scalac-funcheck should be created. -# This will be used to compile the examples since the Funcheck compiler plugin -# will take care of transforming the Specs.forAll calls into ScalaCheck forAll -# ones. - -echo -echo "********************************************************************************" -echo "Check that needed scripts and libraries are available." -echo "********************************************************************************" -echo - -export SCALAC_SCRIPT="scalac-funcheck" -export SCALACHECK_JAR="lib/ScalaCheck-1.5.jar" - -if [ -e "$SCALAC_SCRIPT" ] -then - echo "[OK] ${SCALAC_SCRIPT} script found." - if [ -e "${SCALACHECK_JAR}" ] - then - echo "[OK] ${SCALACHECK_JAR} found." - else - echo "[ERROR] ${SCALACHECK_JAR} NOT found." - echo "Please correct this and try again." - return -1 - fi -else - echo "[ERROR] ${SCALAC_SCRIPT} script NOT found." - echo "Please correct this and try again." - return -1 -fi - - -echo -echo "********************************************************************************" -echo "Compile tests that have declared forAll properties." -echo "********************************************************************************" -echo - - -#This is needed for aliases to work correctly -shopt -s expand_aliases; - - -alias scalac=".././scalac-funcheck -cp ../bin:../lib/ScalaCheck-1.5.jar -d ../bin/tests" - -mkdir bin/tests -cd tests - -scalac plugin/LeftistHeap.scala - -cd .. - -# Scala compiler with the Funcheck plugin integrated -#alias scalac="./scalac-funcheck" - -# compile examples using the compiler with the Funcheck plugin -#ant compile-funcheck-tests - - -echo -echo "********************************************************************************" -echo "Running tests with forAll properties." -echo "********************************************************************************" -echo - -alias scala="scala -cp bin/:${SCALACHECK_JAR}:bin/tests/" - -# examples -export BST="plugin.BST" -export LeftistHeap="plugin.LeftistHeap" -export ListSet="plugin.ListSet" -export LambdaEvaluator="plugin.LambdaEvaluator" -export PropositionalLogic="plugin.PropositionalLogic" -export SetRedBlackTree="plugin.SetRedBlackTree" -export ConsSnoc="plugin.ConsSnoc" - -export InsertSort="plugin.kawaguchi.InsertSort" -export MergeSort="plugin.kawaguchi.MergeSort" -export MergeSortBug="plugin.kawaguchi.MergeSortBug" -export QuickSort="plugin.kawaguchi.QuickSort" -export MapReduce="plugin.kawaguchi.MapReduce" -export SplayHeap="plugin.kawaguchi.SplayHeap" - -echo " - Testing ${LeftistHeap}" -scala ${LeftistHeap} diff --git a/test-splay b/test-splay deleted file mode 100755 index fc7f0ba5e..000000000 --- a/test-splay +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -echo -echo "********************************************************************************" -echo "** COMPILE AND RUN EXAMPLES **" -echo "********************************************************************************" -echo - -echo -echo "********************************************************************************" -echo "Compile and Build the distribution using ANT" -echo "********************************************************************************" -echo - -# first clean -#ant clean -# and build the distribution -ant dist - -# Note: -# When the distribution is builded the script scalac-funcheck should be created. -# This will be used to compile the examples since the Funcheck compiler plugin -# will take care of transforming the Specs.forAll calls into ScalaCheck forAll -# ones. - -echo -echo "********************************************************************************" -echo "Check that needed scripts and libraries are available." -echo "********************************************************************************" -echo - -export SCALAC_SCRIPT="scalac-funcheck" -export SCALACHECK_JAR="lib/ScalaCheck-1.5.jar" - -if [ -e "$SCALAC_SCRIPT" ] -then - echo "[OK] ${SCALAC_SCRIPT} script found." - if [ -e "${SCALACHECK_JAR}" ] - then - echo "[OK] ${SCALACHECK_JAR} found." - else - echo "[ERROR] ${SCALACHECK_JAR} NOT found." - echo "Please correct this and try again." - return -1 - fi -else - echo "[ERROR] ${SCALAC_SCRIPT} script NOT found." - echo "Please correct this and try again." - return -1 -fi - - -echo -echo "********************************************************************************" -echo "Compile tests that have declared forAll properties." -echo "********************************************************************************" -echo - - -#This is needed for aliases to work correctly -shopt -s expand_aliases; - - -alias scalac=".././scalac-funcheck -cp ../bin:../lib/ScalaCheck-1.5.jar -d ../bin/tests" - -mkdir bin/tests -cd tests - -scalac plugin/kawaguchi/SplayHeap.scala - -cd .. - -# Scala compiler with the Funcheck plugin integrated -#alias scalac="./scalac-funcheck" - -# compile examples using the compiler with the Funcheck plugin -#ant compile-funcheck-tests - - -echo -echo "********************************************************************************" -echo "Running tests with forAll properties." -echo "********************************************************************************" -echo - -alias scala="scala -cp bin/:${SCALACHECK_JAR}:bin/tests/" - -# examples -export BST="plugin.BST" -export LeftistHeap="plugin.LeftistHeap" -export ListSet="plugin.ListSet" -export LambdaEvaluator="plugin.LambdaEvaluator" -export PropositionalLogic="plugin.PropositionalLogic" -export SetRedBlackTree="plugin.SetRedBlackTree" -export ConsSnoc="plugin.ConsSnoc" - -export InsertSort="plugin.kawaguchi.InsertSort" -export MergeSort="plugin.kawaguchi.MergeSort" -export MergeSortBug="plugin.kawaguchi.MergeSortBug" -export QuickSort="plugin.kawaguchi.QuickSort" -export MapReduce="plugin.kawaguchi.MapReduce" -export SplayHeap="plugin.kawaguchi.SplayHeap" - -echo " - Testing ${SplayHeap}" -scala ${SplayHeap} -- GitLab