* src/ltltest/tostring.test: New file.
* src/ltltest/tostring.cc: New files. * src/ltlvisit/tostring.hh: From ast to string New files. * src/ltlvisit/tostring.cc: From ast to string New files.
This commit is contained in:
parent
fc9f8965bf
commit
eed40025be
8 changed files with 231 additions and 5 deletions
|
|
@ -5,7 +5,6 @@ LDADD = ../ltlparse/libltlparse.a \
|
|||
../ltlenv/libltlenv.a
|
||||
|
||||
check_SCRIPTS = defs
|
||||
|
||||
# Keep this sorted alphabetically.
|
||||
check_PROGRAMS = \
|
||||
equals \
|
||||
|
|
@ -13,22 +12,25 @@ check_PROGRAMS = \
|
|||
ltl2text \
|
||||
lunabbrev \
|
||||
nenoform \
|
||||
tostring \
|
||||
tunabbrev \
|
||||
tunenoform
|
||||
|
||||
equals_SOURCES = equals.cc
|
||||
ltl2dot_SOURCES = readltl.cc
|
||||
ltl2dot_CPPFLAGS = $(AM_CPPFLAGS) -DDOTTY
|
||||
ltl2text_SOURCES = readltl.cc
|
||||
equals_SOURCES = equals.cc
|
||||
lunabbrev_SOURCES = equals.cc
|
||||
lunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DLUNABBREV
|
||||
tunabbrev_SOURCES = equals.cc
|
||||
tunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DTUNABBREV
|
||||
nenoform_SOURCES = equals.cc
|
||||
nenoform_CPPFLAGS = $(AM_CPPFLAGS) -DNENOFORM
|
||||
tostring_SOURCES = tostring.cc
|
||||
tunabbrev_SOURCES = equals.cc
|
||||
tunabbrev_CPPFLAGS = $(AM_CPPFLAGS) -DTUNABBREV
|
||||
tunenoform_SOURCES = equals.cc
|
||||
tunenoform_CPPFLAGS = $(AM_CPPFLAGS) -DNENOFORM -DTUNABBREV
|
||||
|
||||
|
||||
EXTRA_DIST = $(TESTS)
|
||||
|
||||
# Ordered by strength of the test. Test basic features first.
|
||||
|
|
@ -36,6 +38,7 @@ TESTS = \
|
|||
parse.test \
|
||||
parseerr.test \
|
||||
equals.test \
|
||||
tostring.test \
|
||||
lunabbrev.test \
|
||||
tunabbrev.test \
|
||||
nenoform.test \
|
||||
|
|
|
|||
45
src/ltltest/tostring.cc
Normal file
45
src/ltltest/tostring.cc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "ltlparse/public.hh"
|
||||
#include "ltlvisit/tostring.hh"
|
||||
#include "ltlvisit/equals.hh"
|
||||
|
||||
void
|
||||
syntax(char *prog)
|
||||
{
|
||||
std::cerr << prog << " formula1" << std::endl;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
syntax(argv[0]);
|
||||
|
||||
spot::ltl::parse_error_list p1;
|
||||
spot::ltl::formula* f1 = spot::ltl::parse(argv[1], p1);
|
||||
|
||||
if (spot::ltl::format_parse_errors(std::cerr, argv[1], p1))
|
||||
return 2;
|
||||
|
||||
std::ostringstream os;
|
||||
spot::ltl::to_string(*f1, os);
|
||||
std::cout << os.str() << std::endl;
|
||||
|
||||
spot::ltl::formula* f2 = spot::ltl::parse(os.str(), p1);
|
||||
|
||||
if (spot::ltl::format_parse_errors(std::cerr, os.str(), p1))
|
||||
return 2;
|
||||
|
||||
std::ostringstream os2;
|
||||
spot::ltl::to_string(*f2, os2);
|
||||
std::cout << os2.str() << std::endl;
|
||||
|
||||
if (os2.str() != os.str())
|
||||
return 1;
|
||||
|
||||
if (! equals(f1, f2))
|
||||
return 1;
|
||||
}
|
||||
|
||||
28
src/ltltest/tostring.test
Executable file
28
src/ltltest/tostring.test
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Check that spot::ltl::tostring is correct: after to parse we get the
|
||||
# string of the abstract syntax tree and xe parse it again to apply spot::ltl::tostring one more times.
|
||||
|
||||
. ./defs || exit 1
|
||||
|
||||
check()
|
||||
{
|
||||
./tostring "$1" || exit 1
|
||||
}
|
||||
|
||||
check 'a'
|
||||
check '1'
|
||||
check '0'
|
||||
check 'a => b'
|
||||
check 'G a '
|
||||
check 'a U b'
|
||||
check 'a & b'
|
||||
check 'a & b & c'
|
||||
check 'b & a & b'
|
||||
check 'b & a & a'
|
||||
check 'a & b & (c |(f U g)| e)'
|
||||
check 'b & a & a & (c | e |(f U g)| e | c) & b'
|
||||
check 'a <=> b'
|
||||
check 'a & b & (c |(f U g)| e)'
|
||||
check 'b & a & a & (c | e |(g U g)| e | c) & b'
|
||||
:
|
||||
Loading…
Add table
Add a link
Reference in a new issue