URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-09-19 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add tests on function templates
* check.sh: Add a summary feature.
* config: Add the all-in-one test.
* function/c++_ast/definition_005.aterm,
* function/c++_ast/definition_007.aterm,
* function/c++_ast/parameters_arguments_001.aterm,
* function/c++_ast/parameters_arguments_003.aterm,
* function/c++_ast/parameters_arguments_005.aterm: Update regarding
* the translator changes.
* function/c++_src/definition_004.cc: New.
* function/c++_src/definition_005.cc: New.
* function/c++_src/definition_006.cc: New.
* function/c++_src/definition_007.cc: New.
* function/c++_src/parameters_arguments_001.cc: New.
* function/c++_src/parameters_arguments_002.cc: New.
* function/c++_src/parameters_arguments_003.cc: New.
* function/c++_src/parameters_arguments_005.cc: New.
check.sh | 24 +++++++++++++++++++++---
config | 15 +++++++++++++++
function/c++_ast/definition_005.aterm | 2 +-
function/c++_ast/definition_007.aterm | 2 +-
function/c++_ast/parameters_arguments_001.aterm | 2 +-
function/c++_ast/parameters_arguments_003.aterm | 2 +-
function/c++_ast/parameters_arguments_005.aterm | 2 +-
function/c++_src/definition_004.cc | 5 +++++
function/c++_src/definition_005.cc | 4 ++++
function/c++_src/definition_006.cc | 4 ++++
function/c++_src/definition_007.cc | 4 ++++
function/c++_src/parameters_arguments_001.cc | 5 +++++
function/c++_src/parameters_arguments_002.cc | 5 +++++
function/c++_src/parameters_arguments_003.cc | 5 +++++
function/c++_src/parameters_arguments_005.cc | 5 +++++
15 files changed, 78 insertions(+), 8 deletions(-)
Index: branches/scool-ng/tests/config
===================================================================
--- branches/scool-ng/tests/config (revision 89)
+++ branches/scool-ng/tests/config (revision 90)
@@ -45,3 +45,18 @@
ref_extension=".cc"
}
+test_4 ()
+{
+ desc="Scool translator"
+ cmd='sglri -p ../../src/scl-syn/Scool.tbl -i $input_file | ../../src/scoolt/scoolt
| ../../src/pp-cxx/pp-cxx | abox2text'
+ cmp='diff -EwbB -u $ref $output'
+ print_input_cmd='cat $input_file'
+ print_output_cmd='cat $input_file'
+
+ input_files="scool_src/*.scl"
+ input_extension=".scl"
+
+ ref_dir="c++_src"
+ ref_extension=".cc"
+}
+
Index: branches/scool-ng/tests/function/c++_ast/parameters_arguments_001.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/parameters_arguments_001.aterm (revision 89)
+++ branches/scool-ng/tests/function/c++_ast/parameters_arguments_001.aterm (revision 90)
@@ -1 +1 @@
-CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("T"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a"))],CxxId("a"))])
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("T"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a"))],[CxxExpStm(CxxKeyword("return",CxxId("a")))])])
Index: branches/scool-ng/tests/function/c++_ast/parameters_arguments_003.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/parameters_arguments_003.aterm (revision 89)
+++ branches/scool-ng/tests/function/c++_ast/parameters_arguments_003.aterm (revision 90)
@@ -1 +1 @@
-CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("void"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a"))],CxxId("a"))])
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T"))],CxxType("void"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a"))],[CxxExpStm(CxxKeyword("return",CxxId("a")))])])
Index: branches/scool-ng/tests/function/c++_ast/definition_005.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/definition_005.aterm (revision 89)
+++ branches/scool-ng/tests/function/c++_ast/definition_005.aterm (revision 90)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("int"),CxxId("answer"),[],CxxInt("42"))])
+CxxProgram([CxxFun([],CxxType("int"),CxxId("answer"),[],[CxxExpStm(CxxKeyword("return",CxxInt("42")))])])
Index: branches/scool-ng/tests/function/c++_ast/parameters_arguments_005.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/parameters_arguments_005.aterm (revision 89)
+++ branches/scool-ng/tests/function/c++_ast/parameters_arguments_005.aterm (revision 90)
@@ -1 +1 @@
-CxxProgram([CxxFun([(CxxType("typename"),CxxId("T")),(CxxType("typename"),CxxId("U"))],CxxType("T"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a")),(CxxConstType(CxxRefType(CxxType("U"))),CxxId("b"))],CxxId("a"))])
+CxxProgram([CxxFun([(CxxType("typename"),CxxId("T")),(CxxType("typename"),CxxId("U"))],CxxType("T"),CxxId("f"),[(CxxConstType(CxxRefType(CxxType("T"))),CxxId("a")),(CxxConstType(CxxRefType(CxxType("U"))),CxxId("b"))],[CxxExpStm(CxxKeyword("return",CxxId("a")))])])
Index: branches/scool-ng/tests/function/c++_ast/definition_007.aterm
===================================================================
--- branches/scool-ng/tests/function/c++_ast/definition_007.aterm (revision 89)
+++ branches/scool-ng/tests/function/c++_ast/definition_007.aterm (revision 90)
@@ -1 +1 @@
-CxxProgram([CxxFun([],CxxType("int"),CxxId("sum"),[(CxxType("int"),CxxId("a")),(CxxType("int"),CxxId("b"))],CxxSum(CxxId("a"),CxxId("b")))])
+CxxProgram([CxxFun([],CxxType("int"),CxxId("sum"),[(CxxType("int"),CxxId("a")),(CxxType("int"),CxxId("b"))],[CxxExpStm(CxxKeyword("return",CxxSum(CxxId("a"),CxxId("b"))))])])
Index: branches/scool-ng/tests/function/c++_src/parameters_arguments_001.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/parameters_arguments_001.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/parameters_arguments_001.cc (revision 90)
@@ -0,0 +1,5 @@
+template < typename T >
+T f(const T& a)
+{
+ return a;
+}
Index: branches/scool-ng/tests/function/c++_src/parameters_arguments_002.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/parameters_arguments_002.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/parameters_arguments_002.cc (revision 90)
@@ -0,0 +1,5 @@
+template < typename T >
+void f(const T& a)
+{
+ return a;
+}
Index: branches/scool-ng/tests/function/c++_src/parameters_arguments_003.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/parameters_arguments_003.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/parameters_arguments_003.cc (revision 90)
@@ -0,0 +1,5 @@
+template < typename T >
+void f(const T& a)
+{
+ return a;
+}
Index: branches/scool-ng/tests/function/c++_src/definition_004.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/definition_004.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/definition_004.cc (revision 90)
@@ -0,0 +1,5 @@
+int answer()
+{
+ const int i = 42;
+ return i;
+}
Index: branches/scool-ng/tests/function/c++_src/definition_005.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/definition_005.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/definition_005.cc (revision 90)
@@ -0,0 +1,4 @@
+int answer()
+{
+ return 42;
+}
Index: branches/scool-ng/tests/function/c++_src/parameters_arguments_005.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/parameters_arguments_005.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/parameters_arguments_005.cc (revision 90)
@@ -0,0 +1,5 @@
+template < typename T, typename U >
+T f(const T& a, const U& b)
+{
+ return a;
+}
Index: branches/scool-ng/tests/function/c++_src/definition_006.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/definition_006.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/definition_006.cc (revision 90)
@@ -0,0 +1,4 @@
+int sum(int a, int b)
+{
+ return a + b;
+}
Index: branches/scool-ng/tests/function/c++_src/definition_007.cc
===================================================================
--- branches/scool-ng/tests/function/c++_src/definition_007.cc (revision 0)
+++ branches/scool-ng/tests/function/c++_src/definition_007.cc (revision 90)
@@ -0,0 +1,4 @@
+int sum(int a, int b)
+{
+ return a + b;
+}
Index: branches/scool-ng/tests/check.sh
===================================================================
--- branches/scool-ng/tests/check.sh (revision 89)
+++ branches/scool-ng/tests/check.sh (revision 90)
@@ -19,6 +19,11 @@
utest_name_indent=6
test_result_indent=42
+stat_nb_tests=0
+stat_nb_succ_tests=0
+stat_nb_skip_tests=0
+stat_nb_fail_tests=0
+
indent ()
{
echo -e -n "\033[$1G"
@@ -26,6 +31,8 @@
perform_test()
{
+ stat_nb_tests=$(($stat_nb_tests + 1))
+
cexit_val=0
test_name=`basename "$1" "$2"`
@@ -81,14 +88,23 @@
cp -f $1 $2
}
+print_summary()
+{
+ echo -e " ${bblue}Summary"
+ echo -e " ${bgreen}Succeeds : " $stat_nb_succ_tests
+ echo -e " ${bred}Failures : " $stat_nb_fail_tests
+ echo -e " ${byell}Skips : " $stat_nb_skip_tests
+ echo -e " ${grey}Total : " $stat_nb_tests
+}
+
print_test_result()
{
echo -ne "$bblue[ "
- if [ "$1" = "ok" ]; then echo -ne "${bgreen}ok";
- elif [ "$1" = "ko" ]; then echo -ne "${bred}ko";
+ if [ "$1" = "ok" ]; then echo -ne "${bgreen}ok";
stat_nb_succ_tests=$(($stat_nb_succ_tests + 1));
+ elif [ "$1" = "ko" ]; then echo -ne "${bred}ko";
stat_nb_fail_tests=$(($stat_nb_fail_tests + 1));
elif [ "$1" = "gen" ]; then echo -ne "${bgreen}gen";
- else echo -ne "${byell}sk";
+ else echo -ne "${byell}sk"; stat_nb_skip_tests=$(($stat_nb_skip_tests
+ 1));
fi
echo -n -e " $bblue]"
@@ -301,3 +317,5 @@
do
perform_test_suite $dir "$tests"
done
+
+print_summary
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)