From c0263d4d190bdc2df491abb40a8b84cee7e8dd62 Mon Sep 17 00:00:00 2001 From: Wim Hueskes Date: Sun, 17 Apr 2016 16:55:10 +0200 Subject: [PATCH 3/6] move test scripts to tests subdirectory --- .gitignore | 3 +++ Makefile.am | 1 + configure.in.in | 1 + panel-plugin/Makefile.am | 6 ------ panel-plugin/calctest.c | 2 +- panel-plugin/test-func.awk | 15 --------------- panel-plugin/test-minus.awk | 14 -------------- panel-plugin/test-pow.awk | 14 -------------- panel-plugin/test-simple-expr.awk | 14 -------------- tests/Makefile.am | 11 +++++++++++ tests/test-func.awk | 15 +++++++++++++++ tests/test-minus.awk | 14 ++++++++++++++ tests/test-pow.awk | 14 ++++++++++++++ tests/test-simple-expr.awk | 14 ++++++++++++++ 14 files changed, 74 insertions(+), 64 deletions(-) delete mode 100755 panel-plugin/test-func.awk delete mode 100755 panel-plugin/test-minus.awk delete mode 100755 panel-plugin/test-pow.awk delete mode 100755 panel-plugin/test-simple-expr.awk create mode 100644 tests/Makefile.am create mode 100755 tests/test-func.awk create mode 100755 tests/test-minus.awk create mode 100755 tests/test-pow.awk create mode 100755 tests/test-simple-expr.awk diff --git a/.gitignore b/.gitignore index 3fb3a10..98fc332 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ po/POTFILES po/stamp-it stamp-h1 test-driver +panel-plugin/calctest +tests/*.log +tests/*.trs diff --git a/Makefile.am b/Makefile.am index 7a244fb..a04b36a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ SUBDIRS = \ icons \ panel-plugin \ + tests \ po distclean-local: diff --git a/configure.in.in b/configure.in.in index d2d0efe..15da0a4 100644 --- a/configure.in.in +++ b/configure.in.in @@ -93,6 +93,7 @@ AC_SUBST([PLATFORM_LDFLAGS]) AC_OUTPUT([ Makefile panel-plugin/Makefile +tests/Makefile po/Makefile.in icons/Makefile icons/16x16/Makefile diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am index 3865199..09db5dc 100644 --- a/panel-plugin/Makefile.am +++ b/panel-plugin/Makefile.am @@ -66,16 +66,10 @@ desktop_DATA = \ EXTRA_DIST = \ $(desktop_in_in_files) \ - $(TESTS) \ grammar.txt CLEANFILES = \ $(desktop_in_files) \ $(desktop_DATA) -TESTS = \ - test-simple-expr.awk \ - test-minus.awk \ - test-pow.awk - # vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/panel-plugin/calctest.c b/panel-plugin/calctest.c index 0871201..f0518fd 100644 --- a/panel-plugin/calctest.c +++ b/panel-plugin/calctest.c @@ -51,7 +51,7 @@ void calc(const char *input, char *result, size_t result_len) g_error_free(err); } else if (parsetree) { r = eval_parse_tree(parsetree, FALSE); - snprintf(result, result_len, "%g\n", r); + snprintf(result, result_len, "%.19g\n", r); } else snprintf(result, result_len, "böö\n"); free_parsetree(parsetree); diff --git a/panel-plugin/test-func.awk b/panel-plugin/test-func.awk deleted file mode 100755 index 8314dd6..0000000 --- a/panel-plugin/test-func.awk +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/awk -f - -function abs(x) { - return (x < 0) ? -x : x -} - -BEGIN{ - expr = "'sqrt(1) + log(1) + ln(1) + exp(1) + sin(1) + cos(1) + tan(1) + asin(1) + arcsin(1) + acos(1) + arccos(1) + atan(1) + arctan(1) + log2(1) + log10(1) + lg(1) + abs(1) + cbrt(1)'" - "./calctest " expr | getline res - if (abs(res - 3.0) > 1.0e-15) { - print res - exit 1 - } else - exit 0 -} diff --git a/panel-plugin/test-minus.awk b/panel-plugin/test-minus.awk deleted file mode 100755 index f2dd8b6..0000000 --- a/panel-plugin/test-minus.awk +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/awk -f - -function abs(x) { - return (x < 0) ? -x : x -} - -BEGIN{ - "./calctest '10 - 4 - 3'" | getline res - if (abs(res - 3.0) > 1.0e-15) { - print res - exit 1 - } else - exit 0 -} diff --git a/panel-plugin/test-pow.awk b/panel-plugin/test-pow.awk deleted file mode 100755 index 3ba7445..0000000 --- a/panel-plugin/test-pow.awk +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/awk -f - -function abs(x) { - return (x < 0) ? -x : x -} - -BEGIN{ - "./calctest '4^3**2'" | getline res - if (abs(res - 4096) > 1.0e-15) { - print res - exit 1 - } else - exit 0 -} diff --git a/panel-plugin/test-simple-expr.awk b/panel-plugin/test-simple-expr.awk deleted file mode 100755 index cc743ff..0000000 --- a/panel-plugin/test-simple-expr.awk +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/awk -f - -function abs(x) { - return (x < 0) ? -x : x -} - -BEGIN{ - "./calctest '4.5 + 7/2'" | getline res - if (abs(res - 8.0) > 1.0e-15) { - print res - exit 1 - } else - exit 0 -} diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..0c3bd33 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,11 @@ +# $Id$ + +EXTRA_DIST = \ + $(TESTS) + +TESTS = \ + test-simple-expr.awk \ + test-minus.awk \ + test-pow.awk + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/tests/test-func.awk b/tests/test-func.awk new file mode 100755 index 0000000..89f6424 --- /dev/null +++ b/tests/test-func.awk @@ -0,0 +1,15 @@ +#!/usr/bin/awk -f + +function abs(x) { + return (x < 0) ? -x : x +} + +BEGIN{ + expr = "'sqrt(1) + log(1) + ln(1) + exp(1) + sin(1) + cos(1) + tan(1) + asin(1) + arcsin(1) + acos(1) + arccos(1) + atan(1) + arctan(1) + log2(1) + log10(1) + lg(1) + abs(1) + cbrt(1)'" + "../panel-plugin/calctest " expr | getline res + if (abs(res - 3.0) > 1.0e-15) { + print res + exit 1 + } else + exit 0 +} diff --git a/tests/test-minus.awk b/tests/test-minus.awk new file mode 100755 index 0000000..3becc3a --- /dev/null +++ b/tests/test-minus.awk @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f + +function abs(x) { + return (x < 0) ? -x : x +} + +BEGIN{ + "../panel-plugin/calctest '10 - 4 - 3'" | getline res + if (abs(res - 3.0) > 1.0e-15) { + print res + exit 1 + } else + exit 0 +} diff --git a/tests/test-pow.awk b/tests/test-pow.awk new file mode 100755 index 0000000..34deebf --- /dev/null +++ b/tests/test-pow.awk @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f + +function abs(x) { + return (x < 0) ? -x : x +} + +BEGIN{ + "../panel-plugin/calctest '4^3**2'" | getline res + if (abs(res - 4096) > 1.0e-15) { + print res + exit 1 + } else + exit 0 +} diff --git a/tests/test-simple-expr.awk b/tests/test-simple-expr.awk new file mode 100755 index 0000000..0f5a1bf --- /dev/null +++ b/tests/test-simple-expr.awk @@ -0,0 +1,14 @@ +#!/usr/bin/awk -f + +function abs(x) { + return (x < 0) ? -x : x +} + +BEGIN{ + "../panel-plugin/calctest '4.5 + 7/2'" | getline res + if (abs(res - 8.0) > 1.0e-15) { + print res + exit 1 + } else + exit 0 +} -- 2.1.4