tests: divide the run time of tostring.test by 40

* tests/core/tostring.test: Move all the input formulas into...
* tests/core/tostring.cc: ... the code, and do the loop there.
This commit is contained in:
Alexandre Duret-Lutz 2016-11-29 11:33:56 +01:00
parent b3ee68310f
commit ad51525608
2 changed files with 126 additions and 82 deletions

View file

@ -22,25 +22,64 @@
#include <iostream> #include <iostream>
#include <cassert> #include <cassert>
#include <cstdlib>
#include <spot/tl/parse.hh> #include <spot/tl/parse.hh>
#include <spot/tl/print.hh> #include <spot/tl/print.hh>
static void const char* inputs[] =
syntax(char *prog)
{
std::cerr << prog << " formula1" << std::endl;
exit(2);
}
int
main(int argc, char **argv)
{
if (argc != 2)
syntax(argv[0]);
{ {
auto pf1 = spot::parse_infix_psl(argv[1]); "a",
"1",
"0",
"a => b",
"G a ",
"a U b",
"a & b",
"a & b & c",
"b & a & b",
"b & a & a",
"a & b & (c |(f U g)| e)",
"b & a & a & (c | e |(f U g)| e | c) & b",
"a <=> b",
"a & b & (c |(f U g)| e)",
"b & a & a & (c | e |(g U g)| e | c) & b",
"F\"F1\"&G\"G\"&X\"X\"",
"GFfalse",
"GFtrue",
"p=0Uq=1Ut=1",
"F\"FALSE\"",
"G\"TruE\"",
"FFALSE",
"GTruE",
"p=0UFXp=1",
"GF\"\\GF\"",
"GF\"foo bar\"",
"FFG__GFF",
"X\"U\"",
"X\"W\"",
"X\"M\"",
"X\"R\"",
"{a;b;{c && d*};**}|=>G{a*:b*}",
"GF!{{a || c} && b}",
"GF!{{a || c*} && b}<>->{{!a}*}",
"GF{{a || c*} & b[*]}[]->{d}",
"{a[*2..3]}",
"{a[*0..1]}",
"{a[*0..]}",
"{a[*..]}",
"{a[*1..]}",
"{a[+]}",
"{[+]}",
"{a[*2..3][*4..5]}",
"{a**}<>->1",
};
int main()
{
for (const char* input: inputs)
{
{
auto pf1 = spot::parse_infix_psl(input);
if (pf1.format_errors(std::cerr)) if (pf1.format_errors(std::cerr))
return 2; return 2;
auto f1 = pf1.f; auto f1 = pf1.f;
@ -64,12 +103,14 @@ main(int argc, char **argv)
// It should also map to the same string. // It should also map to the same string.
std::string f2s = spot::str_psl(f2); std::string f2s = spot::str_psl(f2);
std::cout << f2s << '\n';
if (f2s != f1s) if (f2s != f1s)
{
std::cerr << f1s << " != " << f2s << '\n';
return 1; return 1;
} }
}
assert(spot::fnode::instances_check()); assert(spot::fnode::instances_check());
}
return 0; return 0;
} }

View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2011, 2013 Laboratoire de Recherche et # Copyright (C) 2009, 2010, 2011, 2013, 2016 Laboratoire de Recherche et
# Développement de l'Epita (LRDE). # Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre # département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -28,50 +28,53 @@
set -e set -e
run 0 ../tostring 'a' cat >expected <<EOF
run 0 ../tostring '1' a
run 0 ../tostring '0' 1
run 0 ../tostring 'a => b' 0
run 0 ../tostring 'G a ' a -> b
run 0 ../tostring 'a U b' Ga
run 0 ../tostring 'a & b' a U b
run 0 ../tostring 'a & b & c' a & b
run 0 ../tostring 'b & a & b' a & b & c
run 0 ../tostring 'b & a & a' a & b
run 0 ../tostring 'a & b & (c |(f U g)| e)' a & b
run 0 ../tostring 'b & a & a & (c | e |(f U g)| e | c) & b' a & b & (c | e | (f U g))
run 0 ../tostring 'a <=> b' a & b & (c | e | (f U g))
run 0 ../tostring 'a & b & (c |(f U g)| e)' a <-> b
run 0 ../tostring 'b & a & a & (c | e |(g U g)| e | c) & b' a & b & (c | e | (f U g))
run 0 ../tostring 'F"F1"&G"G"&X"X"' a & b & (c | e | g)
run 0 ../tostring 'GFfalse' F"F1" & G"G" & X"X"
run 0 ../tostring 'GFtrue' 0
run 0 ../tostring 'p=0Uq=1Ut=1' 1
run 0 ../tostring 'F"FALSE"' !p U (q U t)
run 0 ../tostring 'G"TruE"' F"FALSE"
run 0 ../tostring 'FFALSE' G"TruE"
run 0 ../tostring 'GTruE' 0
run 0 ../tostring 'p=0UFXp=1' 1
run 0 ../tostring 'GF"\GF"' !p U FXp
run 0 ../tostring 'GF"foo bar"' GF"GF"
run 0 ../tostring 'FFG__GFF' GF"foo bar"
run 0 ../tostring 'X"U"' FG__GFF
run 0 ../tostring 'X"W"' X"U"
run 0 ../tostring 'X"M"' X"W"
run 0 ../tostring 'X"R"' X"M"
X"R"
{a;b;{c && d[*]};[+]}[]-> G{a[*]:b[*]}
GF!(b & (a | c))
GF!({b && {a | c[*]}}<>-> {{!a}[*]})
GF({{a | c[*]} & b[*]}[]-> d)
{a[*2..3]}
{a[*0..1]}
{a[*]}
{a[*]}
{a[+]}
{a[+]}
{[+]}
{a[*8..15]}
{a[*]}!
EOF
run 0 ../tostring '{a;b;{c && d*};**}|=>G{a*:b*}' run 0 ../tostring >out
run 0 ../tostring 'GF!{{a || c} && b}'
run 0 ../tostring 'GF!{{a || c*} && b}<>->{{!a}*}'
run 0 ../tostring 'GF{{a || c*} & b[*]}[]->{d}'
run 0 ../tostring '{a[*2..3]}'
run 0 ../tostring '{a[*0..1]}'
run 0 ../tostring '{a[*0..]}'
run 0 ../tostring '{a[*..]}'
run 0 ../tostring '{a[*1..]}'
run 0 ../tostring '{a[+]}'
run 0 ../tostring '{[+]}'
run 0 ../tostring '{a[*2..3][*4..5]}'
run 0 ../tostring '{a**}<>->1' > out diff expected out
test "`sed 1q < out `" = '{a[*]}!'