Blame agen5/test/case.test

Packit Service 96b5d3
#! /bin/sh
Packit Service 96b5d3
#  -*- Mode: Shell-script -*-
Packit Service 96b5d3
# case.test --- test CASE functionality
Packit Service 96b5d3
#
Packit Service 96b5d3
# Author:            Bruce Korb <bkorb@gnu.org>
Packit Service 96b5d3
#
Packit Service 96b5d3
## This file is part of AutoGen.
Packit Service 96b5d3
## AutoGen Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is free software: you can redistribute it and/or modify it
Packit Service 96b5d3
## under the terms of the GNU General Public License as published by the
Packit Service 96b5d3
## Free Software Foundation, either version 3 of the License, or
Packit Service 96b5d3
## (at your option) any later version.
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is distributed in the hope that it will be useful, but
Packit Service 96b5d3
## WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 96b5d3
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit Service 96b5d3
## See the GNU General Public License for more details.
Packit Service 96b5d3
##
Packit Service 96b5d3
## You should have received a copy of the GNU General Public License along
Packit Service 96b5d3
## with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 96b5d3
Packit Service 96b5d3
. ./defs
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # TEMPLATE FILE # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.tpl
Packit Service 96b5d3
cat > ${testname}.tpl <<'EOF'
Packit Service 96b5d3
<= AutoGen5 template test =>
Packit Service 96b5d3
<=
Packit Service 96b5d3
FOR grp "\n" =><=
Packit Service 96b5d3
  CASE (get "nam") =><=
Packit Service 96b5d3
Packit Service 96b5d3
  == first  =>first:  <=(sprintf "%-6s" (get "val"))=> matches: <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~~ ^[a-z]*$ =>~~ ^[a-z]*$  OK<=
Packit Service 96b5d3
        ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$  *** BOGUS ***<=
Packit Service 96b5d3
        ~~ .*       =>~~ .*        *** BOGUS ***<=
Packit Service 96b5d3
      ESAC => and <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~ ^[a-z]*$ =>~ ^[a-z]*$  OK<=
Packit Service 96b5d3
        *          =>~ .*        *** BOGUS ***<=
Packit Service 96b5d3
      ESAC =><=
Packit Service 96b5d3
Packit Service 96b5d3
  == second =>second: <=(sprintf "%-6s" (get "val"))=> matches: <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~~ ^[a-z]*$ =>~~ ^[a-z]*$  *** BOGUS ***<=
Packit Service 96b5d3
        ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$  *** BOGUS ***<=
Packit Service 96b5d3
        ~* .        =>~* .         OK<=
Packit Service 96b5d3
      ESAC => and <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~ ^[a-z]*$ =>~ ^[a-z]*$  OK<=
Packit Service 96b5d3
        *          =>~ .*        *** BOGUS ***<=
Packit Service 96b5d3
      ESAC =><=
Packit Service 96b5d3
Packit Service 96b5d3
  == third  =>third:  <=(sprintf "%-6s" (get "val"))=> matches: <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~~ ^[a-z]*$ =>~~ ^[a-z]*$  *** BOGUS ***<=
Packit Service 96b5d3
        ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$  OK<=
Packit Service 96b5d3
        ~~ .*       =>~~ .*        *** BOGUS ***<=
Packit Service 96b5d3
      ESAC => and <=
Packit Service 96b5d3
      CASE (get "val") =><=
Packit Service 96b5d3
        ~ ^[a-z]*$ =>~ ^[a-z]*$  OK<=
Packit Service 96b5d3
        *          =>~ .*        *** BOGUS ***<=
Packit Service 96b5d3
      ESAC =><=
Packit Service 96b5d3
Packit Service 96b5d3
  ESAC =><=
Packit Service 96b5d3
Packit Service 96b5d3
ENDFOR grp=>
Packit Service 96b5d3
empty:  <= CASE empty-val =><=
Packit Service 96b5d3
   ~* .  =>WRONG<=
Packit Service 96b5d3
   !E    =>BOGUS<=
Packit Service 96b5d3
   +E    =>valid<=
Packit Service 96b5d3
   *     =>REAL-BOGUS<=
Packit Service 96b5d3
   ESAC  =>
Packit Service 96b5d3
bogus:  <= CASE bogus-val =><=
Packit Service 96b5d3
   ~* .  =>WRONG<=
Packit Service 96b5d3
   +E    =>BOGUS<=
Packit Service 96b5d3
   !E    =>valid<=
Packit Service 96b5d3
   *     =>REAL-BOGUS<=
Packit Service 96b5d3
   ESAC  =>
Packit Service 96b5d3
EOF
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # SAMPLE OUTPUT FILE # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.out in `pwd`
Packit Service 96b5d3
# this is the output we should expect to see
Packit Service 96b5d3
cat > ${testname}.out <<'EOF'
Packit Service 96b5d3
first:  string matches: ~~ ^[a-z]*$  OK and ~ ^[a-z]*$  OK
Packit Service 96b5d3
second: String matches: ~* .         OK and ~ ^[a-z]*$  OK
Packit Service 96b5d3
third:  STRING matches: ~~ ^[A-Z]*$  OK and ~ ^[a-z]*$  OK
Packit Service 96b5d3
empty:  valid
Packit Service 96b5d3
bogus:  valid
Packit Service 96b5d3
EOF
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # DEFINITIONS FILE # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
cat > ${testname}.def <
Packit Service 96b5d3
autogen definitions ${testname};
Packit Service 96b5d3
Packit Service 96b5d3
grp = {
Packit Service 96b5d3
   nam = first;
Packit Service 96b5d3
   val = string;
Packit Service 96b5d3
};
Packit Service 96b5d3
Packit Service 96b5d3
grp = {
Packit Service 96b5d3
   nam = second;
Packit Service 96b5d3
   val = String;
Packit Service 96b5d3
};
Packit Service 96b5d3
Packit Service 96b5d3
grp = {
Packit Service 96b5d3
   nam = third;
Packit Service 96b5d3
   val = STRING;
Packit Service 96b5d3
};
Packit Service 96b5d3
empty-val;
Packit Service 96b5d3
EOF
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # RUN AUTOGEN # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
run_ag x ${testname}.def ||  failure autogen failed
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # TEST RESULTS # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
cmp -s ${testname}.test ${testname}.out || failure unexpected output
Packit Service 96b5d3
Packit Service 96b5d3
cleanup
Packit Service 96b5d3
Packit Service 96b5d3
## Local Variables:
Packit Service 96b5d3
## mode: shell-script
Packit Service 96b5d3
## indent-tabs-mode: nil
Packit Service 96b5d3
## sh-indentation: 2
Packit Service 96b5d3
## sh-basic-offset: 2
Packit Service 96b5d3
## End:
Packit Service 96b5d3
Packit Service 96b5d3
# end of case.test