vcsn-int-fmp-z.test 3.48 KB
Newer Older
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
1
2
3
#! /bin/sh

# Vaucanson, a generic library for finite state machines.
4
# Copyright (C) 2008, 2009 The Vaucanson Group.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# The complete GNU General Public Licence Notice can be found as the
# `COPYING' file in the root directory.
#
# The Vaucanson Group consists of people listed in the `AUTHORS' file.

. ./defs || exit 1

set -e

20
VCSN=vcsn-int-fmp-z
21

22
sed '/^#/d' <<EOF | $VCSN --alphabet1=10,11,12 --alphabet2=20,21,22 edit-automaton x.xml
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
# Add states
1
# Add two states
2
# Set a state to be initial.
5
# Which state
0
# Weight?
2
# Set a state to be final.
7
# Which state
1
# Weight
3
# Add transition
3
# From and to
0
1
# Label (word,word,weight)
10#11
22
5
# Add transition
3
# From and to
1
0
# Label
11
22#20
1
# Exit.
10
EOF

61
62
63
64
65
66
67
# The evaluation of a word on FMP transducers internally uses
# aut-to-exp which may produce different results depending on the
# order used to remove the states of the automaton.  The following
# test are simple enough so that the resulting ratexps should only
# differ by their parentheses.  We use "expand" to hide these
# discrepancies.

68
res=`$VCSN eval x.xml 10.11.11`
69
70
test "x$res" = xz

71
res=`$VCSN eval x.xml 10#11`
72
73
res=`vcsn-int-z expand --alphabet=22 "$res"`
test "x$res" = "x{30} 22"
74

75
res=`$VCSN eval x.xml 10#11.11#10.11`
76
77
res=`vcsn-int-z expand --alphabet=20,22 "$res"`
test "x$res" = "x{150} 22#22#20#22"
78

79
res=`$VCSN image x.xml | vcsn-int-z aut-to-exp -`
80
81
res=`vcsn-int-z expand --alphabet=22,20 "$res"`
test "x$res" = "x{30} (({5} 22#22#20)*.22)"
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

fail1 $VCSN is-ltl x.xml
fail1 $VCSN sub-normalize x.xml \| is-ltl -

sed '/^#/d' <<EOF | $VCSN --alphabet1=10,11,12 --alphabet2=20,21,22 edit-automaton y.xml
# Add states
1
# Add two states
3
# Set a state to be initial.
5
# Which state
0
# Weight?
2
# Set a state to be final.
7
# Which state
2
# Weight
3
# Add transition
3
# From and to
0
1
# Label (word,word,weight)
10#11
22#20
5
# Add transition
3
# From and to
1
2
# Label
11#12
22#20
1
# Add transition
3
# From and to
2
1
# Label
e
e
1
# Exit.
10
EOF

fail1 $VCSN is-ltl y.xml
fail1 $VCSN sub-normalize y.xml \| is-ltl -
fail1 $VCSN eps-removal y.xml \| is-ltl -
      $VCSN sub-normalize y.xml \| eps-removal - \| is-ltl -

$VCSN eps-removal y.xml \| sub-normalize - > yl.xml
$VCSN is-ltl yl.xml
$VCSN ltl-to-pair yl.xml > yp.xml
$VCSN pair-to-fmp yp.xml > yl2.xml
$VCSN info yl.xml > yl.info
$VCSN info yl2.xml > yl2.info
diff yl.info yl2.info



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
## --------------------------- ##
## Test writing data handling. ##
## --------------------------- ##

writing_data="CPAR=_A_ OPAR=_B_ PLUS=_C_ SPACE=_D_ STAR=_E_ TIMES=_F_ CWEIGHT=_G_ OWEIGHT=_H_ ZERO=_I_ ONE=_J_ CONCAT=_K_"
writing_data1="CPAR=#A# OPAR=#B# PLUS=#C# SPACE=#D# STAR=#E# TIMES=#F# CWEIGHT=#G# OWEIGHT=#H# ZERO=#I# ONE=#J# CONCAT=#K#"
writing_data2="CPAR=@A@ OPAR=@B@ PLUS=@C@ SPACE=@D@ STAR=@E@ TIMES=@F@ CWEIGHT=@G@ OWEIGHT=@H@ ZERO=@I@ ONE=@J@ CONCAT=@K@"
sed '/^#/d' <<EOF | $VCSN -a"10,11" -A"12,13" -p"$writing_data" -P"$writing_data1" -Q"$writing_data2" edit-automaton wd-ref.xml
# Exit.
10
EOF
sed '/^#/d' <<EOF | $VCSN -a"10,11" -A"12,13" edit-automaton wd-empty.xml
# Exit.
10
EOF
$VCSN -p"$writing_data" -P"$writing_data1" -Q"$writing_data2" identity wd-empty.xml > wd-new.xml
diff wd-new.xml wd-ref.xml
167
168
169

# Check predefined alphabets in help.
$VCSN --help |fail1 grep predefined