1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
// Author(s): Jeroen Keiren
// Copyright: see the accompanying file COPYING or copy at
// https://svn.win.tue.nl/trac/MCRL2/browser/trunk/COPYING
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
/// \file untime_test.cpp
/// \brief Add your file description here.
#include <iostream>
#include <string>
#include <boost/test/minimal.hpp>
#include <mcrl2/lps/specification.h>
#include <mcrl2/lps/untime.h>
#include <mcrl2/lps/linearise.h>
#include <mcrl2/lps/find.h>
using namespace mcrl2;
using namespace mcrl2::data;
using namespace mcrl2::lps;
/*
* Trivial test: LPS should be left as is, because there is no time involved.
*/
void test_case_1()
{
const std::string text(
"act a,b;\n"
"proc P = a . b . P;\n"
"init P;\n"
);
specification s0 = linearise(text);
specification s1 = s0;
lps::untime_algorithm(s1).run();
const action_summand_vector& summands1 = s1.process().action_summands();
for (action_summand_vector::const_iterator i = summands1.begin(); i != summands1.end(); ++i)
{
BOOST_CHECK(!i->has_time());
}
BOOST_CHECK(s0 == s1);
if (s0 != s1)
{
std::clog << "Input specification : " << lps::pp(s0) << std::endl
<< "Output specification : " << lps::pp(s1) << std::endl;
}
}
/*
* An extra process parameter (say "lat") of type Real is introduced
* time is removed from the actions, and the condition
* is weakened with time > lat (i.e. 2 > lat or 3 > lat in this case).
* Furthermore a summand true->delta is introduced.
*/
void test_case_2()
{
const std::string text(
"act a,b;\n"
"proc P = a@2 . b@3 . P;\n"
"init P;\n"
);
specification s0 = linearise(text);
specification s1 = s0;
lps::untime_algorithm(s1).run();
const action_summand_vector& summands0 = s0.process().action_summands();
const action_summand_vector& summands1 = s1.process().action_summands();
BOOST_CHECK(s0.process().process_parameters().size() == s1.process().process_parameters().size() - 1);
for (action_summand_vector::const_iterator i = summands1.begin(); i != summands1.end(); ++i)
{
BOOST_CHECK(!i->has_time());
}
}
/*
* An extra process parameter (say "lat") of type Real is introduced
* time is removed from the actions, and the condition
* is weakened with time > lat (i.e. 2 > lat or 3 > lat in this case).
* In the untimed summand, a summation over Real (say sum tv:Real) is introduced,
* and the condition is weakened with tv > lat.
* Furthermore a summand true->delta is introduced.
*/
void test_case_3()
{
const std::string text(
"act a,b;\n"
"proc P = a@2 . b@3 . P\n"
" + a . P;\n"
"init P;\n"
);
specification s0 = linearise(text);
specification s1 = s0;
lps::untime_algorithm(s1).run();
const action_summand_vector& summands0 = s0.process().action_summands();
const action_summand_vector& summands1 = s1.process().action_summands();
BOOST_CHECK(s0.process().process_parameters().size() == s1.process().process_parameters().size() - 1);
int sumvar_count = 0;
for (action_summand_vector::const_iterator i = summands1.begin(); i != summands1.end(); ++i)
{
BOOST_CHECK(!i->has_time());
sumvar_count += i->summation_variables().size();
}
BOOST_CHECK(sumvar_count == 1);
}
/*
* An extra process parameter (say "lat") of type Real is introduced
* time is removed from the actions, and the condition
* is weakened with time > lat (i.e. 2 > lat or 3 > lat in this case).
* In the untimed summand, a summation over Real (say sum tv:Real) is introduced,
* and the condition is weakened with tv > lat.
*/
void test_case_4()
{
const std::string text(
"act a,b;\n"
"proc P = a@2 . b@3 . P\n"
" + a . P\n"
" + true -> delta;\n"
"init P;\n"
);
specification s0 = linearise(text);
specification s1 = s0;
lps::untime_algorithm(s1).run();
const action_summand_vector& summands0 = s0.process().action_summands();
const action_summand_vector& summands1 = s1.process().action_summands();
BOOST_CHECK(s0.process().process_parameters().size() == s1.process().process_parameters().size() - 1);
int sumvar_count = 0;
for (action_summand_vector::const_iterator i = summands1.begin(); i != summands1.end(); ++i)
{
BOOST_CHECK(!i->has_time());
sumvar_count += i->summation_variables().size();
}
BOOST_CHECK(sumvar_count == 1);
}
int test_main(int ac, char** av)
{
test_case_1();
test_case_2();
test_case_3();
test_case_4();
return 0;
}
|