From c24b91e76897936e00a8d7fb8e635a466a92e28e Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Sat, 22 Apr 2017 14:32:36 -0400 Subject: [PATCH] tests: convert "dc" test to new framework The 'dc.sed' program (implementing dc calculator in sed) is kept as-is. The input (dc.inp) and expected output (dc.good) are merged into the new shell script. The old-style test executed two calculations at once (Easter 2002 and square root of 2). They are now separated into two invocations of 'dc.sed'. * testsuite/dc.sh: New test. * testsuite/dc.inp, testuite/dc.good: Removed. * testsuite/local.mk (EXTRA_DIST): Remove inp/good files. (SEDTEST): Remove dc.sed. (T): Add dc.sh. --- testsuite/dc.good | 3 --- testsuite/dc.inp | 14 ---------- testsuite/dc.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++ testsuite/local.mk | 9 +++---- 4 files changed, 68 insertions(+), 23 deletions(-) delete mode 100644 testsuite/dc.good delete mode 100644 testsuite/dc.inp create mode 100755 testsuite/dc.sh diff --git a/testsuite/dc.good b/testsuite/dc.good deleted file mode 100644 index 7604d56..0000000 --- a/testsuite/dc.good +++ /dev/null @@ -1,3 +0,0 @@ -31 -March 2002 -1.6A09E667A diff --git a/testsuite/dc.inp b/testsuite/dc.inp deleted file mode 100644 index 95e17a4..0000000 --- a/testsuite/dc.inp +++ /dev/null @@ -1,14 +0,0 @@ -# Compute Easter of 2002... -# usage: (echo YEAR; cat easter.dc) | dc - -2002 - -[ddsf[lfp[too early -]Pq]s@1583>@ -ddd19%1+sg100/1+d3*4/12-sx8*5+25/5-sz5*4/lx-10-sdlg11*20+lz+lx-30% -d[30+]s@0>@d[[1+]s@lg11<@]s@25=@d[1+]s@24=@se44le-d[30+]s@21>@dld+7%-7+ -[March ]smd[31-[April ]sm]s@31<@psnlmPpsn1z>p]splpx - -# Compute square root of 2 - -16oAk2vpq diff --git a/testsuite/dc.sh b/testsuite/dc.sh new file mode 100755 index 0000000..5f572ac --- /dev/null +++ b/testsuite/dc.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Test runner for dc.sed + +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed +print_ver_ sed + +fail=0 + + +# Compute Easter of 2002... +# usage: (echo YEAR; cat easter.dc) | dc.sed +cat << \EOF > easter.dc || framework_failure_ +[ddsf[lfp[too early +]Pq]s@1583>@ +ddd19%1+sg100/1+d3*4/12-sx8*5+25/5-sz5*4/lx-10-sdlg11*20+lz+lx-30% +d[30+]s@0>@d[[1+]s@lg11<@]s@25=@d[1+]s@24=@se44le-d[30+]s@21>@dld+7%-7+ +[March ]smd[31-[April ]sm]s@31<@psnlmPpsn1z>p]splpx +EOF + +cat <<\EOF > easter-exp || framework_failure_ +31 +March 2002 +EOF + + +# Compute square root of 2 +cat << \EOF > sqrt2-inp || framework_failure_ +16oAk2vpq +EOF + + +cat << \EOF > sqrt2-exp || framework_failure_ +1.6A09E667A +EOF + + +# location of external test files +dir="$abs_top_srcdir/testsuite" + +# Easter 2002 +( echo 2002 ; cat easter.dc ) | sed -n -f "$dir/dc.sed" > easter-out|| fail=1 +compare easter-exp easter-out || fail=1 + +# Square root of 2 +sed -n -f "$dir/dc.sed" sqrt2-inp > sqrt2-out || fail=1 +compare sqrt2-exp sqrt2-out || fail=1 + + + +Exit $fail diff --git a/testsuite/local.mk b/testsuite/local.mk index 16a6d90..a98b6fb 100644 --- a/testsuite/local.mk +++ b/testsuite/local.mk @@ -86,8 +86,8 @@ endif # Old tests converted to newer init.sh style T += testsuite/8bit.sh \ - testsuite/binary.sh - + testsuite/binary.sh \ + testsuite/dc.sh TESTS = $(check_PROGRAMS) $(SEDTESTS) $(T) @@ -120,8 +120,7 @@ SEDTESTS += testsuite/newjis \ testsuite/utf8-1 \ testsuite/utf8-2 testsuite/utf8-3 testsuite/utf8-4 \ testsuite/badenc testsuite/inplace-hold \ - testsuite/help \ - testsuite/dc + testsuite/help # Note that the first lines are statements. They ensure that environment # variables that can perturb tests are unset or set to expected values. @@ -195,8 +194,6 @@ EXTRA_DIST += \ testsuite/binary3.sed \ testsuite/bsd.good \ testsuite/bsd.sh \ - testsuite/dc.good \ - testsuite/dc.inp \ testsuite/dc.sed \ testsuite/distrib.good \ testsuite/distrib.inp \