From eeb079f414792863a4da550ffc937a9a32f7c10e Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 28 Oct 2014 21:52:22 +0100
Subject: [PATCH] make former derivation and integral tests working

---
 aderivation2/src/aderivation.cpp |  2 +-
 aintegral2/src/aintegral.cpp     |  2 +-
 makefile                         |  2 ++
 tests.aderivation.aintegral.sh   | 36 +++++++++++++++++---------------
 4 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/aderivation2/src/aderivation.cpp b/aderivation2/src/aderivation.cpp
index b09584aa34..6770a8202b 100644
--- a/aderivation2/src/aderivation.cpp
+++ b/aderivation2/src/aderivation.cpp
@@ -42,7 +42,7 @@ int main(int argc, char** argv) {
 			}
 		}
 
-		if(false){
+		{
 			regexp::RegExp regexp = alib::DataFactory::fromTokens<regexp::RegExp>(regexpTokens);
 			string::LinearString string = alib::DataFactory::fromTokens<string::LinearString>(stringTokens);
 			alib::DataFactory::toStdout(regexp::RegExpDerivation::derivation(regexp, string));
diff --git a/aintegral2/src/aintegral.cpp b/aintegral2/src/aintegral.cpp
index 0fc59797f7..d7098448dc 100644
--- a/aintegral2/src/aintegral.cpp
+++ b/aintegral2/src/aintegral.cpp
@@ -42,7 +42,7 @@ int main(int argc, char** argv) {
 			}
 		}
 
-		if(false){
+		{
 			regexp::RegExp regexp = alib::DataFactory::fromTokens<regexp::RegExp>(regexpTokens);
 			string::LinearString string = alib::DataFactory::fromTokens<string::LinearString>(stringTokens);
 			alib::DataFactory::toStdout(regexp::RegExpIntegral::integral(regexp, string));
diff --git a/makefile b/makefile
index 59365399d4..1fabc55a27 100644
--- a/makefile
+++ b/makefile
@@ -53,6 +53,7 @@ debug  : all-debug
 	    cp $$dir/bin-debug/* $(addsuffix -debug, $(BINFOLDER)); \
 	done
 	./tests.aconversion.sh debug
+	./tests.aderivation.aintegral.sh debug
 
 release: all-release
 	mkdir -p $(addsuffix -release, $(BINFOLDER))
@@ -64,6 +65,7 @@ release: all-release
 	    cp $$dir/bin-release/* $(addsuffix -release, $(BINFOLDER)); \
 	done
 	./tests.aconversion.sh release
+	./tests.aderivation.aintegral.sh debug
 
 clean  : clean-debug   clean-release
 	$(RM) -r bin-debug bin-release
diff --git a/tests.aderivation.aintegral.sh b/tests.aderivation.aintegral.sh
index 9b25a30dfd..ce8107e561 100755
--- a/tests.aderivation.aintegral.sh
+++ b/tests.aderivation.aintegral.sh
@@ -1,25 +1,27 @@
 #!/usr/bin/env bash
 
+# $1 test dir suffix (debug / release)
+
 set -o pipefail
 
-EXECUTABLES="aepsilon atrim adeterminize aminimize anormalize adiff.automaton aderivation aintegral"
-TESTS_DIR="../examples/regexp"
+EXECUTABLES="aepsilon2 atrim2 adeterminize2 aminimize2 anormalize2 adiff2 aderivations2 aintegral2 aconversions2"
+TESTS_DIR="../examples2/regexp"
 
 # ----------------------------
 
 for FILE in $EXECUTABLES; do
-	if [ ! -f bin/$FILE ]; then
-		echo "Executable" $FILE "is required for testing. Make sure it is in bin folder."
+	if [ ! -f bin-$1/$FILE ]; then
+		echo "Executable $FILE is required for testing. Make sure it is in bin-$1 folder."
 		exit 1
 	fi
 done
 
-cd bin/
+cd bin-$1/
 
 # ----------------------------
 
 function regexpToMDFA {
-	echo "$1" | ./aconversion -t FSM | ./aepsilon | ./atrim | ./adeterminize -t FSM | ./aminimize | ./anormalize
+	echo "$1" | ./aconversions2 -t FSM | ./aepsilon2 | ./atrim2 | ./adeterminize2 -t FSM | ./aminimize2 | ./anormalize2
 }
 
 function compareRegexp {
@@ -27,7 +29,7 @@ function compareRegexp {
     regexpToMDFA "$2" > tmp2.xml
 
 	# relies on ret code by adiff.automaton
-	./adiff.automaton tmp1.xml tmp2.xml > /dev/null
+	./adiff2 tmp1.xml tmp2.xml > /dev/null
 	RET=$?
 	rm tmp1.xml tmp2.xml
 
@@ -61,7 +63,7 @@ function runTestD {
     FILE_REGEXP_RESULT=$(echo "$2")
     shift 2
 
-    REGEXP_DERIVATIVE=$(cat $TESTS_DIR/$FILE_REGEXP_ORIG | ./aderivation $@) 
+    REGEXP_DERIVATIVE=$(./aconvert2 --string_from_string <<< "$1" | ./aderivations2 -r $TESTS_DIR/$FILE_REGEXP_ORIG -s - )
     REGEXP_RESULT=$(cat $TESTS_DIR/$FILE_REGEXP_RESULT)
     runTest "$REGEXP_DERIVATIVE" "$REGEXP_RESULT"
 }
@@ -71,7 +73,7 @@ function runTestI {
     FILE_REGEXP_RESULT=$(echo "$2")
     shift 2
 
-    REGEXP_INTEGRAL=$(cat $TESTS_DIR/$FILE_REGEXP_ORIG | ./aintegral $@) 
+    REGEXP_INTEGRAL=$(./aconvert2 --string_from_string <<< "$1" | ./aintegral2 -r $TESTS_DIR/$FILE_REGEXP_ORIG -s - )
     REGEXP_RESULT=$(cat $TESTS_DIR/$FILE_REGEXP_RESULT)
 
     runTest "$REGEXP_INTEGRAL" "$REGEXP_RESULT"
@@ -80,17 +82,17 @@ function runTestI {
 
 # derivatives
 echo "Derivatives"
-runTestD "oppa-4-13.xml" "oppa-4-13.d0.xml" "0"
-runTestD "oppa-4-13.xml" "oppa-4-13.d00.xml" "0" "0"
-runTestD "oppa-4-14.xml" "oppa-4-14.d1.xml" "1"
-runTestD "oppa-4-14.xml" "oppa-4-14.d10.xml" "1" "0"
-runTestD "oppa-4-15.xml" "oppa-4-15.d100.xml" "1" "0" "0"
+runTestD "unbounded.oppa.4.13.xml" "unbounded.oppa.4.13.d0.xml" "\"0\""
+runTestD "unbounded.oppa.4.13.xml" "unbounded.oppa.4.13.d00.xml" "\"0 0\""
+runTestD "unbounded.oppa.4.14.xml" "unbounded.oppa.4.14.d1.xml" "\"1\""
+runTestD "unbounded.oppa.4.14.xml" "unbounded.oppa.4.14.d10.xml" "\"1 0\""
+runTestD "unbounded.oppa.4.15.xml" "unbounded.oppa.4.15.d100.xml" "\"1 0 0\""
 
 # integrals 
 echo ""
 echo "Integrals"
-runTestI "oppa-4-16.xml" "oppa-4-16.i1.xml" "1"
-runTestI "Melichar2-94.xml" "Melichar2-94.i0.xml" "0"
-runTestI "Melichar2-94.xml" "Melichar2-94.i1.xml" "1"
+runTestI "unbounded.oppa.4.16.xml" "unbounded.oppa.4.16.i1.xml" "\"1\""
+runTestI "Melichar2-94.xml" "Melichar2-94.i0.xml" "\"0\""
+runTestI "Melichar2-94.xml" "Melichar2-94.i1.xml" "\"1\""
 
 echo ""
-- 
GitLab