Commit 646fb4e1 authored by Akim Demaille's avatar Akim Demaille
Browse files

style: tests: simplifications

* tests/bin/test.py (SKIP): Comply with the syntax of TAP.
* tests/python/to-expansion.py: Remove unused argument.
parent 9cbbfc6d
......@@ -107,7 +107,7 @@ def PASS(*msg, **kwargs):
sys.stdout.flush()
def SKIP(*msg):
PASS('SKIP', *msg)
PASS('# SKIP', *msg)
def XFAIL(fun, exp = None):
try:
......
......@@ -15,44 +15,44 @@ def check(weight, exp):
w = ctx.weight(weight)
re = ctx.expression(exp)
CHECK_EQ(w, re.constant_term())
CHECK_EQ(w, re.automaton('expansion').eval(''))
CHECK_EQ(w, re.automaton().eval(''))
check('\z', 'a')
check('\e', 'a*')
check('x', '<x>a*')
# Test zero.
# zero.
check('\z', '<x>\z')
# Test one.
# one.
check('x', '<x>\e')
# Test add.
# label.
check('\z', 'a')
# add.
check('x+y', '<x>a*+<y>b*')
check('x(y+y)z', '<x>(<y>a*+<y>b*)<z>')
# Test mul.
# left and right weight.
check('xy*z', '<x>(<y>\e)*<z>')
# mul.
check('xy', '<x>a*<y>b*')
# Test conjunction.
# conjunction.
check('\z', '<x>a&<y>b')
check('xy', '<x>a*&<y>b*')
# Test shuffle.
# shuffle.
check('\z', '<x>a:<y>b')
check('xy', '<x>a*:<y>b*')
# Test infiltration.
# infiltration.
check('\z', '<x>a&:<y>b')
check('xy', '<x>a*&:<y>b*')
# Test star.
# star.
check('\e', '(<x>a)*')
check('x*', '(<x>\e)*')
# Test complement.
# complement.
check('\e', '(<x>a){c}')
check('x*', '(<x>\e)*')
# Test left and right weight.
check('xy*z', '<x>(<y>\e)*<z>')
......@@ -3,13 +3,9 @@
import vcsn
from test import *
def is_wordset(c):
return str(c).startswith("law_")
c = vcsn.context("lal_char(abc), expressionset<lal_char(xyz), q>")
def check(re, exp, use_spontaneous = False):
def check(re, exp):
'''Check that d(re) = exp. Also check that both derived_term
algorithms (`derivation` and `expansion`) compute the same result.
'''
......@@ -22,13 +18,12 @@ def check(re, exp, use_spontaneous = False):
aut = re.automaton("expansion")
# Check that if derived_term can do it, then it's the same
# automaton.
if not use_spontaneous and not is_wordset(re.context()):
try:
dt = re.automaton("derivation")
except RuntimeError as e:
SKIP(e)
else:
CHECK_ISOMORPHIC(dt, aut)
try:
dt = re.automaton("derivation")
except RuntimeError as e:
SKIP(e)
else:
CHECK_ISOMORPHIC(dt, aut)
##########################
## Regular derivation. ##
......@@ -92,7 +87,7 @@ ctx = vcsn.context('lal_char(a), polynomialset<law_char(x), q>')
check(ctx.expression('((<x>a)*+(<xx>aa)*){c}'), 'a.[(<x>(<x>a)*+<xx>(a(<xx>aa)*)){c}]')
check(ctx.expression('((<<2>x>a)*+(<<4>xx>aa)*){c}'), 'a.[(<<2>x>(<<2>x>a)*+<<4>xx>(a(<<4>xx>aa)*)){c}]')
# Transposition
# Transposition.
check('\z{T}', '<\z>')
check('\e{T}', '<\e>')
check('a{T}', 'a.[\e]')
......
......@@ -439,7 +439,7 @@ namespace vcsn
possibly_implicit_lweight_(r)),
one());
// <k>a&<h>a = <kh>a. <k>a&<h>b = 0.
// <k>a&<h>a => <kh>a. <k>a&<h>b => 0.
else if (type_ignoring_lweight_(l) == type_t::atom
&& type_ignoring_lweight_(r) == type_t::atom)
{
......@@ -453,7 +453,7 @@ namespace vcsn
res = zero();
}
// <k>1&<h>a = 0, <k>a&<h>1 = 0.
// <k>1&<h>a => 0, <k>a&<h>1 => 0.
else if ((type_ignoring_lweight_(l) == type_t::one
&& type_ignoring_lweight_(r) == type_t::atom)
|| (type_ignoring_lweight_(l) == type_t::atom
......@@ -473,15 +473,15 @@ namespace vcsn
if (!ids_)
res = std::make_shared<ldiv_t>(l, r);
// 0\E = 0{c}.
// 0\E => 0{c}.
else if (ids_ && l->type() == type_t::zero)
res = complement(zero());
// 1\E = E.
// 1\E => E.
else if (ids_ && l->type() == type_t::one)
res = r;
// E\0 = 0.
// E\0 => 0.
else if (ids_ && r->type() == type_t::zero)
res = r;
......@@ -728,7 +728,7 @@ namespace vcsn
res = std::make_shared<complement_t>(e);
// The following identities make derived-term (<2>a)*{c} terminate.
// (<k>E){c} => E{c}
// (<k>E){c} => E{c}.
else if (auto w = std::dynamic_pointer_cast<const lweight_t>(e))
res = complement(w->sub());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment