* src/ltlvisit/equals.cc, src/ltlvisit/equals.hh: New files.

* src/ltlvisit/Makefile.am (libltlvisit_a_SOURCES): Add equals.hh
and equals.cc.
* src/ltltest/equals.cc, src/ltltest/equals.test: New files.
* src/ltltest/Makefile.am (check_PROGRAMS): Add equals.
(equals_SOURCES): New variable.
(TESTS): Add equals.test.
This commit is contained in:
Alexandre Duret-Lutz 2003-04-16 12:30:21 +00:00
parent eec66e6d07
commit 7425f4a91e
8 changed files with 299 additions and 3 deletions

View file

@ -7,3 +7,4 @@ stdout
parser.dot
expect
defs
equals

View file

@ -4,12 +4,13 @@ LDADD = ../ltlparse/libltlparse.a \
../ltlast/libltlast.a
check_SCRIPTS = defs
check_PROGRAMS = ltl2dot ltl2text
check_PROGRAMS = ltl2dot ltl2text equals
ltl2dot_SOURCES = readltl.cc
ltl2dot_CPPFLAGS = $(AM_CPPFLAGS) -DDOTTY
ltl2text_SOURCES = readltl.cc
equals_SOURCES = equals.cc
EXTRA_DIST = $(TESTS)
TESTS = parse.test parseerr.test
TESTS = parse.test parseerr.test equals.test
CLEANFILES = stdout expect parse.dot

59
src/ltltest/equals.cc Normal file
View file

@ -0,0 +1,59 @@
#include <iostream>
#include "ltlparse/public.hh"
#include "ltlvisit/equals.hh"
void
syntax(char *prog)
{
std::cerr << prog << " formulae1 formulae2" << std::endl;
exit(2);
}
bool
print_parse_error(const char* f, spot::ltl::parse_error_list& pel)
{
bool err = false;
spot::ltl::parse_error_list::iterator it;
for (it = pel.begin(); it != pel.end(); ++it)
{
std::cerr << ">>> " << f << std::endl;
unsigned n = 0;
yy::Location& l = it->first;
for (; n < 4 + l.begin.column; ++n)
std::cerr << ' ';
// Write at least one '^', even if begin==end.
std::cerr << '^';
++n;
for (; n < 4 + l.end.column; ++n)
std::cerr << '^';
std::cerr << std::endl << it->second << std::endl << std::endl;
err = true;
}
return err;
}
int
main(int argc, char **argv)
{
if (argc != 3)
syntax(argv[0]);
spot::ltl::parse_error_list p1;
spot::ltl::formulae *f1 = spot::ltl::parse(argv[1], p1);
if (print_parse_error(argv[1], p1))
return 2;
spot::ltl::parse_error_list p2;
spot::ltl::formulae *f2 = spot::ltl::parse(argv[2], p2);
if (print_parse_error(argv[2], p2))
return 2;
if (equals(f1, f2))
return 0;
return 1;
}

51
src/ltltest/equals.test Executable file
View file

@ -0,0 +1,51 @@
#! /bin/sh
# Check for the equals visitor
. ./defs || exit 1
check()
{
./equals "$2" "$3"
test $? != $1 && exit 1;
}
check0()
{
check 0 "$@"
}
check1()
{
check 1 "$@"
}
# A few things which are equal
check0 'a' 'a'
check0 '1' '1'
check0 '0' '0'
check0 'a => b' 'a => b'
check0 'G a ' ' G a'
check0 'a U b' 'a U b'
check0 'a & b' 'a & b'
check0 'a & b' 'b & a'
check0 'a & b & c' 'c & a & b'
check0 'a & b & c' 'b & c & a'
check0 'a & b & a' 'b & a & b'
check0 'a & b' 'b & a & b'
check0 'a & b' 'b & a & a'
check0 'a & b & (c |(f U g)| e)' 'b & a & a & (c | e |(f U g)| e | c) & b'
# other formulae which are not
check1 'a' 'b'
check1 '1' '0'
check1 'a => b' 'b => a'
check1 'a => b' 'a <=> b'
check1 'a => b' 'a U b'
check1 'a R b' 'a U b'
check1 'a & b & c' 'c & a'
check1 'b & c' 'c & a & b'
check1 'a & b & (c |(f U g)| e)' 'b & a & a & (c | e |(g U g)| e | c) & b'
# Success.
: