#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
# Développement de l'EPITA.
#
# This file is part of Spot, a model checking library.
#
# Spot 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.
#
# Spot 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 <http://www.gnu.org/licenses/>.


. ./defs

set -e

check ()
{
  run 0 ../ltl2tgba -f -KV "$1" > out.dot
  test -z "$DOT" || "$DOT" out.dot > /dev/null
  rm -f out.dot
}

# We don't check the output, but running these might be
# enough to trigger assertions in the code, or raise valgrind concerns.

check 'a R (b R c)'
check '(a U b) U (c U d)'
check '((Xp2)U(X(1)))&(p1 R(p2 R p0))'

# Make sure escaped variables print OK.
check '"G1"U"GG" && "FF"'


# Make sure we count 4 atomic propositions in
# G("P_1.p2" <-> (F"P_1.p3" & ("P_0.p3" | (X"P_1.CS" U "P_1.p2")))) U G"P_1.p2"
# even after iterated simulation
# Report from Etienne Renault.

../ltl2tgba -KV -R3 -RIS >out \
'G("P_1.p2" <-> (F"P_1.p3" & ("P_0.p3" | (X"P_1.CS" U "P_1.p2")))) U G"P_1.p2"'
x=`sed -n '/APrec/{
  s/.*APrec=\[\([^]]*\)\].*/\1/p
  q
}' out | tr ' ' '\n' | wc -l`
test "$x" -eq 4
