summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/grammar_fa/tests
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2016-10-27 19:39:39 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2016-10-27 19:39:39 (GMT)
commitea28451286d3ea4a772fa174483f9a7a66bb1ab3 (patch)
tree6ee9d8a7848333a7ceeee3b13d492e40225f8b86 /tcllib/modules/grammar_fa/tests
parentb5ca09bae0d6a1edce939eea03594dd56383f2c8 (diff)
parent7c621da28f07e449ad90c387344f07a453927569 (diff)
downloadblt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.zip
blt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.tar.gz
blt-ea28451286d3ea4a772fa174483f9a7a66bb1ab3.tar.bz2
Merge commit '7c621da28f07e449ad90c387344f07a453927569' as 'tcllib'
Diffstat (limited to 'tcllib/modules/grammar_fa/tests')
-rw-r--r--tcllib/modules/grammar_fa/tests/Xsupport371
-rw-r--r--tcllib/modules/grammar_fa/tests/da_accept.test84
-rw-r--r--tcllib/modules/grammar_fa/tests/da_cons.test140
-rw-r--r--tcllib/modules/grammar_fa/tests/de_cons.test157
-rw-r--r--tcllib/modules/grammar_fa/tests/de_exec.test104
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_cons.test87
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_ec.test84
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_final.test391
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_is.test59
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_is_complete.test60
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_is_deterministic.test75
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_is_epsfree.test60
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_is_useful.test715
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_next.test421
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_reach.test344
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_serial.test221
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_start.test386
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_state.test304
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_states.test76
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_symbol.test254
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_symbols.test81
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_symbols_at.test138
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_useful.test344
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_complete.test107
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_concat.test113
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_determinize.test117
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_difference.test110
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_intersect.test111
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_kleene.test102
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_minimize.test117
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_optional.test102
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_regex.test256
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_remeps.test158
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_reverse.test95
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_trim.test209
-rw-r--r--tcllib/modules/grammar_fa/tests/faop_union.test113
36 files changed, 6666 insertions, 0 deletions
diff --git a/tcllib/modules/grammar_fa/tests/Xsupport b/tcllib/modules/grammar_fa/tests/Xsupport
new file mode 100644
index 0000000..73c2d56
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/Xsupport
@@ -0,0 +1,371 @@
+# -*- tcl -*-
+# -------------------------------------------------------------------------
+# Helper for tests: Validation of serializations.
+
+proc validate_serial {value fa} {
+ # value is list/3 ('grammar::fa' symbols states)
+ # !("" in symbols)
+ # states is ordered dict (key is state, value is statedata)
+ # statedata is list/3 (start final trans|"")
+ # start is boolean
+ # final is boolean
+ # trans is dict (key in symbols, value is list (state))
+
+ # Output for debug ...
+ ##puts "$fa => ($value)"
+
+ # symbols set-equal symbols(fa)
+ # states set-equal states(fa)
+ # finalstates set-equal finalstates(fa)
+ # startstates set-equal startstates(fa)
+
+ set prefix "error in serialization:"
+ if {[llength $value] != 3} {
+ return "$prefix list length not 3"
+ }
+
+ struct::list assign $value type symbols statedata
+
+ if {$type ne "grammar::fa"} {
+ return "$prefix unknown type \"$type\""
+ }
+ if {[struct::set contains $symbols ""]} {
+ return "$prefix empty symbol is not legal"
+ }
+ if {![struct::set equal $symbols [$fa symbols]]} {
+ return "$prefix set of symbols does not match"
+ }
+ if {[llength $statedata] % 2 == 1} {
+ return "$prefix state data is not a dictionary"
+ }
+ array set _states $statedata
+ if {[llength $statedata] != (2*[array size _states])} {
+ return "$prefix state data contains duplicate states"
+ }
+ if {![struct::set equal [array names _states] [$fa states]]} {
+ return "$prefix set of states does not match"
+ }
+ foreach {k v} $statedata {
+ if {[llength $v] != 3} {
+ return "$prefix state list length not 3"
+ }
+ struct::list assign $v start final trans
+ if {![string is boolean -strict $start]} {
+ return "$prefix expected boolean for start, got \"$start\", for state \"$k\""
+ }
+ if {($start && ![$fa start? $k]) || (!$start && [$fa start? $k])} {
+ return "$prefix start does not match for state \"$k\""
+ }
+ if {![string is boolean -strict $final]} {
+ return "$prefix expected boolean for final, got \"$final\", for state \"$k\""
+ }
+ if {($final && ![$fa final? $k]) || (!$final && [$fa final? $k])} {
+ return "$prefix final does not match for state \"$k\""
+ }
+ if {[llength $trans] % 2 == 1} {
+ return "$prefix transition data is not a dictionary for state \"$k\""
+ }
+ array set _trans $trans
+ if {[llength $trans] != (2*[array size _trans])} {
+ return "$prefix transition data contains duplicate symbols for state \"$k\""
+ }
+ # trans keys set-equal to trans/symbols(fa,k)
+ if {![struct::set equal [$fa symbols@ $k] [array names _trans]]} {
+ return "$prefix transition symbols do not match for state \"$k\""
+ }
+ unset _trans
+
+ foreach {sym destinations} $trans {
+ if {($sym ne "") && ![struct::set contains $symbols $sym]} {
+ return "$prefix illegal symbol \"$sym\" in transition for state \"$k\""
+ }
+ foreach dest $destinations {
+ if {![info exists _states($dest)]} {
+ return "$prefix illegal destination state \"$dest\" for state \"$k\""
+ }
+ }
+ if {![struct::set equal $destinations [$fa next $k $sym]]} {
+ return "$prefix destination set does not match for state \"$k\""
+ }
+ }
+ }
+ return ok
+}
+
+# -------------------------------------------------------------------------
+# Helper for tests: Serialization of empty FA.
+
+set fa_empty {grammar::fa {} {}}
+
+# -------------------------------------------------------------------------
+# Helper for tests: Predefined graphs for use in tests.
+# (Properties and such). Number of graphs: 30.
+
+array set fa_pre {}
+
+proc gen {code} {
+ global fa_pre
+ uplevel #0 $fa_pre($code)
+ return
+}
+proc def {code script} {
+ global fa_pre
+ set fa_pre($code) $script
+ return
+}
+
+
+def x {
+ a state add x
+}
+def x- {
+ a state add x
+ a symbol add @
+ a next x @ --> x
+}
+def xe {
+ a state add x
+ a next x "" --> x
+}
+def xy {
+ a state add x y
+}
+def xy- {
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+}
+def xye {
+ a state add x y
+ a next x "" --> y
+}
+def xyee {
+ a state add x y
+ a next x "" --> y
+ a next y "" --> x
+}
+def xye- {
+ a state add x y
+ a symbol add @
+ a next x "" --> y
+ a next y @ --> x
+}
+def xy-- {
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+ a next y @ --> x
+}
+def xy-= {
+ a state add x y
+ a symbol add @ =
+ a next x @ --> y
+ a next y = --> x
+}
+def xyz/ee {
+ a state add x y z
+ a next x "" --> y
+ a next x "" --> z
+}
+def xyz/e- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next x "" --> z
+}
+def xyz/-- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next x @ --> z
+}
+def xyz/-= {
+ a state add x y z
+ a symbol add @ =
+ a next x @ --> y
+ a next x = --> z
+}
+def xyz|ee {
+ a state add x y z
+ a next x "" --> z
+ a next y "" --> z
+}
+def xyz|e- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> z
+ a next y "" --> z
+}
+def xyz|-- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> z
+ a next y @ --> z
+}
+def xyz|-= {
+ a state add x y z
+ a symbol add @ =
+ a next x @ --> z
+ a next y = --> z
+}
+def xyz+eee {
+ a state add x y z
+ a next x "" --> y
+ a next y "" --> z
+ a next z "" --> x
+}
+def xyz+ee- {
+ a state add x y z
+ a symbol add @
+ a next x "" --> y
+ a next y "" --> z
+ a next z @ --> x
+}
+def xyz+e-- {
+ a state add x y z
+ a symbol add @
+ a next x "" --> y
+ a next y @ --> z
+ a next z @ --> x
+}
+def xyz+e-= {
+ a state add x y z
+ a symbol add @ =
+ a next x "" --> y
+ a next y @ --> z
+ a next z = --> x
+}
+def xyz+--- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next y @ --> z
+ a next z @ --> x
+}
+def xyz+--= {
+ a state add x y z
+ a symbol add @ =
+ a next x @ --> y
+ a next y @ --> z
+ a next z = --> x
+}
+def xyz+-=_ {
+ a state add x y z
+ a symbol add @ = %
+ a next x @ --> y
+ a next y = --> z
+ a next z % --> x
+}
+def xyz&eee {
+ a state add x y z
+ a next x "" --> y
+ a next x "" --> z
+ a next y "" --> z
+}
+def xyz&ee- {
+ a state add x y z
+ a symbol add @
+ a next x "" --> y
+ a next x "" --> z
+ a next y @ --> z
+}
+def xyz&e-- {
+ a state add x y z
+ a symbol add @
+ a next x "" --> y
+ a next x @ --> z
+ a next y @ --> z
+}
+def xyz&e-= {
+ a state add x y z
+ a symbol add @ =
+ a next x "" --> y
+ a next x @ --> z
+ a next y = --> z
+}
+def xyz&--- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next x @ --> z
+ a next y @ --> z
+}
+def xyz&--= {
+ a state add x y z
+ a symbol add @ =
+ a next x @ --> y
+ a next x @ --> z
+ a next y = --> z
+}
+def xyz&-=_ {
+ a state add x y z
+ a symbol add @ = %
+ a next x @ --> y
+ a next x = --> z
+ a next y % --> z
+}
+def xyz!ee {
+ a state add x y z
+ a next x "" --> y
+ a next y "" --> z
+}
+def xyz!e- {
+ a state add x y z
+ a symbol add @
+ a next x "" --> y
+ a next y @ --> z
+}
+def xyz!-- {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next y @ --> z
+}
+def xyz!-= {
+ a state add x y z
+ a symbol add @ = %
+ a next x @ --> y
+ a next y = --> z
+}
+def xyz!-e {
+ a state add x y z
+ a symbol add @
+ a next x @ --> y
+ a next y "" --> z
+}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+def datom {
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+}
+def dalt {
+ a state add u v w x y z
+ a symbol add @ =
+ a next u "" --> v ; a next v @ --> x ; a next x "" --> z
+ a next u "" --> w ; a next w = --> y ; a next y "" --> z
+}
+def daltb {
+ a state add u v w x y z
+ a symbol add @ =
+ a next u "" --> v ; a next v @ --> x ; a next x "" --> z
+ a next u "" --> w ; a next w = --> y ; a next y "" --> z
+ a next z "" --> u
+}
+def dopt {
+ a state add u v w x
+ a symbol add @
+ a next u "" --> v ; a next v @ --> w ; a next w "" --> x
+ a next u "" --> x
+}
+def drep {
+ a state add u v w x
+ a symbol add @
+ a next u "" --> v ; a next v @ --> w ; a next w "" --> x
+ a next u "" --> x
+ a next x "" --> u
+}
+
+# -------------------------------------------------------------------------
diff --git a/tcllib/modules/grammar_fa/tests/da_accept.test b/tcllib/modules/grammar_fa/tests/da_accept.test
new file mode 100644
index 0000000..3ea7cc1
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/da_accept.test
@@ -0,0 +1,84 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa::dacceptor engine
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: da_accept.test,v 1.5 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+# Regular expression for C comments (Extended notation, using the 'not' operator).
+#
+# '/' . '*' . (! (ALL* . '*' . '/' . ALL*)) . '*' . '/'
+# ALL = '/' | '*' | 'any'
+#
+# Generated minimal DFA
+#
+# any/ *
+# | |
+# 0 -/-> 1 -*-> 2 -*-> 3 -/-> 4
+# \<-any-/
+
+#puts -nonewline " RE compile, " ; flush stdout
+
+grammar::fa ccomments fromRegex {. {S /}
+ {S *}
+ {! {. {* {| {S *} {S /} {S any}}}
+ {S *}
+ {S /}
+ {* {| {S *} {S /} {S any}}}}}
+ {S *}
+ {S /}
+ } {/ * any}
+
+#puts -nonewline {FA, } ; flush stdout
+
+ccomments determinize ; #puts -nonewline {deterministic, } ; flush stdout
+ccomments minimize ; #puts minimal ; flush stdout
+
+
+# -------------------------------------------------------------------------
+
+test da-accept-${setimpl}-1.0 {accept? error} {
+ grammar::fa::dacceptor da ccomments
+ catch {da accept?} msg
+ da destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::dacceptor::Snit_methodaccept? type selfns win self symbolstring"}
+
+
+test da-accept-${setimpl}-1.1 {accept? error} {
+ grammar::fa::dacceptor da ccomments
+ catch {da accept? x y} msg
+ da destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::dacceptor::Snit_methodaccept? type selfns win self symbolstring"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n acceptany accept string} {
+ 0 0 0 {x y}
+ 1 1 1 {/ * * /}
+ 2 1 0 {/ * x * /}
+ 3 0 0 {/ * * / * /}
+ 4 0 0 {/ * x * / x * /}
+ 5 0 0 {/ * * * / * * /}
+} {
+ test da-accept-${setimpl}-2.$n {accept?, -any any} {
+ grammar::fa::dacceptor da ccomments -any any
+ set res [da accept? $string]
+ da destroy
+ set res
+ } $acceptany ; # {}
+
+ test da-accept-${setimpl}-3.$n {accept?} {
+ grammar::fa::dacceptor da ccomments
+ set res [da accept? $string]
+ da destroy
+ set res
+ } $accept ; # {}
+}
+
+# -------------------------------------------------------------------------
+ccomments destroy
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/da_cons.test b/tcllib/modules/grammar_fa/tests/da_cons.test
new file mode 100644
index 0000000..42cdb6a
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/da_cons.test
@@ -0,0 +1,140 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa::dacceptor engine
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: da_cons.test,v 1.8 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+
+test da-cons-${setimpl}-1.0 {construction error} {
+ catch {grammar::fa::dacceptor a} msg
+ set msg
+} {Error in constructor: wrong # args: should be "::grammar::fa::dacceptor::Snit_constructor type selfns win self fa args"}
+
+
+test da-cons-${setimpl}-1.1 {construction error} {
+ catch {grammar::fa::dacceptor a foo fie far} msg
+ set msg
+} {Error in constructor: unknown option "fie"}
+
+
+test da-cons-${setimpl}-1.2 {construction error} {
+ catch {grammar::fa::dacceptor a b} msg
+ set msg
+} {Error in constructor: invalid command name "b"}
+
+foreach {n code setup_result} {
+ 00 x {{} 0 x 1}
+ 01 x- {{} 0 x 1}
+ 02 xe {{} 0 x 0}
+ 03 xy {{} 0 x 1 y 1 {x y} 0}
+ 04 xy- {{} 0 x 1 y 1 {x y} 0}
+ 05 xye {{} 0 x 0 y 0 {x y} 0}
+ 06 xyee {{} 0 x 0 y 0 {x y} 0}
+ 07 xye- {{} 0 x 0 y 0 {x y} 0}
+ 08 xy-- {{} 0 x 1 y 1 {x y} 0}
+ 09 xy-= {{} 0 x 1 y 1 {x y} 0}
+ 10 xyz/ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 11 xyz/e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 12 xyz/-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 13 xyz/-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 14 xyz|ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 15 xyz|e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 16 xyz|-- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 17 xyz|-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 18 xyz+eee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 19 xyz+ee- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 20 xyz+e-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 21 xyz+e-= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 22 xyz+--- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 23 xyz+--= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 24 xyz+-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 25 xyz&eee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 26 xyz&ee- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 27 xyz&e-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 28 xyz&e-= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 29 xyz&--- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 30 xyz&--= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 31 xyz&-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 32 xyz!ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 33 xyz!e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 34 xyz!-- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 35 xyz!-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 36 xyz!-e {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+} {
+ foreach {stset expected} $setup_result {
+ foreach {fset __} $setup_result {
+ set key ${n}.${code}.([join $stset {}]).([join $fset {}])
+
+ test da-cons-${setimpl}-1.3.$key {construction error} {
+ grammar::fa a
+ gen $code
+ a start set $stset
+ a final set $fset
+ set nfa [expr {![a is deterministic]}]
+ set fail [catch {grammar::fa::dacceptor da a} msg]
+ a destroy
+ catch {da destroy}
+
+ expr {($nfa && $fail) || (!$nfa && !$fail)}
+ } 1
+ }
+ }
+}
+
+test da-cons-${setimpl}-1.4 {construction error} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ catch {grammar::fa::dacceptor da a -any *} msg
+ a destroy
+ set msg
+} {Error in constructor: Chosen any symbol "*" does not exist}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test da-cons-${setimpl}-2.0 {construction} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ grammar::fa::dacceptor da a
+ a destroy
+ da destroy
+} {}
+
+
+test da-cons-${setimpl}-2.1 {construction} {
+ set res {}
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ lappend res [info commands ::da]
+ grammar::fa::dacceptor da a
+ a destroy
+ lappend res [info commands ::da]
+ da destroy
+ lappend res [info commands ::da]
+ set res
+} {{} ::da {}}
+
+
+test da-cons-${setimpl}-2.2 {construction} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ grammar::fa::dacceptor da a -any @
+ a destroy
+ da destroy
+} {}
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/de_cons.test b/tcllib/modules/grammar_fa/tests/de_cons.test
new file mode 100644
index 0000000..5ff8407
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/de_cons.test
@@ -0,0 +1,157 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa::dexec engine
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: de_cons.test,v 1.8 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+
+global events
+
+# -------------------------------------------------------------------------
+
+test de-cons-${setimpl}-1.0 {construction error} {
+ catch {grammar::fa::dexec a} msg
+ set msg
+} {Error in constructor: wrong # args: should be "::grammar::fa::dexec::Snit_constructor type selfns win self fa args"}
+
+
+test de-cons-${setimpl}-1.1 {construction error} {
+ catch {grammar::fa::dexec a foo fie far} msg
+ set msg
+} {Error in constructor: unknown option "fie"}
+
+
+test de-cons-${setimpl}-1.2 {construction error} {
+ catch {grammar::fa::dexec a b} msg
+ set msg
+} {Error in constructor: invalid command name "b"}
+
+foreach {n code setup_result} {
+ 00 x {{} 0 x 1}
+ 01 x- {{} 0 x 1}
+ 02 xe {{} 0 x 0}
+ 03 xy {{} 0 x 1 y 1 {x y} 0}
+ 04 xy- {{} 0 x 1 y 1 {x y} 0}
+ 05 xye {{} 0 x 0 y 0 {x y} 0}
+ 06 xyee {{} 0 x 0 y 0 {x y} 0}
+ 07 xye- {{} 0 x 0 y 0 {x y} 0}
+ 08 xy-- {{} 0 x 1 y 1 {x y} 0}
+ 09 xy-= {{} 0 x 1 y 1 {x y} 0}
+ 10 xyz/ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 11 xyz/e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 12 xyz/-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 13 xyz/-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 14 xyz|ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 15 xyz|e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 16 xyz|-- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 17 xyz|-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 18 xyz+eee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 19 xyz+ee- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 20 xyz+e-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 21 xyz+e-= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 22 xyz+--- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 23 xyz+--= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 24 xyz+-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 25 xyz&eee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 26 xyz&ee- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 27 xyz&e-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 28 xyz&e-= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 29 xyz&--- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 30 xyz&--= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 31 xyz&-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 32 xyz!ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 33 xyz!e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 34 xyz!-- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 35 xyz!-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 36 xyz!-e {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+} {
+ foreach {stset expected} $setup_result {
+ foreach {fset __} $setup_result {
+ set key ${n}.${code}.([join $stset {}]).([join $fset {}])
+
+ test de-cons-${setimpl}-1.3.$key {construction error} {
+ grammar::fa a
+ gen $code
+ a start set $stset
+ a final set $fset
+ set nfa [expr {![a is deterministic]}]
+ set fail [catch {grammar::fa::dexec de a -command {lappend events}} msg]
+ a destroy
+ catch {de destroy}
+
+ set res [expr {($nfa && $fail) || (!$nfa && !$fail)}]
+ if {!$res} {set res $msg}
+ set res
+ } 1
+ }
+ }
+}
+
+test de-cons-${setimpl}-1.4 {construction error} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ catch {grammar::fa::dexec de a -any *} msg
+ a destroy
+ set msg
+} {Error in constructor: Chosen any symbol "*" does not exist}
+
+test de-cons-${setimpl}-1.5 {construction error} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ catch {grammar::fa::dexec de a -any @} msg
+ a destroy
+ set msg
+} {Error in constructor: Command callback missing}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test de-cons-${setimpl}-2.0 {construction} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ grammar::fa::dexec de a -command {lappend events}
+ a destroy
+ de destroy
+} {}
+
+
+test de-cons-${setimpl}-2.1 {construction} {
+ set res {}
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ lappend res [info commands ::de]
+ grammar::fa::dexec de a -command {lappend events}
+ a destroy
+ lappend res [info commands ::de]
+ de destroy
+ lappend res [info commands ::de]
+ set res
+} {{} ::de {}}
+
+
+test de-cons-${setimpl}-2.2 {construction} {
+ grammar::fa a
+ gen xyz+-=_
+ a start add x
+ grammar::fa::dexec de a -any @ -command {lappend events}
+ a destroy
+ de destroy
+} {}
+
+
+# -------------------------------------------------------------------------
+unset events
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/de_exec.test b/tcllib/modules/grammar_fa/tests/de_exec.test
new file mode 100644
index 0000000..ab0cce9
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/de_exec.test
@@ -0,0 +1,104 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa::dexec engine
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: de_exec.test,v 1.6 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+# Regular expression for C comments (Extended notation, using the 'not' operator).
+#
+# '/' . '*' . (! (ALL* . '*' . '/' . ALL*)) . '*' . '/'
+# ALL = '/' | '*' | 'any'
+#
+# Generated minimal DFA
+#
+# any/ *
+# | |
+# 0 -/-> 1 -*-> 2 -*-> 3 -/-> 4
+# \<-any-/
+
+#puts -nonewline " RE compile, " ; flush stdout
+
+grammar::fa ccomments fromRegex {. {S /}
+ {S *}
+ {! {. {* {| {S *} {S /} {S any}}}
+ {S *}
+ {S /}
+ {* {| {S *} {S /} {S any}}}}}
+ {S *}
+ {S /}
+ } {/ * any}
+
+#puts -nonewline {FA, } ; flush stdout
+
+ccomments determinize ; #puts -nonewline {deterministic, } ; flush stdout
+ccomments minimize ; #puts minimal ; flush stdout
+
+# -------------------------------------------------------------------------
+
+global events
+
+# -------------------------------------------------------------------------
+
+test de-reset-${setimpl}-1.0 {reset error} {
+ grammar::fa::dexec de ccomments -command {lappend events}
+ catch {de reset x} msg
+ de destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::dexec::Snit_methodreset type selfns win self"}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n string acceptany accept} {
+ 0 {x y}
+ {reset . error BADTRANS {Bad transition ("0" "any"), no destination} .}
+ {reset . error BADSYM {Bad symbol "x"} .}
+
+ 1 {/ * * /}
+ {reset . state 1 . state 2 . state 3 . state 4 final 4}
+ {reset . state 1 . state 2 . state 3 . state 4 final 4}
+
+ 2 {/ * x * /}
+ {reset . state 1 . state 2 . state 2 . state 3 . state 4 final 4}
+ {reset . state 1 . state 2 . error BADSYM {Bad symbol "x"} . .}
+
+ 3 {/ * * / * /}
+ {reset . state 1 . state 2 . state 3 . state 4 final 4 . error BADTRANS {Bad transition ("4" "*"), no destination} .}
+ {reset . state 1 . state 2 . state 3 . state 4 final 4 . error BADTRANS {Bad transition ("4" "*"), no destination} .}
+
+ 4 {/ * x * / x * /}
+ {reset . state 1 . state 2 . state 2 . state 3 . state 4 final 4 . error BADTRANS {Bad transition ("4" "any"), no destination} . .}
+ {reset . state 1 . state 2 . error BADSYM {Bad symbol "x"} . . . . .}
+
+ 5 {/ * * * / * * /}
+ {reset . state 1 . state 2 . state 3 . state 3 . state 4 final 4 . error BADTRANS {Bad transition ("4" "*"), no destination} . .}
+ {reset . state 1 . state 2 . state 3 . state 3 . state 4 final 4 . error BADTRANS {Bad transition ("4" "*"), no destination} . .}
+} {
+ test de-put-${setimpl}-2.$n {put, -any any} {
+ set events {}
+ grammar::fa::dexec de ccomments -any any -command {lappend events}
+ foreach sy $string {
+ lappend events .
+ de put $sy
+ }
+ de destroy
+ set events
+ } $acceptany ; # {}
+
+ test de-put-${setimpl}-3.$n {put} {
+ set events {}
+ grammar::fa::dexec de ccomments -command {lappend events}
+ foreach sy $string {
+ lappend events .
+ de put $sy
+ }
+ de destroy
+ set events
+ } $accept ; # {}
+}
+
+# -------------------------------------------------------------------------
+ccomments destroy
+unset events
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_cons.test b/tcllib/modules/grammar_fa/tests/fa_cons.test
new file mode 100644
index 0000000..6bbfaf1
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_cons.test
@@ -0,0 +1,87 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_cons.test,v 1.6 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-cons-${setimpl}-1.0 {construction error} {
+ catch {grammar::fa a foo} msg
+ set msg
+} {Error in constructor: wrong#args: ::a ?=|:=|<--|as|deserialize a'|fromRegex re ?over??}
+
+
+test fa-cons-${setimpl}-1.1 {construction error} {
+ catch {grammar::fa a foo fie far fux} msg
+ set msg
+} {Error in constructor: wrong#args: ::a ?=|:=|<--|as|deserialize a'|fromRegex re ?over??}
+
+
+test fa-cons-${setimpl}-1.2 {construction error} {
+ catch {grammar::fa a foo fie far} msg
+ set msg
+} {Error in constructor: bad assignment: ::a ?=|:=|<--|as|deserialize a'|fromRegex re ?over??}
+
+
+test fa-cons-${setimpl}-1.3 {construction error} {
+ catch {grammar::fa a foo fie} msg
+ set msg
+} {Error in constructor: bad assignment: ::a ?=|:=|<--|as|deserialize a'|fromRegex re ?over??}
+
+
+test fa-cons-${setimpl}-1.4 {construction error} {
+ catch {grammar::fa a = b} msg
+ set msg
+} {Error in constructor: invalid command name "b"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-cons-${setimpl}-2.0 {construction} {
+ grammar::fa a
+ a destroy
+} {}
+
+test fa-cons-${setimpl}-2.1 {construction} {
+ set res {}
+ lappend res [info commands ::a]
+ grammar::fa a
+ lappend res [info commands ::a]
+ a destroy
+ lappend res [info commands ::a]
+ set res
+} {{} ::a {}}
+
+
+test fa-cons-${setimpl}-2.2 {construction, properties of empty fa} {
+ set res {}
+ grammar::fa a
+ lappend res [a info type]
+ lappend res [a symbols]
+ lappend res [a states]
+ lappend res [a finalstates]
+ lappend res [a startstates]
+ lappend res [a reachable_states]
+ lappend res [a useful_states]
+ lappend res [a is deterministic]
+ lappend res [a is useful]
+ lappend res [a is complete]
+ lappend res [a is epsilon-free]
+ a destroy
+ set res
+} {::grammar::fa {} {} {} {} {} {} 0 0 1 1}
+
+
+test fa-cons-${setimpl}-2.3 {construction, serial} {
+ grammar::fa a
+ set res [a serialize]
+ a destroy
+ set res
+} $fa_empty
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_ec.test b/tcllib/modules/grammar_fa/tests/fa_ec.test
new file mode 100644
index 0000000..ef488e7
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_ec.test
@@ -0,0 +1,84 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_ec.test,v 1.4 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-ec-${setimpl}-1.0 {epsilon closure} {
+ grammar::fa a
+ catch {a epsilon_closure} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodepsilon_closure type selfns win self s"}
+
+test fa-ec-${setimpl}-1.1 {epsilon closure} {
+ grammar::fa a
+ catch {a epsilon_closure x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+test fa-ec-${setimpl}-1.2 {epsilon closure} {
+ grammar::fa a
+ catch {a epsilon_closure x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodepsilon_closure type selfns win self s"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n code ec} {
+ 00 x {x}
+ 01 x- {x}
+ 02 xe {x}
+ 03 xy {x}
+ 04 xy- {x}
+ 05 xye {x y}
+ 06 xyee {x y}
+ 07 xye- {x y}
+ 08 xy-- {x}
+ 09 xy-= {x}
+ 10 xyz/ee {x y z}
+ 11 xyz/e- {x z}
+ 12 xyz/-- {x}
+ 13 xyz/-= {x}
+ 14 xyz|ee {x z}
+ 15 xyz|e- {x}
+ 16 xyz|-- {x}
+ 17 xyz|-= {x}
+ 18 xyz+eee {x y z}
+ 19 xyz+ee- {x y z}
+ 20 xyz+e-- {x y}
+ 21 xyz+e-= {x y}
+ 22 xyz+--- {x}
+ 23 xyz+--= {x}
+ 24 xyz+-=_ {x}
+ 25 xyz&eee {x y z}
+ 26 xyz&ee- {x y z}
+ 27 xyz&e-- {x y}
+ 28 xyz&e-= {x y}
+ 29 xyz&--- {x}
+ 30 xyz&--= {x}
+ 31 xyz&-=_ {x}
+ 32 xyz!ee {x y z}
+ 33 xyz!e- {x y}
+ 34 xyz!-- {x}
+ 35 xyz!-= {x}
+ 36 xyz!-e {x}
+} {
+ test fa-ec-${setimpl}-2.${n}.$code {epsilon closure} {
+ grammar::fa a
+ gen $code
+ set res [lsort [a epsilon_closure x]]
+ a destroy
+ set res
+ } $ec
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_final.test b/tcllib/modules/grammar_fa/tests/fa_final.test
new file mode 100644
index 0000000..0927af3
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_final.test
@@ -0,0 +1,391 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_final.test,v 1.6 2009/10/27 21:17:23 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-final-${setimpl}-1.0 {final states, error} {
+ grammar::fa a
+ catch {a finalstates x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodfinalstates type selfns win self"}
+
+
+test fa-final-${setimpl}-1.1 {final query, error} {
+ grammar::fa a
+ catch {a final?} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodfinal? type selfns win self s"}
+
+
+test fa-final-${setimpl}-1.2 {final query, error} {
+ grammar::fa a
+ catch {a final? x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodfinal? type selfns win self s"}
+
+
+test fa-final-${setimpl}-1.3 {final query, error} {
+ grammar::fa a
+ catch {a final? x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-1.4 {final query set, error} {
+ grammar::fa a
+ catch {a final?set} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodfinal?set type selfns win self states"}
+
+
+test fa-final-${setimpl}-1.5 {final query set, error} {
+ grammar::fa a
+ catch {a final?set x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodfinal?set type selfns win self states"}
+
+
+test fa-final-${setimpl}-1.6 {final query set, error} {
+ grammar::fa a
+ catch {a final?set x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-1.7 {final query set, error} {
+ grammar::fa a
+ a state add x
+ catch {a final?set {x y}} res
+ a destroy
+ set res
+} {Illegal state "y"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-final-${setimpl}-2.0 {final, error} {
+ grammar::fa a
+ catch {a final} res
+ a destroy
+ set res
+} {wrong number args: should be "::a final method args"}
+# [tcltest::wrongNumArgs {::a final method} {args} 0]
+
+
+test fa-final-${setimpl}-2.1 {final, error} {
+ grammar::fa a
+ catch {a final foo} res
+ a destroy
+ set res
+} {"::a final foo" is not defined}
+
+
+test fa-final-${setimpl}-2.2 {final, error} {
+ grammar::fa a
+ catch {a final add} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs {::grammar::fa::Snit_hmethodfinal_add} {type selfns win self state args} 0]
+# [snitWrongNumArgs a {final add} {state args} 0]
+# {wrong # args: should be "::grammar::fa::Snit_hmethodfinal_add type selfns win self state args"}
+
+
+test fa-final-${setimpl}-2.3 {final, error} {
+ grammar::fa a
+ catch {a final add x y} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-2.4 {final, error} {
+ grammar::fa a
+ catch {a final add x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-2.5 {final states} {
+ grammar::fa a
+ catch {a final remove} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs {::grammar::fa::Snit_hmethodfinal_remove} {type selfns win self state args} 0]
+# {wrong # args: should be "::grammar::fa::Snit_hmethodfinal_remove type selfns win self state args"}
+
+
+test fa-final-${setimpl}-2.6 {final states} {
+ grammar::fa a
+ catch {a final remove x y} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-2.7 {final states} {
+ grammar::fa a
+ catch {a final remove x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-final-${setimpl}-2.8 {final states} {
+ grammar::fa a
+ catch {a final set} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_hmethodfinal_set type selfns win self states"}
+
+
+test fa-final-${setimpl}-2.9 {final states} {
+ grammar::fa a
+ a state add x
+ catch {a final set {x y}} res
+ a destroy
+ set res
+} {Illegal state "y"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-final-${setimpl}-3.0 {final states, empty fa} {
+ grammar::fa a
+ set res [a finalstates]
+ a destroy
+ set res
+} {}
+
+
+test fa-final-${setimpl}-3.1 {final states, plain state} {
+ grammar::fa a
+ a state add x
+ set res [a finalstates]
+ a destroy
+ set res
+} {}
+
+
+test fa-final-${setimpl}-3.2 {final states, state addition} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a finalstates]
+ a destroy
+ set res
+} x
+
+
+test fa-final-${setimpl}-3.3 {final states, state addition} {
+ grammar::fa a
+ a state add x y
+ a final add x y
+ set res [lsort [a finalstates]]
+ a destroy
+ set res
+} {x y}
+
+
+test fa-final-${setimpl}-3.4 {final states, state addition, and remova;} {
+ grammar::fa a
+ a state add x y
+ a final add x y
+ set res {}
+ lappend res [a finalstates]
+ a final remove y
+ lappend res [a finalstates]
+ a final remove x
+ lappend res [a finalstates]
+ a destroy
+ set res
+} {{x y} x {}}
+
+
+test fa-final-${setimpl}-3.5 {final states, state addition, and remova;} {
+ grammar::fa a
+ a state add x y
+ a final add x y
+ set res {}
+ lappend res [a finalstates]
+ a state delete y
+ lappend res [a finalstates]
+ a state delete x
+ lappend res [a finalstates]
+ a destroy
+ set res
+} {{x y} x {}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-final-${setimpl}-4.0 {final?} {
+ grammar::fa a
+ a state add x
+ set res [a final? x]
+ a destroy
+ set res
+} 0
+
+
+test fa-final-${setimpl}-4.1 {final?} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a final? x]
+ a destroy
+ set res
+} 1
+
+
+test fa-final-${setimpl}-4.2 {final?} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a final? x]
+ a final remove x
+ lappend res [a final? x]
+ a destroy
+ set res
+} {1 0}
+
+
+test fa-final-${setimpl}-4.3 {final?} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a final? x]
+ a state delete x
+ catch {a final? x} msg
+ lappend res $msg
+ a destroy
+ set res
+} {1 {Illegal state "x"}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-final-${setimpl}-5.0 {final?set} {
+ grammar::fa a
+ a state add x
+ set res [a final?set x]
+ a destroy
+ set res
+} 0
+
+
+test fa-final-${setimpl}-5.1 {final?set} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a final?set x]
+ a destroy
+ set res
+} 1
+
+
+test fa-final-${setimpl}-5.2 {final?set} {
+ grammar::fa a
+ set res {}
+ a state add x
+ a final add x
+ lappend res [a final?set x]
+ a final remove x
+ lappend res [a final?set x]
+ a destroy
+ set res
+} {1 0}
+
+
+test fa-final-${setimpl}-5.3 {final?set} {
+ grammar::fa a
+ set res {}
+ a state add x y
+ a final add x
+ lappend res [a final?set y]
+ lappend res [a final?set {x y}]
+ a destroy
+ set res
+} {0 1}
+
+
+test fa-final-${setimpl}-5.4 {final?set} {
+ grammar::fa a
+ a state add x
+ set res {}
+ lappend res [a final? x]
+ lappend res [a final remove x]
+ lappend res [a final? x]
+ a destroy
+ set res
+} {0 {} 0}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test fa-final-${setimpl}-6.0 {final clear} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res {}
+ lappend res [a finalstates]
+ a final clear
+ lappend res [a finalstates]
+ a destroy
+ set res
+} {x {}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-final-${setimpl}-7.0 {final set} {
+ grammar::fa a
+ a state add x
+ a final set x
+ set res [a finalstates]
+ a destroy
+ set res
+} x
+
+
+test fa-final-${setimpl}-7.1 {final set} {
+ grammar::fa a
+ a state add x y
+ a final set {x y}
+ set res [lsort [a finalstates]]
+ a destroy
+ set res
+} {x y}
+
+
+test fa-final-${setimpl}-7.2 {final set} {
+ grammar::fa a
+ set res {}
+ a state add x y z
+ a final add z
+ lappend res [a finalstates]
+ a final set {x y}
+ lappend res [lsort [a finalstates]]
+ a destroy
+ set res
+} {z {x y}}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_is.test b/tcllib/modules/grammar_fa/tests/fa_is.test
new file mode 100644
index 0000000..8f8e36a
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_is.test
@@ -0,0 +1,59 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_is.test,v 1.4 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-is-${setimpl}-1.0 {is, error} {
+ grammar::fa a
+ catch {a is} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodis type selfns win self cmd"}
+
+
+test fa-is-${setimpl}-1.1 {is, error} {
+ grammar::fa a
+ catch {a is foo} msg
+ a destroy
+ set msg
+} {Expected complete, deterministic, epsilon-free, or useful, got "foo"}
+
+
+test fa-is-${setimpl}-1.2 {is, error} {
+ grammar::fa a
+ catch {a is complete bar} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodis type selfns win self cmd"}
+
+
+test fa-is-${setimpl}-1.3 {is, error} {
+ grammar::fa a
+ catch {a is deterministic bar} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodis type selfns win self cmd"}
+
+
+test fa-is-${setimpl}-1.4 {is, error} {
+ grammar::fa a
+ catch {a is useful bar} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodis type selfns win self cmd"}
+
+
+test fa-is-${setimpl}-1.5 {is, error} {
+ grammar::fa a
+ catch {a is epsilon-free bar} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodis type selfns win self cmd"}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_is_complete.test b/tcllib/modules/grammar_fa/tests/fa_is_complete.test
new file mode 100644
index 0000000..7229303
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_is_complete.test
@@ -0,0 +1,60 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_is_complete.test,v 1.5 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+foreach {n code result} {
+ 00 x 1
+ 01 x- 1
+ 02 xe 1
+ 03 xy 1
+ 04 xy- 0
+ 05 xye 1
+ 06 xyee 1
+ 07 xye- 1
+ 08 xy-- 1
+ 09 xy-= 0
+ 10 xyz/ee 1
+ 11 xyz/e- 0
+ 12 xyz/-- 0
+ 13 xyz/-= 0
+ 14 xyz|ee 1
+ 15 xyz|e- 0
+ 16 xyz|-- 0
+ 17 xyz|-= 0
+ 18 xyz+eee 1
+ 19 xyz+ee- 1
+ 20 xyz+e-- 1
+ 21 xyz+e-= 0
+ 22 xyz+--- 1
+ 23 xyz+--= 0
+ 24 xyz+-=_ 0
+ 25 xyz&eee 1
+ 26 xyz&ee- 0
+ 27 xyz&e-- 0
+ 28 xyz&e-= 0
+ 29 xyz&--- 0
+ 30 xyz&--= 0
+ 31 xyz&-=_ 0
+ 32 xyz!ee 1
+ 33 xyz!e- 0
+ 34 xyz!-- 0
+ 35 xyz!-= 0
+ 36 xyz!-e 0
+} {
+ test fa-is-${setimpl}-complete-1.${n}.$code {is complete} {
+ grammar::fa a
+ gen $code
+ set res [a is complete]
+ a destroy
+ set res
+ } $result ;# {}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_is_deterministic.test b/tcllib/modules/grammar_fa/tests/fa_is_deterministic.test
new file mode 100644
index 0000000..3be3831
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_is_deterministic.test
@@ -0,0 +1,75 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_is_deterministic.test,v 1.7 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+
+foreach {n code setup_result} {
+ 00 x {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}
+ 23 xyz+--= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 24 xyz+-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 25 xyz&eee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 26 xyz&ee- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 27 xyz&e-- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 28 xyz&e-= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 29 xyz&--- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 30 xyz&--= {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 31 xyz&-=_ {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 32 xyz!ee {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 33 xyz!e- {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 34 xyz!-- {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 35 xyz!-= {{} 0 x 1 y 1 z 1 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+ 36 xyz!-e {{} 0 x 0 y 0 z 0 {x y} 0 {x z} 0 {y z} 0 {x y z} 0}
+} {
+ foreach {stset expected} $setup_result {
+ foreach {fset __} $setup_result {
+ set key ${n}.${code}.([join $stset {}]).([join $fset {}])
+
+ test fa-is-${setimpl}-deterministic-1.$key {is deterministic} {
+ grammar::fa a
+ gen $code
+ a start set $stset
+ a final set $fset
+ set res [a is deterministic]
+ a destroy
+ set res
+ } $expected ; # {}
+ }
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_is_epsfree.test b/tcllib/modules/grammar_fa/tests/fa_is_epsfree.test
new file mode 100644
index 0000000..32d2f36
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_is_epsfree.test
@@ -0,0 +1,60 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_is_epsfree.test,v 1.4 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+foreach {n code result} {
+ 00 x 1
+ 01 x- 1
+ 02 xe 0
+ 03 xy 1
+ 04 xy- 1
+ 05 xye 0
+ 06 xyee 0
+ 07 xye- 0
+ 08 xy-- 1
+ 09 xy-= 1
+ 10 xyz/ee 0
+ 11 xyz/e- 0
+ 12 xyz/-- 1
+ 13 xyz/-= 1
+ 14 xyz|ee 0
+ 15 xyz|e- 0
+ 16 xyz|-- 1
+ 17 xyz|-= 1
+ 18 xyz+eee 0
+ 19 xyz+ee- 0
+ 20 xyz+e-- 0
+ 21 xyz+e-= 0
+ 22 xyz+--- 1
+ 23 xyz+--= 1
+ 24 xyz+-=_ 1
+ 25 xyz&eee 0
+ 26 xyz&ee- 0
+ 27 xyz&e-- 0
+ 28 xyz&e-= 0
+ 29 xyz&--- 1
+ 30 xyz&--= 1
+ 31 xyz&-=_ 1
+ 32 xyz!ee 0
+ 33 xyz!e- 0
+ 34 xyz!-- 1
+ 35 xyz!-= 1
+ 36 xyz!-e 0
+} {
+ test fa-is-${setimpl}-epsilonfree-1.${n}.$code {is epsilon free} {
+ grammar::fa a
+ gen $code
+ set res [a is epsilon-free]
+ a destroy
+ set res
+ } $result ; # {}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_is_useful.test b/tcllib/modules/grammar_fa/tests/fa_is_useful.test
new file mode 100644
index 0000000..65d870b
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_is_useful.test
@@ -0,0 +1,715 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_is_useful.test,v 1.7 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+unset -nocomplain expected
+array set expected {
+ 04.xy-.(x,y) _
+ 04.xy-.(x,xy) _
+ 04.xy-.(xy,y) _
+ 05.xye.(x,y) _
+ 05.xye.(x,xy) _
+ 05.xye.(xy,y) _
+ 06.xyee.(x,x) _
+ 06.xyee.(x,y) _
+ 06.xyee.(x,xy) _
+ 06.xyee.(y,x) _
+ 06.xyee.(y,y) _
+ 06.xyee.(y,xy) _
+ 06.xyee.(xy,x) _
+ 06.xyee.(xy,y) _
+ 07.xye-.(x,x) _
+ 07.xye-.(x,y) _
+ 07.xye-.(x,xy) _
+ 07.xye-.(y,x) _
+ 07.xye-.(y,y) _
+ 07.xye-.(y,xy) _
+ 07.xye-.(xy,x) _
+ 07.xye-.(xy,y) _
+ 08.xy--.(x,x) _
+ 08.xy--.(x,y) _
+ 08.xy--.(x,xy) _
+ 08.xy--.(y,x) _
+ 08.xy--.(y,y) _
+ 08.xy--.(y,xy) _
+ 08.xy--.(xy,x) _
+ 08.xy--.(xy,y) _
+ 09.xy-=.(x,x) _
+ 09.xy-=.(x,y) _
+ 09.xy-=.(x,xy) _
+ 09.xy-=.(y,x) _
+ 09.xy-=.(y,y) _
+ 09.xy-=.(y,xy) _
+ 09.xy-=.(xy,x) _
+ 09.xy-=.(xy,y) _
+ 10.xyz/ee.(x,yz) _
+ 10.xyz/ee.(x,xyz) _
+ 10.x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.xyz+e-=.(xyz,yz) _
+ 22.xyz+---.(x,x) _
+ 22.xyz+---.(x,y) _
+ 22.xyz+---.(x,z) _
+ 22.xyz+---.(x,xy) _
+ 22.xyz+---.(x,xz) _
+ 22.xyz+---.(x,yz) _
+ 22.xyz+---.(x,xyz) _
+ 22.xyz+---.(y,x) _
+ 22.xyz+---.(y,y) _
+ 22.xyz+---.(y,z) _
+ 22.xyz+---.(y,xy) _
+ 22.xyz+---.(y,xz) _
+ 22.xyz+---.(y,yz) _
+ 22.xyz+---.(y,xyz) _
+ 22.xyz+---.(z,x) _
+ 22.xyz+---.(z,y) _
+ 22.xyz+---.(z,z) _
+ 22.xyz+---.(z,xy) _
+ 22.xyz+---.(z,xz) _
+ 22.xyz+---.(z,yz) _
+ 22.xyz+---.(z,xyz) _
+ 22.xyz+---.(xy,x) _
+ 22.xyz+---.(xy,y) _
+ 22.xyz+---.(xy,z) _
+ 22.xyz+---.(xy,xy) _
+ 22.xyz+---.(xy,xz) _
+ 22.xyz+---.(xy,yz) _
+ 22.xyz+---.(xy,xyz) _
+ 22.xyz+---.(xz,x) _
+ 22.xyz+---.(xz,y) _
+ 22.xyz+---.(xz,z) _
+ 22.xyz+---.(xz,xy) _
+ 22.xyz+---.(xz,xz) _
+ 22.xyz+---.(xz,yz) _
+ 22.xyz+---.(xz,xyz) _
+ 22.xyz+---.(yz,x) _
+ 22.xyz+---.(yz,y) _
+ 22.xyz+---.(yz,z) _
+ 22.xyz+---.(yz,xy) _
+ 22.xyz+---.(yz,xz) _
+ 22.xyz+---.(yz,yz) _
+ 22.xyz+---.(yz,xyz) _
+ 22.xyz+---.(xyz,x) _
+ 22.xyz+---.(xyz,y) _
+ 22.xyz+---.(xyz,z) _
+ 22.xyz+---.(xyz,xy) _
+ 22.xyz+---.(xyz,xz) _
+ 22.xyz+---.(xyz,yz) _
+ 23.xyz+--=.(x,x) _
+ 23.xyz+--=.(x,y) _
+ 23.xyz+--=.(x,z) _
+ 23.xyz+--=.(x,xy)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{
+ set sets {{} x y z {x y} {x z} {y z} {x y z}}
+ set max 2
+ } elseif {[string match xy* $code]} {
+ set sets {{} x y {x y}}
+ set max 1
+ } elseif {[string match x* $code]} {
+ set sets {{} x}
+ set max 0
+ } else {
+ set sets {{}}
+ set max 4
+ }
+
+ foreach st $sets {
+ foreach fin $sets {
+ set key $n.$code.([join $st {}],[join $fin {}])
+
+ if {
+ ([join $st {}] eq [join $fin {}]) &&
+ ([join $st {}] eq [string range $code 0 $max])
+ } {
+ # If all states are both start and final the FA cannot
+ # be other than useful.
+ set expected($key) .
+ }
+
+ test fa-is-${setimpl}-useful-1.$key {is useful} {
+ grammar::fa a
+ gen $code
+ a start set $st
+ a final set $fin
+ set res [a is useful]
+ a destroy
+ set res
+ } [info exists expected($key)] ;# {}
+ }
+ }
+}
+
+
+#parray expected
+unset expected
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_next.test b/tcllib/modules/grammar_fa/tests/fa_next.test
new file mode 100644
index 0000000..749d354
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_next.test
@@ -0,0 +1,421 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_next.test,v 1.5 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-next-${setimpl}-1.0 {next} {
+ grammar::fa a
+ catch {a next} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_methodnext {type selfns win self s sym args} 5]
+
+
+test fa-next-${setimpl}-1.1 {next} {
+ grammar::fa a
+ catch {a next a} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_methodnext {type selfns win self s sym args} 5]
+
+
+test fa-next-${setimpl}-1.2 {next} {
+ grammar::fa a
+ catch {a next a b c} res
+ a destroy
+ set res
+} {wrong#args: ::a next s sym ?--> s'?}
+
+
+test fa-next-${setimpl}-1.3 {next} {
+ grammar::fa a
+ catch {a next a b c d e} res
+ a destroy
+ set res
+} {wrong#args: ::a next s sym ?--> s'?}
+
+
+test fa-next-${setimpl}-1.4 {next} {
+ grammar::fa a
+ catch {a next a b} res
+ a destroy
+ set res
+} {Illegal state "a"}
+
+
+test fa-next-${setimpl}-1.5 {next} {
+ grammar::fa a
+ a state add a
+ catch {a next a b} res
+ a destroy
+ set res
+} {Illegal symbol "b"}
+
+
+test fa-next-${setimpl}-1.6 {next} {
+ grammar::fa a
+ a state add a
+ a symbol add b
+ catch {a next a b --> c} res
+ a destroy
+ set res
+} {Illegal state "c"}
+
+
+test fa-next-${setimpl}-1.7 {next} {
+ grammar::fa a
+ a state add a
+ a state add c
+ a symbol add b
+ catch {a next a b x c} res
+ a destroy
+ set res
+} {Expected -->, got "x"}
+
+
+test fa-next-${setimpl}-1.8 {next} {
+ grammar::fa a
+ a state add a c
+ a symbol add b
+ a next a b --> c
+ catch {a next a b --> c} res
+ a destroy
+ set res
+} {Transition "(a, (b)) --> c" is already known}
+
+
+test fa-next-${setimpl}-1.9 {!next} {
+ grammar::fa a
+ catch {a !next} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_method!next {type selfns win self s sym args} 5]
+
+
+test fa-next-${setimpl}-1.10 {!next} {
+ grammar::fa a
+ catch {a !next a} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_method!next {type selfns win self s sym args} 5]
+
+
+test fa-next-${setimpl}-1.11 {!next} {
+ grammar::fa a
+ catch {a !next a b c} res
+ a destroy
+ set res
+} {wrong#args: ::a !next s sym ?--> s'?}
+
+
+test fa-next-${setimpl}-1.12 {!next} {
+ grammar::fa a
+ catch {a !next a b c d e} res
+ a destroy
+ set res
+} {wrong#args: ::a !next s sym ?--> s'?}
+
+
+test fa-next-${setimpl}-1.13 {!next} {
+ grammar::fa a
+ catch {a !next a b} res
+ a destroy
+ set res
+} {Illegal state "a"}
+
+
+test fa-next-${setimpl}-1.14 {!next} {
+ grammar::fa a
+ a state add a
+ catch {a !next a b} res
+ a destroy
+ set res
+} {Illegal symbol "b"}
+
+
+test fa-next-${setimpl}-1.15 {!next} {
+ grammar::fa a
+ a state add a
+ a symbol add b
+ catch {a !next a b --> c} res
+ a destroy
+ set res
+} {Illegal state "c"}
+
+
+test fa-next-${setimpl}-1.16 {!next} {
+ grammar::fa a
+ a state add a
+ a state add c
+ a symbol add b
+ catch {a !next a b x c} res
+ a destroy
+ set res
+} {Expected -->, got "x"}
+
+
+test fa-next-${setimpl}-1.17 {nextset} {
+ grammar::fa a
+ catch {a nextset} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodnextset type selfns win self states sym"}
+
+
+test fa-next-${setimpl}-1.18 {nextset} {
+ grammar::fa a
+ catch {a nextset a} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodnextset type selfns win self states sym"}
+
+
+test fa-next-${setimpl}-1.19 {nextset} {
+ grammar::fa a
+ catch {a nextset a b c} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodnextset type selfns win self states sym"}
+
+
+test fa-next-${setimpl}-1.20 {nextset} {
+ grammar::fa a
+ catch {a nextset a b} res
+ a destroy
+ set res
+} {Illegal symbol "b"}
+
+
+test fa-next-${setimpl}-1.21 {nextset} {
+ grammar::fa a
+ a symbol add b
+ catch {a nextset a b} res
+ a destroy
+ set res
+} {Illegal state "a"}
+
+
+test fa-next-${setimpl}-1.22 {nextset} {
+ grammar::fa a
+ a symbol add b
+ a state add a
+ catch {a nextset {a c} b} res
+ a destroy
+ set res
+} {Illegal state "c"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-next-${setimpl}-2.0 {next} {
+ grammar::fa a
+ a state add a
+ a symbol add b
+ set res [a next a b]
+ a destroy
+ set res
+} {}
+
+
+test fa-next-${setimpl}-2.1 {next} {
+ grammar::fa a
+ a state add a
+ a state add c
+ a symbol add b
+ a next a b --> c
+ set res [a next a b]
+ a destroy
+ set res
+} c
+
+
+test fa-next-${setimpl}-2.2 {next} {
+ grammar::fa a
+ a state add a c d
+ a symbol add b
+ a next a b --> c
+ a next a b --> d
+ set res [lsort [a next a b]]
+ a destroy
+ set res
+} {c d}
+
+
+test fa-next-${setimpl}-2.3 {next, loop} {
+ grammar::fa a
+ a state add a
+ a symbol add @
+ a next a @ --> a
+ set res [a next a @]
+ a destroy
+ set res
+} a
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-next-${setimpl}-3.0 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a symbol add b
+ a next a b --> a
+ lappend res [a next a b]
+ a !next a b --> a
+ lappend res [a next a b]
+ a destroy
+ set res
+} {a {}}
+
+
+test fa-next-${setimpl}-3.1 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a symbol add b
+ a next a b --> a
+ lappend res [a next a b]
+ a !next a b
+ lappend res [a next a b]
+ a destroy
+ set res
+} {a {}}
+
+
+test fa-next-${setimpl}-3.2 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a state add b
+ a symbol add b
+ a next a b --> a
+ a next a b --> b
+ lappend res [lsort [a next a b]]
+ a !next a b --> a
+ lappend res [a next a b]
+ a destroy
+ set res
+} {{a b} b}
+
+
+test fa-next-${setimpl}-3.3 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a state add b
+ a symbol add b
+ a next a b --> a
+ a next a b --> b
+ lappend res [lsort [a next a b]]
+ a !next a b
+ lappend res [a next a b]
+ a destroy
+ set res
+} {{a b} {}}
+
+
+test fa-next-${setimpl}-3.4 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a symbol add b
+ a !next a b
+ a destroy
+ set res
+} {}
+
+
+test fa-next-${setimpl}-3.5 {!next} {
+ set res {}
+ grammar::fa a
+ a state add a
+ a symbol add b
+ a !next a b --> a
+ a destroy
+ set res
+} {}
+
+
+test fa-next-${setimpl}-3.6 {!next, loop} {
+ grammar::fa a
+ a state add a
+ a symbol add @
+ a next a @ --> a
+ set res [a next a @]
+ a !next a @ --> a
+ a destroy
+ set res
+} a
+
+
+test fa-next-${setimpl}-3.7 {!next, loop} {
+ grammar::fa a
+ a state add a
+ a symbol add @
+ a next a @ --> a
+ set res [a next a @]
+ a !next a @
+ a destroy
+ set res
+} a
+
+
+test fa-next-${setimpl}-3.8 {!next, loop} {
+ grammar::fa a
+ a state add a
+ a symbol add @ =
+ a next a @ --> a
+ a next a = --> a
+ a !next a @ --> a
+ a !next a = --> a
+ a destroy
+} {}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-next-${setimpl}-4.0 {nextset} {
+ grammar::fa a
+ a symbol add b
+ a state add a
+ a state add c
+ set res [a nextset {a c} b]
+ a destroy
+ set res
+} {}
+
+
+test fa-next-${setimpl}-4.1 {nextset} {
+ grammar::fa a
+ a symbol add b
+ a state add a
+ a state add c
+ a next a b --> c
+ set res [a nextset {a c} b]
+ a destroy
+ set res
+} c
+
+
+test fa-next-${setimpl}-4.2 {nextset} {
+ grammar::fa a
+ a symbol add b
+ a state add a
+ a state add c
+ a next a b --> c
+ a next c b --> a
+ set res [lsort [a nextset {a c} b]]
+ a destroy
+ set res
+} {a c}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_reach.test b/tcllib/modules/grammar_fa/tests/fa_reach.test
new file mode 100644
index 0000000..21ac0d1
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_reach.test
@@ -0,0 +1,344 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_reach.test,v 1.4 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-reach-${setimpl}-1.0 {reachability} {
+ grammar::fa a
+ catch {a reachable_states x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodreachable_states type selfns win self"}
+
+
+test fa-reach-${setimpl}-1.1 {!reachability} {
+ grammar::fa a
+ catch {a unreachable_states a} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodunreachable_states type selfns win self"}
+
+
+test fa-reach-${setimpl}-1.2 {reachability} {
+ grammar::fa a
+ catch {a reachable} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodreachable type selfns win self s"}
+
+
+test fa-reach-${setimpl}-1.3 {reachability} {
+ grammar::fa a
+ catch {a reachable x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-reach-${setimpl}-1.4 {reachability} {
+ grammar::fa a
+ catch {a reachable x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodreachable type selfns win self s"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-reach-${setimpl}-2.0 {reachable states, empty fa} {
+ grammar::fa a
+ set res [a reachable_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-reach-${setimpl}-2.1 {reachable states, state addition, plain} {
+ grammar::fa a
+ a state add x
+ set res [a reachable_states]
+ a destroy
+ set res
+} {}
+
+test fa-reach-${setimpl}-2.2 {reachable states, state addition, final} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a reachable_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-reach-${setimpl}-2.3 {reachable states, state addition, start} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a reachable_states]
+ a destroy
+ set res
+} x
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-reach-${setimpl}-3.0 {unreachable states, empty fa} {
+ grammar::fa a
+ set res [a unreachable_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-reach-${setimpl}-3.1 {unreachable states, state addition, plain} {
+ grammar::fa a
+ a state add x
+ set res [a unreachable_states]
+ a destroy
+ set res
+} x
+
+test fa-reach-${setimpl}-3.2 {unreachable states, state addition, final} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a unreachable_states]
+ a destroy
+ set res
+} x
+
+
+test fa-reach-${setimpl}-3.3 {unreachable states, state addition, start} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a unreachable_states]
+ a destroy
+ set res
+} {}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code setup_result} {
+ 00 x {{} {} x x x {}}
+ 01 x- {{} {} x x x {}}
+ 02 xe {{} {} x x x {}}
+ 03 xy {{} {} {x y} x x y y y x {x y} {x y} {}}
+ 04 xy- {{} {} {x y} x {x y} {} y y x {x y} {x y} {}}
+ 05 xye {{} {} {x y} x {x y} {} y y x {x y} {x y} {}}
+ 06 xyee {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 07 xye- {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 08 xy-- {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 09 xy-= {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 10 xyz/ee {
+ {} {} {x y z} x {x y z} {}
+ y y {x z} z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 11 xyz/e- {
+ {} {} {x y z} x {x y z} {}
+ y y {x z} z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 12 xyz/-- {
+ {} {} {x y z} x {x y z} {}
+ y y {x z} z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 13 xyz/-= {
+ {} {} {x y z} x {x y z} {}
+ y y {x z} z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 14 xyz|ee {
+ {} {} {x y z} x {x z} y
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x z} y
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 15 xyz|e- {
+ {} {} {x y z} x {x z} y
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x z} y
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 16 xyz|-- {
+ {} {} {x y z} x {x z} y
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x z} y
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 17 xyz|-= {
+ {} {} {x y z} x {x z} y
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x z} y
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 18 xyz+eee {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 19 xyz+ee- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 20 xyz+e-- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 21 xyz+e-= {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 22 xyz+--- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 23 xyz+--= {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 24 xyz+-=_ {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 25 xyz&eee {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 26 xyz&ee- {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 27 xyz&e-- {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 28 xyz&e-= {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 29 xyz&--- {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 30 xyz&--= {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 31 xyz&-=_ {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 32 xyz!ee {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 33 xyz!e- {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 34 xyz!-- {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 35 xyz!-= {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+ 36 xyz!-e {
+ {} {} {x y z} x {x y z} {}
+ y {y z} x z z {x y}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {y z} x {x y z} {x y z} {}
+ }
+} {
+ foreach {fset reachable unreach} $setup_result {
+ set key ${n}.${code}.([join $fset {}])
+ set expected {}
+ foreach x $reachable {lappend expected 1}
+ foreach x $unreach {lappend expected 0}
+
+ test fa-reach-${setimpl}-4.$key {reachable states} {
+ grammar::fa a
+ gen $code
+ a start set $fset
+ set res [lsort [a reachable_states]]
+ a destroy
+ set res
+ } $reachable ; # {}
+
+ test fa-reach-${setimpl}-5.$key {!reachable states} {
+ grammar::fa a
+ gen $code
+ a start set $fset
+ set res [lsort [a unreachable_states]]
+ a destroy
+ set res
+ } $unreach ; # {}
+
+ test fa-reach-${setimpl}-6.$key {reachability testing} {
+ grammar::fa a
+ gen $code
+ a start set $fset
+ set res {}
+ foreach x $reachable {lappend res [a reachable $x]}
+ foreach x $unreach {lappend res [a reachable $x]}
+ a destroy
+ set res
+ } $expected ; # {}
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_serial.test b/tcllib/modules/grammar_fa/tests/fa_serial.test
new file mode 100644
index 0000000..46b018f
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_serial.test
@@ -0,0 +1,221 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_serial.test,v 1.8 2007/04/12 03:43:14 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+
+test fa-serial-${setimpl}-1.0 {serialize, error} {
+ grammar::fa a
+ catch {a serialize a} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methodserialize type selfns win self"}
+
+
+test fa-serial-${setimpl}-1.1 {deserialize, error} {
+ grammar::fa a
+ catch {a deserialize} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methoddeserialize type selfns win self value"}
+
+
+test fa-serial-${setimpl}-1.2 {deserialize, error} {
+ grammar::fa a
+ catch {a deserialize a b} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_methoddeserialize type selfns win self value"}
+
+
+test fa-serial-${setimpl}-1.3 {assignment, error} {
+ grammar::fa a
+ catch {a =} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_method= type selfns win self b"}
+
+
+test fa-serial-${setimpl}-1.4 {assignment, error} {
+ grammar::fa a
+ catch {a = a b} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_method= type selfns win self b"}
+
+
+test fa-serial-${setimpl}-1.5 {assignment, error} {
+ grammar::fa a
+ catch {a -->} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_method--> type selfns win self b"}
+
+test fa-serial-${setimpl}-1.6 {assignment, error} {
+ grammar::fa a
+ catch {a --> a b} msg
+ a destroy
+ set msg
+} {wrong # args: should be "::grammar::fa::Snit_method--> type selfns win self b"}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n code} {
+ 00 x
+ 01 x-
+ 02 xe
+ 03 xy
+ 04 xy-
+ 05 xye
+ 06 xyee
+ 07 xye-
+ 08 xy--
+ 09 xy-=
+ 10 xyz/ee
+ 11 xyz/e-
+ 12 xyz/--
+ 13 xyz/-=
+ 14 xyz|ee
+ 15 xyz|e-
+ 16 xyz|--
+ 17 xyz|-=
+ 18 xyz+eee
+ 19 xyz+ee-
+ 20 xyz+e--
+ 21 xyz+e-=
+ 22 xyz+---
+ 23 xyz+--=
+ 24 xyz+-=_
+ 25 xyz&eee
+ 26 xyz&ee-
+ 27 xyz&e--
+ 28 xyz&e-=
+ 29 xyz&---
+ 30 xyz&--=
+ 31 xyz&-=_
+ 32 xyz!ee
+ 33 xyz!e-
+ 34 xyz!--
+ 35 xyz!-=
+ 36 xyz!-e
+} {
+ if {[string match xyz* $code]} {
+ set sets {{} x y z {x y} {x z} {y z} {x y z}}
+ } elseif {[string match xy* $code]} {
+ set sets {{} x y {x y}}
+ } elseif {[string match x* $code]} {
+ set sets {{} x}
+ } else {
+ set sets {{}}
+ }
+
+ foreach st $sets {
+ foreach fin $sets {
+ set key $n.$code.([join $st {}],[join $fin {}])
+
+ test fa-serial-${setimpl}-2.$key {serialize} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+ set res [validate_serial [a serialize] a]
+ a destroy
+ set res
+ } ok
+
+ test fa-serial-${setimpl}-3.$key {deserialize} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+
+ grammar::fa b
+ b deserialize [a serialize]
+ set res [validate_serial [b serialize] a]
+ lappend res [validate_serial [a serialize] b]
+
+ a destroy
+ b destroy
+ set res
+ } {ok ok}
+
+ test fa-serial-${setimpl}-4.$key {assignment} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+
+ grammar::fa b
+ b = a
+ set res [validate_serial [b serialize] a]
+ lappend res [validate_serial [a serialize] b]
+
+ a destroy
+ b destroy
+ set res
+ } {ok ok}
+
+ test fa-serial-${setimpl}-5.$key {reverse assignment} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+
+ grammar::fa b
+ a --> b
+ set res [validate_serial [b serialize] a]
+ lappend res [validate_serial [a serialize] b]
+
+ a destroy
+ b destroy
+ set res
+ } {ok ok}
+
+ foreach op {= := <-- as} {
+ test fa-serial-${setimpl}-6.$key.$op {construction from fa} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+
+ grammar::fa b $op a
+ set res [validate_serial [b serialize] a]
+ lappend res [validate_serial [a serialize] b]
+
+ a destroy
+ b destroy
+ set res
+ } {ok ok}
+ }
+
+ test fa-serial-${setimpl}-7.$key {construction from fa} {
+ grammar::fa a
+ gen $code
+ foreach s $st {if {[a state exists $s]} {a start add $s}}
+ foreach s $fin {if {[a state exists $s]} {a final add $s}}
+
+ grammar::fa b deserialize [a serialize]
+ set res [validate_serial [b serialize] a]
+ lappend res [validate_serial [a serialize] b]
+
+ a destroy
+ b destroy
+ set res
+ } {ok ok}
+ }
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_start.test b/tcllib/modules/grammar_fa/tests/fa_start.test
new file mode 100644
index 0000000..bc12f1c
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_start.test
@@ -0,0 +1,386 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_start.test,v 1.6 2009/10/27 21:17:23 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-start-${setimpl}-1.0 {start states, error} {
+ grammar::fa a
+ catch {a startstates x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstartstates type selfns win self"}
+
+
+test fa-start-${setimpl}-1.1 {start query, error} {
+ grammar::fa a
+ catch {a start?} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstart? type selfns win self s"}
+
+
+test fa-start-${setimpl}-1.2 {start query, error} {
+ grammar::fa a
+ catch {a start? x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstart? type selfns win self s"}
+
+
+test fa-start-${setimpl}-1.3 {start query, error} {
+ grammar::fa a
+ catch {a start? x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-1.4 {start query set, error} {
+ grammar::fa a
+ catch {a start?set} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstart?set type selfns win self states"}
+
+
+test fa-start-${setimpl}-1.5 {start query set, error} {
+ grammar::fa a
+ catch {a start?set x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstart?set type selfns win self states"}
+
+
+test fa-start-${setimpl}-1.6 {start query set, error} {
+ grammar::fa a
+ catch {a start?set x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-1.7 {start query set, error} {
+ grammar::fa a
+ a state add x
+ catch {a start?set {x y}} res
+ a destroy
+ set res
+} {Illegal state "y"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-start-${setimpl}-2.0 {start, error} {
+ grammar::fa a
+ catch {a start} res
+ a destroy
+ set res
+} {wrong number args: should be "::a start method args"}
+# [tcltest::wrongNumArgs ::grammar::fa::Snit_methodstart {type selfns win self cmd args} 5]
+
+
+test fa-start-${setimpl}-2.1 {start, error} {
+ grammar::fa a
+ catch {a start foo} res
+ a destroy
+ set res
+} {"::a start foo" is not defined}
+
+
+test fa-start-${setimpl}-2.2 {start, error} {
+ grammar::fa a
+ catch {a start add} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstart_add {type selfns win self state args} 5]
+
+test fa-start-${setimpl}-2.3 {start, error} {
+ grammar::fa a
+ catch {a start add x y} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-2.4 {start, error} {
+ grammar::fa a
+ catch {a start add x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-2.5 {start states} {
+ grammar::fa a
+ catch {a start remove} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstart_remove {type selfns win self state args} 5]
+
+
+test fa-start-${setimpl}-2.6 {start states} {
+ grammar::fa a
+ catch {a start remove x y} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-2.7 {start states} {
+ grammar::fa a
+ catch {a start remove x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-start-${setimpl}-2.8 {start states} {
+ grammar::fa a
+ catch {a start set} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstart_set {type selfns win self states} 4]
+
+
+test fa-start-${setimpl}-2.9 {start states} {
+ grammar::fa a
+ a state add x
+ catch {a start set {x y}} res
+ a destroy
+ set res
+} {Illegal state "y"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-start-${setimpl}-3.0 {start states, empty fa} {
+ grammar::fa a
+ set res [a startstates]
+ a destroy
+ set res
+} {}
+
+
+test fa-start-${setimpl}-3.1 {start states, plain state} {
+ grammar::fa a
+ a state add x
+ set res [a startstates]
+ a destroy
+ set res
+} {}
+
+
+test fa-start-${setimpl}-3.2 {start states, state addition} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a startstates]
+ a destroy
+ set res
+} x
+
+
+test fa-start-${setimpl}-3.3 {start states, state addition} {
+ grammar::fa a
+ a state add x y
+ a start add x y
+ set res [lsort [a startstates]]
+ a destroy
+ set res
+} {x y}
+
+
+test fa-start-${setimpl}-3.4 {start states, state addition, and remova;} {
+ grammar::fa a
+ a state add x y
+ a start add x y
+ set res {}
+ lappend res [a startstates]
+ a start remove y
+ lappend res [a startstates]
+ a start remove x
+ lappend res [a startstates]
+ a destroy
+ set res
+} {{x y} x {}}
+
+
+test fa-start-${setimpl}-3.5 {start states, state addition, and remova;} {
+ grammar::fa a
+ a state add x y
+ a start add x y
+ set res {}
+ lappend res [a startstates]
+ a state delete y
+ lappend res [a startstates]
+ a state delete x
+ lappend res [a startstates]
+ a destroy
+ set res
+} {{x y} x {}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-start-${setimpl}-4.0 {start?} {
+ grammar::fa a
+ a state add x
+ set res [a start? x]
+ a destroy
+ set res
+} 0
+
+
+test fa-start-${setimpl}-4.1 {start?} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a start? x]
+ a destroy
+ set res
+} 1
+
+
+test fa-start-${setimpl}-4.2 {start?} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a start? x]
+ a start remove x
+ lappend res [a start? x]
+ a destroy
+ set res
+} {1 0}
+
+
+test fa-start-${setimpl}-4.3 {start?} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a start? x]
+ a state delete x
+ catch {a start? x} msg
+ lappend res $msg
+ a destroy
+ set res
+} {1 {Illegal state "x"}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-start-${setimpl}-5.0 {start?set} {
+ grammar::fa a
+ a state add x
+ set res [a start?set x]
+ a destroy
+ set res
+} 0
+
+
+test fa-start-${setimpl}-5.1 {start?set} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a start?set x]
+ a destroy
+ set res
+} 1
+
+
+test fa-start-${setimpl}-5.2 {start?set} {
+ grammar::fa a
+ set res {}
+ a state add x
+ a start add x
+ lappend res [a start?set x]
+ a start remove x
+ lappend res [a start?set x]
+ a destroy
+ set res
+} {1 0}
+
+
+test fa-start-${setimpl}-5.3 {start?set} {
+ grammar::fa a
+ set res {}
+ a state add x y
+ a start add x
+ lappend res [a start?set y]
+ lappend res [a start?set {x y}]
+ a destroy
+ set res
+} {0 1}
+
+
+test fa-start-${setimpl}-5.4 {start?set} {
+ grammar::fa a
+ a state add x
+ set res {}
+ lappend res [a start? x]
+ lappend res [a start remove x]
+ lappend res [a start? x]
+ a destroy
+ set res
+} {0 {} 0}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test fa-start-${setimpl}-6.0 {start clear} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res {}
+ lappend res [a startstates]
+ a start clear
+ lappend res [a startstates]
+ a destroy
+ set res
+} {x {}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test fa-start-${setimpl}-7.0 {start set} {
+ grammar::fa a
+ a state add x
+ a start set x
+ set res [a startstates]
+ a destroy
+ set res
+} x
+
+
+test fa-start-${setimpl}-7.1 {start set} {
+ grammar::fa a
+ a state add x y
+ a start set {x y}
+ set res [lsort [a startstates]]
+ a destroy
+ set res
+} {x y}
+
+
+test fa-start-${setimpl}-7.2 {start set} {
+ grammar::fa a
+ set res {}
+ a state add x y z
+ a start add z
+ lappend res [a startstates]
+ a start set {x y}
+ lappend res [lsort [a startstates]]
+ a destroy
+ set res
+} {z {x y}}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_state.test b/tcllib/modules/grammar_fa/tests/fa_state.test
new file mode 100644
index 0000000..d752b72
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_state.test
@@ -0,0 +1,304 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_state.test,v 1.8 2009/10/27 21:17:23 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-state-${setimpl}-1.0 {state, error} {
+ grammar::fa a
+ catch {a state} res
+ a destroy
+ set res
+} {wrong number args: should be "::a state method args"}
+# [tcltest::wrongNumArgs {::a state method} {args} 0]
+
+
+test fa-state-${setimpl}-1.1 {state, error} {
+ grammar::fa a
+ catch {a state add} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstate_add {type selfns win self s args} 4]
+
+
+test fa-state-${setimpl}-1.2 {state, error} {
+ grammar::fa a
+ a state add x
+ catch {a state foo x} res
+ a destroy
+ set res
+} {"::a state foo" is not defined}
+
+
+test fa-state-${setimpl}-1.3 {state, error} {
+ grammar::fa a
+ a state add x
+ catch {a state add x} res
+ a destroy
+ set res
+} {State "x" is already known}
+
+
+test fa-state-${setimpl}-1.4 {state, error} {
+ grammar::fa a
+ catch {a state exists} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstate_exists {type selfns win self s} 4]
+
+
+test fa-state-${setimpl}-1.5 {state, error} {
+ grammar::fa a
+ catch {a state exists a b} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_hmethodstate_exists type selfns win self s"}
+
+
+test fa-state-${setimpl}-1.6 {state, error} {
+ grammar::fa a
+ catch {a state delete} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstate_delete {type selfns win self s args} 4]
+
+
+test fa-state-${setimpl}-1.7 {state, error} {
+ grammar::fa a
+ catch {a state delete x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-state-${setimpl}-1.8 {state, error} {
+ grammar::fa a
+ catch {a state rename} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstate_rename {type selfns win self s snew} 0]
+
+
+test fa-state-${setimpl}-1.9 {state, error} {
+ grammar::fa a
+ catch {a state rename foo} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodstate_rename {type selfns win self s snew} 1]
+
+
+test fa-state-${setimpl}-1.10 {state, error} {
+ grammar::fa a
+ catch {a state rename x y} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-state-${setimpl}-1.11 {state, error} {
+ grammar::fa a
+ a state add x y
+ catch {a state rename x y} res
+ a destroy
+ set res
+} {State "y" is already known}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-state-${setimpl}-2.0 {state add} {
+ grammar::fa a
+ set res [a state add x]
+ a destroy
+ set res
+} {}
+
+
+test fa-state-${setimpl}-2.1 {state add, variadic} {
+ grammar::fa a
+ set res [a state add x y]
+ a destroy
+ set res
+} {}
+
+
+test fa-state-${setimpl}-2.2 {state add / states / exists} {
+ grammar::fa a
+ a state add x
+ set res [a states]
+ lappend res [a state exists x]
+ lappend res [a state exists y]
+ a destroy
+ set res
+} {x 1 0}
+
+
+test fa-state-${setimpl}-2.3 {state add / states / exists} {
+ grammar::fa a
+ a state add x y
+ set res {}
+ lappend res [lsort [a states]]
+ lappend res [a state exists x]
+ lappend res [a state exists y]
+ a destroy
+ set res
+} {{x y} 1 1}
+
+
+test fa-state-${setimpl}-2.4 {state add, basic properties} {
+ grammar::fa a
+ a state add x
+ set res {}
+ lappend res [a final? x]
+ lappend res [a start? x]
+ lappend res [a symbols@ x]
+ a destroy
+ set res
+} {0 0 {}}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test fa-state-${setimpl}-3.0 {state delete} {
+ grammar::fa a
+ a state add x
+ set res [a states]
+ lappend res [a state exists x]
+ a state delete x
+ lappend res [a states]
+ lappend res [a state exists x]
+ a destroy
+ set res
+} {x 1 {} 0}
+
+test fa-state-${setimpl}-3.1 {state delete, variadic} {
+ grammar::fa a
+ a state add x y
+ set res {}
+ lappend res [lsort [a states]]
+ lappend res [a state exists x]
+ lappend res [a state exists y]
+ a state delete x y
+ lappend res [a states]
+ lappend res [a state exists x]
+ lappend res [a state exists y]
+ a destroy
+ set res
+} {{x y} 1 1 {} 0 0}
+
+test fa-state-${setimpl}-3.2 {state delete, loop} {
+ grammar::fa a
+ a state add a
+ a symbol add @
+ a next a @ --> a
+ a state delete a
+ a destroy
+} {}
+
+test fa-state-${setimpl}-3.3 {state delete, inbound transition} {
+ grammar::fa a
+ gen xyz!-=
+ set res [a next x @]
+ a state delete y
+ lappend res [a next x @]
+ a destroy
+ set res
+} {y {}}
+
+
+test fa-state-${setimpl}-3.4 {state delete, outbound transition} {
+ grammar::fa a
+ gen xy-
+ a state delete x
+ a state delete y
+ a symbol delete @
+ a destroy
+ set res {}
+} {}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-state-${setimpl}-4.0 {state, exists} {
+ grammar::fa a
+ set res [a state exists x]
+ a destroy
+ set res
+} 0
+
+
+test fa-state-${setimpl}-4.1 {state, exists} {
+ grammar::fa a
+ a state add x
+ set res [a state exists x]
+ a destroy
+ set res
+} 1
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-state-${setimpl}-5.4 {state rename} {
+ grammar::fa a
+ a state add x y
+ a state rename x z
+ set res [a serialize]
+ a destroy
+ set res
+} {grammar::fa {} {z {0 0 {}} y {0 0 {}}}}
+
+
+test fa-state-${setimpl}-5.5 {state rename} {
+ grammar::fa a
+ a state add x y
+ a state rename y z
+ set res [a serialize]
+ a destroy
+ set res
+} {grammar::fa {} {x {0 0 {}} z {0 0 {}}}}
+
+
+test fa-state-${setimpl}-5.6 {state rename} {
+ grammar::fa a
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+ a state rename x z
+ set res [a serialize]
+ a destroy
+ set res
+} {grammar::fa @ {z {0 0 {@ y}} y {0 0 {}}}}
+
+
+test fa-state-${setimpl}-5.7 {state rename} {
+ grammar::fa a
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+ a state rename y z
+ set res [a serialize]
+ a destroy
+ set res
+} {grammar::fa @ {x {0 0 {@ z}} z {0 0 {}}}}
+
+
+test fa-state-${setimpl}-6.0 {state rename with loop, SF bug 2595296} {
+ grammar::fa a
+ a state add x
+ a symbol add @
+ a next x @ --> x
+ a state rename x y
+ set res [a serialize]
+ a destroy
+ set res
+} {grammar::fa @ {y {0 0 {@ y}}}}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_states.test b/tcllib/modules/grammar_fa/tests/fa_states.test
new file mode 100644
index 0000000..788993c
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_states.test
@@ -0,0 +1,76 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_states.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-states-${setimpl}-1.0 {states, argument errors} {
+ grammar::fa a
+ catch {a states x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodstates type selfns win self"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-states-${setimpl}-2.0 {states, empty fa} {
+ grammar::fa a
+ set res [a states]
+ a destroy
+ set res
+} {}
+
+test fa-states-${setimpl}-2.1 {states, state addition} {
+ grammar::fa a
+ a state add x
+ set res [a states]
+ a destroy
+ set res
+} x
+
+test fa-states-${setimpl}-2.2 {states, state addition} {
+ grammar::fa a
+ a state add x y
+ set res [lsort [a states]]
+ a destroy
+ set res
+} {x y}
+
+
+test fa-states-${setimpl}-2.3 {states, state addition and removal} {
+ grammar::fa a
+ a state add x y
+ a state delete x
+ set res [a states]
+ a destroy
+ set res
+} y
+
+
+test fa-states-${setimpl}-2.4 {states, state addition and removal} {
+ grammar::fa a
+ a state add x y
+ a state delete y
+ set res [a states]
+ a destroy
+ set res
+} x
+
+
+test fa-states-${setimpl}-2.5 {states, state addition and removal} {
+ grammar::fa a
+ a state add x y
+ a state delete x y
+ set res [a states]
+ a destroy
+ set res
+} {}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_symbol.test b/tcllib/modules/grammar_fa/tests/fa_symbol.test
new file mode 100644
index 0000000..673baa5
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_symbol.test
@@ -0,0 +1,254 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_symbol.test,v 1.7 2009/10/27 21:17:23 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-symbol-${setimpl}-1.0 {symbol, error} {
+ grammar::fa a
+ catch {a symbol} res
+ a destroy
+ set res
+} {wrong number args: should be "::a symbol method args"}
+# [tcltest::wrongNumArgs {::a symbol method} {sym args} 0]
+
+
+test fa-symbol-${setimpl}-1.1 {symbol, error} {
+ grammar::fa a
+ catch {a symbol foo @} res
+ a destroy
+ set res
+} {"::a symbol foo" is not defined}
+
+
+test fa-symbol-${setimpl}-1.2 {symbol, error} {
+ grammar::fa a
+ catch {a symbol add} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodsymbol_add {type selfns win self sym args} 4]
+
+
+test fa-symbol-${setimpl}-1.3 {symbol, error} {
+ grammar::fa a
+ a symbol add x
+ catch {a symbol add x} res
+ a destroy
+ set res
+} {Symbol "x" is already known}
+
+
+test fa-symbol-${setimpl}-1.4 {symbol, error} {
+ grammar::fa a
+ catch {a symbol add ""} res
+ a destroy
+ set res
+} {Cannot add illegal empty symbol ""}
+
+
+test fa-symbol-${setimpl}-1.5 {symbol, error} {
+ grammar::fa a
+ catch {a symbol delete} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodsymbol_delete {type selfns win self sym args} 4]
+
+
+test fa-symbol-${setimpl}-1.6 {symbol, error} {
+ grammar::fa a
+ catch {a symbol delete @} res
+ a destroy
+ set res
+} {Illegal symbol "@"}
+
+
+test fa-symbol-${setimpl}-1.7 {symbol, error} {
+ grammar::fa a
+ catch {a symbol exists} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodsymbol_exists {type selfns win self sym} 4]
+
+
+test fa-symbol-${setimpl}-1.8 {symbol, error} {
+ grammar::fa a
+ catch {a symbol exists a b} res
+ a destroy
+ set res
+} [tcltest::tooManyArgs ::grammar::fa::Snit_hmethodsymbol_exists {type selfns win self sym}]
+
+
+test fa-symbol-${setimpl}-1.9 {symbol, error} {
+ grammar::fa a
+ catch {a symbol rename} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodsymbol_rename {type selfns win self sym newsym} 4]
+
+
+test fa-symbol-${setimpl}-1.10 {symbol, error} {
+ grammar::fa a
+ catch {a symbol rename foo} res
+ a destroy
+ set res
+} [tcltest::wrongNumArgs ::grammar::fa::Snit_hmethodsymbol_rename {type selfns win self sym newsym} 5]
+
+
+test fa-symbol-${setimpl}-1.11 {symbol, error} {
+ grammar::fa a
+ catch {a symbol rename foo bar snarf} res
+ a destroy
+ set res
+} [tcltest::tooManyArgs ::grammar::fa::Snit_hmethodsymbol_rename {type selfns win self sym newsym}]
+
+
+test fa-symbol-${setimpl}-1.12 {symbol, error} {
+ grammar::fa a
+ catch {a symbol rename x y} res
+ a destroy
+ set res
+} {Illegal symbol "x"}
+
+
+test fa-symbol-${setimpl}-1.13 {symbol, error} {
+ grammar::fa a
+ catch {a symbol rename "" y} res
+ a destroy
+ set res
+} {Illegal symbol ""}
+
+
+test fa-symbol-${setimpl}-1.14 {symbol, error} {
+ grammar::fa a
+ a symbol add x y
+ catch {a symbol rename x y} res
+ a destroy
+ set res
+} {Symbol "y" is already known}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-symbol-${setimpl}-2.0 {symbol add} {
+ grammar::fa a
+ set res {}
+ lappend res [a symbol add x y]
+ lappend res [lsort [a symbols]]
+ a destroy
+ set res
+} {{} {x y}}
+
+
+test fa-symbol-${setimpl}-2.1 {symbol add} {
+ grammar::fa a
+ a symbol add x
+ set res [a symbols]
+ a destroy
+ set res
+} x
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-symbol-${setimpl}-3.0 {symbol delete} {
+ grammar::fa a
+ a symbol add x
+ set res [a symbols]
+ lappend res [a symbol exists x]
+ a symbol delete x
+ lappend res [a symbols]
+ lappend res [a symbol exists x]
+ a destroy
+ set res
+} {x 1 {} 0}
+
+
+test fa-symbol-${setimpl}-3.1 {symbol delete, transitions} {
+ grammar::fa a
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+
+ set res [a symbols]
+ lappend res [a symbol exists @]
+ a symbol delete @
+ lappend res [a symbols]
+ lappend res [a symbol exists @]
+ lappend res [validate_serial {grammar::fa {} {x {0 0 {}} y {0 0 {}}}} a]
+ a destroy
+ set res
+} {@ 1 {} 0 ok}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-symbol-${setimpl}-4.0 {symbol exists} {
+ grammar::fa a
+ set res [a symbol exists x]
+ a destroy
+ set res
+} 0
+
+
+test fa-symbol-${setimpl}-4.1 {symbol exists} {
+ grammar::fa a
+ a symbol add x
+ set res [a symbol exists x]
+ a destroy
+ set res
+} 1
+
+
+test fa-symbol-${setimpl}-4.2 {symbol exists} {
+ grammar::fa a
+ a symbol add x
+ set res [a symbol exists x]
+ a symbol delete x
+ lappend res [a symbol exists x]
+ a destroy
+ set res
+} {1 0}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+test fa-symbol-${setimpl}-5.0 {symbol rename} {
+ grammar::fa a
+ a symbol add x y
+ a symbol rename x z
+ set res [validate_serial {grammar::fa {y z} {}} a]
+ a destroy
+ set res
+} ok
+
+
+test fa-symbol-${setimpl}-5.1 {symbol rename} {
+ grammar::fa a
+ a symbol add x y
+ a symbol rename y z
+ set res [validate_serial {grammar::fa {x z} {}} a]
+ a destroy
+ set res
+} ok
+
+
+test fa-symbol-${setimpl}-5.2 {symbol rename} {
+ grammar::fa a
+ a state add x y
+ a symbol add @
+ a next x @ --> y
+ a symbol rename @ =
+ set res [validate_serial {grammar::fa = {x {0 0 {= y}} y {0 0 {}}}} a]
+ a destroy
+ set res
+} ok
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_symbols.test b/tcllib/modules/grammar_fa/tests/fa_symbols.test
new file mode 100644
index 0000000..06054b4
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_symbols.test
@@ -0,0 +1,81 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_symbols.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-symbols-${setimpl}-1.0 {symbols, argument errors} {
+ grammar::fa a
+ catch {a symbols x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols type selfns win self"}
+
+
+test fa-symbols-${setimpl}-1.1 {symbol mgmt} {
+ grammar::fa a
+ catch {a symbols x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols type selfns win self"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-symbols-${setimpl}-2.0 {symbols, empty fa} {
+ grammar::fa a
+ set res [a symbols]
+ a destroy
+ set res
+} {}
+
+test fa-symbols-${setimpl}-2.1 {symbols, symbol addition} {
+ grammar::fa a
+ a symbol add x
+ set res [a symbols]
+ a destroy
+ set res
+} x
+
+test fa-symbols-${setimpl}-2.2 {symbols, symbol addition} {
+ grammar::fa a
+ a symbol add x y
+ set res [lsort [a symbols]]
+ a destroy
+ set res
+} {x y}
+
+test fa-symbols-${setimpl}-2.3 {symbols, symbol addition and removal} {
+ grammar::fa a
+ a symbol add x y
+ a symbol delete x
+ set res [a symbols]
+ a destroy
+ set res
+} y
+
+test fa-symbols-${setimpl}-2.4 {symbols, symbol addition and removal} {
+ grammar::fa a
+ a symbol add x y
+ a symbol delete y
+ set res [a symbols]
+ a destroy
+ set res
+} x
+
+test fa-symbols-${setimpl}-2.5 {symbols, symbol addition and removal} {
+ grammar::fa a
+ a symbol add x y
+ a symbol delete x y
+ set res [a symbols]
+ a destroy
+ set res
+} {}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_symbols_at.test b/tcllib/modules/grammar_fa/tests/fa_symbols_at.test
new file mode 100644
index 0000000..0a9057f
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_symbols_at.test
@@ -0,0 +1,138 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_symbols_at.test,v 1.6 2007/08/14 21:42:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-symbols-${setimpl}-at-1.0 {symbols@, error} {
+ grammar::fa a
+ catch {a symbols@} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols@ type selfns win self s ?t?"}
+
+
+test fa-symbols-${setimpl}-at-1.1 {symbols@, error} {
+ grammar::fa a
+ catch {a symbols@ x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-symbols-${setimpl}-at-1.2 {symbols@, error} {
+ grammar::fa a
+ catch {a symbols@ x y z} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols@ type selfns win self s ?t?"}
+
+
+test fa-symbols-${setimpl}-at-1.3 {symbols@set, error} {
+ grammar::fa a
+ catch {a symbols@set} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols@set type selfns win self states"}
+
+
+test fa-symbols-${setimpl}-at-1.4 {symbols@set, error} {
+ grammar::fa a
+ catch {a symbols@set x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodsymbols@set type selfns win self states"}
+
+
+test fa-symbols-${setimpl}-at-1.5 {symbols@set, error} {
+ grammar::fa a
+ catch {a symbols@set x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-symbols-${setimpl}-at-1.6 {symbols@set, error} {
+ grammar::fa a
+ a state add y
+ catch {a symbols@set {y x}} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n code setup_result} {
+ 00 x {x {}}
+ 01 x- {x @}
+ 02 xe {x {{}}}
+ 03 xy {x {} y {}}
+ 04 xy- {x @ y {}}
+ 05 xye {x {{}} y {}}
+ 06 xyee {x {{}} y {{}}}
+ 07 xye- {x {{}} y @}
+ 08 xy-- {x @ y @}
+ 09 xy-= {x @ y =}
+ 10 xyz/ee {x {{}} y {} z {}}
+ 11 xyz/e- {x {{} @} y {} z {}}
+ 12 xyz/-- {x @ y {} z {}}
+ 13 xyz/-= {x {= @} y {} z {}}
+ 14 xyz|ee {x {{}} y {{}} z {}}
+ 15 xyz|e- {x @ y {{}} z {}}
+ 16 xyz|-- {x @ y @ z {}}
+ 17 xyz|-= {x @ y = z {}}
+ 18 xyz+eee {x {{}} y {{}} z {{}}}
+ 19 xyz+ee- {x {{}} y {{}} z @}
+ 20 xyz+e-- {x {{}} y @ z @}
+ 21 xyz+e-= {x {{}} y @ z =}
+ 22 xyz+--- {x @ y @ z @}
+ 23 xyz+--= {x @ y @ z =}
+ 24 xyz+-=_ {x @ y = z %}
+ 25 xyz&eee {x {{}} y {{}} z {}}
+ 26 xyz&ee- {x {{}} y @ z {}}
+ 27 xyz&e-- {x {{} @} y @ z {}}
+ 28 xyz&e-= {x {{} @} y = z {}}
+ 29 xyz&--- {x @ y @ z {}}
+ 30 xyz&--= {x @ y = z {}}
+ 31 xyz&-=_ {x {= @} y % z {}}
+ 32 xyz!ee {x {{}} y {{}} z {}}
+ 33 xyz!e- {x {{}} y @ z {}}
+ 34 xyz!-- {x @ y @ z {}}
+ 35 xyz!-= {x @ y = z {}}
+ 36 xyz!-e {x @ y {{}} z {}}
+} {
+ foreach {state expected} $setup_result {
+ set key ${n}.$code.$state
+
+ test fa-symbols-${setimpl}-at-2.$key {symbols@} {
+ grammar::fa a
+ gen $code
+ set res [lsort [a symbols@ $state]]
+ a destroy
+ set res
+ } $expected ; # {}
+ }
+}
+
+foreach {n code setup_result} {
+} {
+ foreach {states expected} $setup_result {
+ set key ${n}.$code.[join $states {}]
+
+ test fa-symbols-${setimpl}-at-3.$key {symbols@set} {
+ grammar::fa a
+ gen $code
+ set res [lsort [a symbols@set $states]]
+ a destroy
+ set res
+ } $expected ; # {}
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/fa_useful.test b/tcllib/modules/grammar_fa/tests/fa_useful.test
new file mode 100644
index 0000000..131740a
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/fa_useful.test
@@ -0,0 +1,344 @@
+# -*- tcl -*-
+# finite_automaton.test: tests for the grammar::fa container.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: fa_useful.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test fa-useful-${setimpl}-1.0 {usefulness} {
+ grammar::fa a
+ catch {a useful_states x} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methoduseful_states type selfns win self"}
+
+
+test fa-useful-${setimpl}-1.1 {!usefulness} {
+ grammar::fa a
+ catch {a unuseful_states a} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methodunuseful_states type selfns win self"}
+
+
+test fa-useful-${setimpl}-1.2 {usefulness} {
+ grammar::fa a
+ catch {a useful} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methoduseful type selfns win self s"}
+
+
+test fa-useful-${setimpl}-1.3 {usefulness} {
+ grammar::fa a
+ catch {a useful x} res
+ a destroy
+ set res
+} {Illegal state "x"}
+
+
+test fa-useful-${setimpl}-1.4 {usefulness} {
+ grammar::fa a
+ catch {a useful x y} res
+ a destroy
+ set res
+} {wrong # args: should be "::grammar::fa::Snit_methoduseful type selfns win self s"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-useful-${setimpl}-2.0 {useful states, empty fa} {
+ grammar::fa a
+ set res [a useful_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-useful-${setimpl}-2.1 {useful states, state addition, plain} {
+ grammar::fa a
+ a state add x
+ set res [a useful_states]
+ a destroy
+ set res
+} {}
+
+test fa-useful-${setimpl}-2.2 {useful states, state addition, final} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a useful_states]
+ a destroy
+ set res
+} x
+
+
+test fa-useful-${setimpl}-2.3 {useful states, state addition, start} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a useful_states]
+ a destroy
+ set res
+} {}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+test fa-useful-${setimpl}-3.0 {unuseful states, empty fa} {
+ grammar::fa a
+ set res [a unuseful_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-useful-${setimpl}-3.1 {unuseful states, state addition, plain} {
+ grammar::fa a
+ a state add x
+ set res [a unuseful_states]
+ a destroy
+ set res
+} x
+
+test fa-useful-${setimpl}-3.2 {unuseful states, state addition, final} {
+ grammar::fa a
+ a state add x
+ a final add x
+ set res [a unuseful_states]
+ a destroy
+ set res
+} {}
+
+
+test fa-useful-${setimpl}-3.3 {unuseful states, state addition, start} {
+ grammar::fa a
+ a state add x
+ a start add x
+ set res [a unuseful_states]
+ a destroy
+ set res
+} x
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code setup_result} {
+ 00 x {{} {} x x x {}}
+ 01 x- {{} {} x x x {}}
+ 02 xe {{} {} x x x {}}
+ 03 xy {{} {} {x y} x x y y y x {x y} {x y} {}}
+ 04 xy- {{} {} {x y} x x y y {x y} {} {x y} {x y} {}}
+ 05 xye {{} {} {x y} x x y y {x y} {} {x y} {x y} {}}
+ 06 xyee {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 07 xye- {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 08 xy-- {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 09 xy-= {{} {} {x y} x {x y} {} y {x y} {} {x y} {x y} {}}
+ 10 xyz/ee {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x z} y
+ {x y} {x y} z {x z} {x z} y
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 11 xyz/e- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x z} y
+ {x y} {x y} z {x z} {x z} y
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 12 xyz/-- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x z} y
+ {x y} {x y} z {x z} {x z} y
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 13 xyz/-= {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x z} y
+ {x y} {x y} z {x z} {x z} y
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 14 xyz|ee {
+ {} {} {x y z} x x {y z}
+ y y {x z} z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 15 xyz|e- {
+ {} {} {x y z} x x {y z}
+ y y {x z} z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 16 xyz|-- {
+ {} {} {x y z} x x {y z}
+ y y {x z} z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 17 xyz|-= {
+ {} {} {x y z} x x {y z}
+ y y {x z} z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 18 xyz+eee {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 19 xyz+ee- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 20 xyz+e-- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 21 xyz+e-= {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 22 xyz+--- {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 23 xyz+--= {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 24 xyz+-=_ {
+ {} {} {x y z} x {x y z} {}
+ y {x y z} {} z {x y z} {}
+ {x y} {x y z} {} {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 25 xyz&eee {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 26 xyz&ee- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 27 xyz&e-- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 28 xyz&e-= {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 29 xyz&--- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 30 xyz&--= {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 31 xyz&-=_ {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 32 xyz!ee {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 33 xyz!e- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 34 xyz!-- {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 35 xyz!-= {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+ 36 xyz!-e {
+ {} {} {x y z} x x {y z}
+ y {x y} z z {x y z} {}
+ {x y} {x y} z {x z} {x y z} {}
+ {y z} {x y z} {} {x y z} {x y z} {}
+ }
+} {
+ foreach {fset useful unuse} $setup_result {
+ set key ${n}.${code}.([join $fset {}])
+ set expected {}
+ foreach x $useful {lappend expected 1}
+ foreach x $unuse {lappend expected 0}
+
+ test fa-useful-${setimpl}-4.$key {useful states} {
+ grammar::fa a
+ gen $code
+ a final set $fset
+ set res [lsort [a useful_states]]
+ a destroy
+ set res
+ } $useful ; # {}
+
+ test fa-useful-${setimpl}-5.$key {!useful states} {
+ grammar::fa a
+ gen $code
+ a final set $fset
+ set res [lsort [a unuseful_states]]
+ a destroy
+ set res
+ } $unuse ; # {}
+
+ test fa-useful-${setimpl}-6.$key {usefulness testing} {
+ grammar::fa a
+ gen $code
+ a final set $fset
+ set res {}
+ foreach x $useful {lappend res [a useful $x]}
+ foreach x $unuse {lappend res [a useful $x]}
+ a destroy
+ set res
+ } $expected ; # {}
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_complete.test b/tcllib/modules/grammar_fa/tests/faop_complete.test
new file mode 100644
index 0000000..ff87a9d
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_complete.test
@@ -0,0 +1,107 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_complete.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-complete-${setimpl}-1.0 {complete, error} {
+ catch {grammar::fa::op::complete} res
+ set res
+} {wrong # args: should be "grammar::fa::op::complete fa ?sink?"}
+
+
+test faop-complete-${setimpl}-1.1 {complete, error} {
+ catch {grammar::fa::op::complete a b c} res
+ set res
+} {wrong # args: should be "grammar::fa::op::complete fa ?sink?"}
+
+
+test faop-complete-${setimpl}-1.2 {complete, error} {
+ catch {grammar::fa::op::complete a} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-complete-${setimpl}-1.3 {complete, error} {
+ grammar::fa a
+ a state add sink x
+ a symbol add @
+ catch {grammar::fa::op::complete a sink} res
+ a destroy
+ set res
+} {The chosen sink state exists already}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code result} {
+ 00 x {grammar::fa {} {x {0 0 {}}}}
+ 01 x- {grammar::fa @ {x {0 0 {@ x}}}}
+ 02 xe {grammar::fa {} {x {0 0 {{} x}}}}
+ 03 xy {grammar::fa {} {x {0 0 {}} y {0 0 {}}}}
+ 04 xy- {grammar::fa @ {x {0 0 {@ y}} y {0 0 {@ sink}} sink {0 0 {@ sink}}}}
+ 05 xye {grammar::fa {} {x {0 0 {{} y}} y {0 0 {}}}}
+ 06 xyee {grammar::fa {} {x {0 0 {{} y}} y {0 0 {{} x}}}}
+ 07 xyz/ee {grammar::fa {} {x {0 0 {{} {y z}}} y {0 0 {}} z {0 0 {}}}}
+ 08 xyz/-= {grammar::fa {@ =} {x {0 0 {@ y = z}} y {0 0 {@ sink = sink}} z {0 0 {@ sink = sink}} sink {0 0 {@ sink = sink}}}}
+ 09 xyz|ee {grammar::fa {} {x {0 0 {{} z}} y {0 0 {{} z}} z {0 0 {}}}}
+ 10 xyz|-= {grammar::fa {@ =} {x {0 0 {@ z = sink}} y {0 0 {@ sink = z}} z {0 0 {@ sink = sink}} sink {0 0 {@ sink = sink}}}}
+ 11 xyz+eee {grammar::fa {} {x {0 0 {{} y}} y {0 0 {{} z}} z {0 0 {{} x}}}}
+ 12 xyz+-=_ {grammar::fa {@ % =} {x {0 0 {@ y % sink = sink}} y {0 0 {@ sink % sink = z}} z {0 0 {@ sink = sink % x}} sink {0 0 {@ sink = sink % sink}}}}
+ 13 xyz&eee {grammar::fa {} {x {0 0 {{} {y z}}} y {0 0 {{} z}} z {0 0 {}}}}
+ 14 xyz&-=_ {grammar::fa {@ % =} {x {0 0 {@ y % sink = z}} y {0 0 {@ sink = sink % z}} z {0 0 {@ sink = sink % sink}} sink {0 0 {@ sink = sink % sink}}}}
+ 15 xyz!ee {grammar::fa {} {x {0 0 {{} y}} y {0 0 {{} z}} z {0 0 {}}}}
+ 16 xyz!-= {grammar::fa {@ % =} {x {0 0 {@ y % sink = sink}} y {0 0 {@ sink % sink = z}} z {0 0 {@ sink = sink % sink}} sink {0 0 {@ sink = sink % sink}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-complete-${setimpl}-2.$key {complete} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::complete a sink
+ set res [a is complete]
+ lappend res [validate_serial $result a]
+ a destroy
+ set res
+ } {1 ok}
+
+ test faop-complete-${setimpl}-3.$key {second complete is a null operation} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::complete a
+ set res [a serialize]
+ grammar::fa::op::complete a
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+
+ test faop-complete-${setimpl}-4.$key {complete, as method} {
+ grammar::fa a
+ gen $code
+ a complete sink
+ set res [a is complete]
+ lappend res [validate_serial $result a]
+ a destroy
+ set res
+ } {1 ok}
+
+ test faop-complete-${setimpl}-5.$key {as method, second complete is a null operation} {
+ grammar::fa a
+ gen $code
+ a complete
+ set res [a serialize]
+ a complete
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_concat.test b/tcllib/modules/grammar_fa/tests/faop_concat.test
new file mode 100644
index 0000000..ad2b422
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_concat.test
@@ -0,0 +1,113 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_concat.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-concat-${setimpl}-1.0 {concat, error} {
+ catch {grammar::fa::op::concatenate} res
+ set res
+} {wrong # args: should be "grammar::fa::op::concatenate fa fb ?mapvar?"}
+
+
+test faop-concat-${setimpl}-1.1 {concat, error} {
+ catch {grammar::fa::op::concatenate a b c d} res
+ set res
+} {wrong # args: should be "grammar::fa::op::concatenate fa fb ?mapvar?"}
+
+
+test faop-concat-${setimpl}-1.2 {concat, error} {
+ catch {grammar::fa::op::concatenate a b} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-concat-${setimpl}-1.3 {concat, error} {
+ grammar::fa a
+ catch {grammar::fa::op::concatenate a b} res
+ a destroy
+ set res
+} {invalid command name "b"}
+
+
+test faop-concat-${setimpl}-1.4 {concat, error} {
+ grammar::fa a
+ grammar::fa b
+ catch {grammar::fa::op::concatenate a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to concatenate FAs without start/final states}
+
+
+test faop-concat-${setimpl}-1.5 {concat, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a start add x
+ catch {grammar::fa::op::concatenate a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to concatenate FAs without start/final states}
+
+
+test faop-concat-${setimpl}-1.6 {concat, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a final add x
+ catch {grammar::fa::op::concatenate a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to concatenate FAs without start/final states}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n fa fb fres rmap} {
+ 0
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+ {grammar::fa = {u {1 0 {= v}} v {0 1 {}}}}
+ {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} m.0}} u {0 0 {= v}} v {0 0 {{} f.0}} s.0 {1 0 {{} x}} f.0 {0 1 {}} m.0 {0 0 {{} u}}}}
+ {}
+
+ 1
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+ {grammar::fa = {x {1 0 {= y}} y {0 1 {}}}}
+ {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} m.0}} 0 {0 0 {= 1}} 1 {0 0 {{} f.0}} s.0 {1 0 {{} x}} f.0 {0 1 {}} m.0 {0 0 {{} 0}}}}
+ {0 x 1 y}
+} {
+ set key ${n}
+
+ test faop-concat-${setimpl}-2.$key {concat} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ grammar::fa::op::concatenate a b map
+ set res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+
+ test faop-concat-${setimpl}-3.$key {concat, as method} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ a concatenate b map
+ set res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_determinize.test b/tcllib/modules/grammar_fa/tests/faop_determinize.test
new file mode 100644
index 0000000..4daaeed
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_determinize.test
@@ -0,0 +1,117 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_determinize.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-determinize-${setimpl}-1.0 {determinize, error} {
+ catch {grammar::fa::op::determinize} res
+ set res
+} {wrong # args: should be "grammar::fa::op::determinize fa ?mapvar? ?idstart?"}
+
+
+test faop-determinize-${setimpl}-1.1 {determinize, error} {
+ catch {grammar::fa::op::determinize a b c d} res
+ set res
+} {wrong # args: should be "grammar::fa::op::determinize fa ?mapvar? ?idstart?"}
+
+
+test faop-determinize-${setimpl}-1.2 {determinize, error} {
+ catch {grammar::fa::op::determinize a} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code st fin mapres result} {
+ 00 datom x y {}
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+
+ 01 dalt u z {0 {u v w} 1 {y z} 2 {x z}}
+ {grammar::fa {@ =} {0 {1 0 {@ 2 = 1}} 1 {0 1 {}} 2 {0 1 {}}}}
+
+ 02 dopt u x {0 {u v x} 1 {w x}}
+ {grammar::fa @ {0 {1 1 {@ 1}} 1 {0 1 {}}}}
+
+ 03 drep u x {0 {u v x} 1 {u v w x}}
+ {grammar::fa @ {0 {1 1 {@ 1}} 1 {0 1 {@ 1}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-determinize-${setimpl}-2.$key {determinize, bounded} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ grammar::fa::op::determinize a map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic]
+ a destroy
+ set res
+ } {ok 1 1}
+
+ test faop-determinize-${setimpl}-3.$key {determinize, bounded, as method} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ a determinize map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic]
+ a destroy
+ set res
+ } {ok 1 1}
+}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code mapres result} {
+ 00 datom {0 x 1 y}
+ {grammar::fa @ {0 {0 0 {@ 1}} 1 {0 0 {}}}}
+
+ 01 dalt {0 x 1 y 2 u 3 z 4 v 5 w 6 {y z} 7 {x z}}
+ {grammar::fa {@ =} {0 {0 0 {}} 1 {0 0 {}} 2 {0 0 {@ 7 = 6}} 3 {0 0 {}} 4 {0 0 {@ 7}} 5 {0 0 {= 6}} 6 {0 0 {}} 7 {0 0 {}}}}
+
+ 02 dopt {0 x 1 u 2 v 3 w 4 {w x}}
+ {grammar::fa @ {0 {0 0 {}} 1 {0 0 {@ 4}} 2 {0 0 {@ 4}} 3 {0 0 {}} 4 {0 0 {}}}}
+
+ 03 drep {0 x 1 u 2 v 3 w 4 {u v w x}}
+ {grammar::fa @ {0 {0 0 {@ 4}} 1 {0 0 {@ 4}} 2 {0 0 {@ 4}} 3 {0 0 {@ 4}} 4 {0 0 {@ 4}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-determinize-${setimpl}-4.$key {determinize, unbounded} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::determinize a map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic] ; # Never formally det, because of missing start.
+ a destroy
+ set res
+ } {ok 1 0}
+
+ test faop-determinize-${setimpl}-5.$key {determinize, unbounded, as method} {
+ grammar::fa a
+ gen $code
+ a determinize map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic] ; # Never formally det, because of missing start.
+ a destroy
+ set res
+ } {ok 1 0}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_difference.test b/tcllib/modules/grammar_fa/tests/faop_difference.test
new file mode 100644
index 0000000..8c3f1f0
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_difference.test
@@ -0,0 +1,110 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_difference.test,v 1.6 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-difference-${setimpl}-1.0 {difference, error} {
+ catch {grammar::fa::op::difference} res
+ set res
+} {wrong # args: should be "grammar::fa::op::difference fa fb ?mapvar?"}
+
+
+test faop-difference-${setimpl}-1.1 {difference, error} {
+ catch {grammar::fa::op::difference a b c d} res
+ set res
+} {wrong # args: should be "grammar::fa::op::difference fa fb ?mapvar?"}
+
+
+test faop-difference-${setimpl}-1.2 {difference, error} {
+ catch {grammar::fa::op::difference a b} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-difference-${setimpl}-1.3 {difference, error} {
+ grammar::fa a
+ catch {grammar::fa::op::difference a b} res
+ a destroy
+ set res
+} {invalid command name "b"}
+
+
+test faop-difference-${setimpl}-1.4 {difference, error} {
+ grammar::fa a
+ grammar::fa b
+ catch {grammar::fa::op::difference a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the difference of two FAs without start/final states}
+
+
+test faop-difference-${setimpl}-1.5 {difference, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a start add x
+ catch {grammar::fa::op::difference a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the difference of two FAs without start/final states}
+
+
+test faop-difference-${setimpl}-1.6 {difference, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a final add x
+ catch {grammar::fa::op::difference a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the difference of two FAs without start/final states}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n fa fb fres rmap} {
+ 00
+ {grammar::fa {a b c} {x {1 0 {a y}} y {0 0 {b y c z}} z {0 1 {}}}}
+ {grammar::fa {a d c} {u {1 0 {a v}} v {0 0 {d v c w}} w {0 1 {}}}}
+ {grammar::fa {a b c d} {0 {1 0 {a 2}} 2 {0 0 {b 4}} 4 {0 0 {c 7 b 4}} 7 {0 1 {}}}}
+ {0 {x u} 2 {y v} 4 {y sink.0} 7 {z sink.0}}
+
+} {
+ set key $n
+
+ test faop-difference-${setimpl}-2.$key {difference} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ set res {}
+ grammar::fa::op::difference a b map
+ lappend res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+
+ test faop-difference-${setimpl}-3.$key {difference, as method} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ set res {}
+ a difference b map
+ lappend res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_intersect.test b/tcllib/modules/grammar_fa/tests/faop_intersect.test
new file mode 100644
index 0000000..8abced6
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_intersect.test
@@ -0,0 +1,111 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_intersect.test,v 1.6 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-intersect-${setimpl}-1.0 {intersect, error} {
+ catch {grammar::fa::op::intersect} res
+ set res
+} {wrong # args: should be "grammar::fa::op::intersect fa fb ?mapvar? ?idstart?"}
+
+
+test faop-intersect-${setimpl}-1.1 {intersect, error} {
+ catch {grammar::fa::op::intersect a b c d e} res
+ set res
+} {wrong # args: should be "grammar::fa::op::intersect fa fb ?mapvar? ?idstart?"}
+
+
+test faop-intersect-${setimpl}-1.2 {intersect, error} {
+ catch {grammar::fa::op::intersect a b} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-intersect-${setimpl}-1.3 {intersect, error} {
+ grammar::fa a
+ catch {grammar::fa::op::intersect a b} res
+ a destroy
+ set res
+} {invalid command name "b"}
+
+
+test faop-intersect-${setimpl}-1.4 {intersect, error} {
+ grammar::fa a
+ grammar::fa b
+ catch {grammar::fa::op::intersect a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the intersection of two FAs without start/final states}
+
+
+test faop-intersect-${setimpl}-1.5 {intersect, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a start add x
+ catch {grammar::fa::op::intersect a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the intersection of two FAs without start/final states}
+
+
+test faop-intersect-${setimpl}-1.6 {intersect, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a final add x
+ catch {grammar::fa::op::intersect a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to perform the intersection of two FAs without start/final states}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n fa fb fres rmap} {
+ 00
+ {grammar::fa {a b c} {x {1 0 {a y}} y {0 0 {b y c z}} z {0 1 {}}}}
+ {grammar::fa {a d c} {u {1 0 {a v}} v {0 0 {d v c w}} w {0 1 {}}}}
+ {grammar::fa {a b c d} {0 {1 0 {a 2}} 2 {0 0 {c 5}} 5 {0 1 {}}}}
+ {0 {x u} 2 {y v} 5 {z w}}
+} {
+ set key $n
+
+ test faop-intersect-${setimpl}-2.$key {intersect} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ set res {}
+ grammar::fa::op::intersect a b map
+
+ lappend res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+
+ test faop-intersect-${setimpl}-3.$key {intersect, as method} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ set res {}
+ a intersect b map
+
+ lappend res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_kleene.test b/tcllib/modules/grammar_fa/tests/faop_kleene.test
new file mode 100644
index 0000000..3db1e72
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_kleene.test
@@ -0,0 +1,102 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_kleene.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-kleene-${setimpl}-1.0 {kleene, error} {
+ catch {grammar::fa::op::kleene} res
+ set res
+} {wrong # args: should be "grammar::fa::op::kleene fa"}
+
+
+test faop-kleene-${setimpl}-1.1 {kleene, error} {
+ catch {grammar::fa::op::kleene a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::kleene fa"}
+
+
+test faop-kleene-${setimpl}-1.2 {kleene, error} {
+ catch {grammar::fa::op::kleene a} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-kleene-${setimpl}-1.3 {kleene, error} {
+ grammar::fa a
+ catch {grammar::fa::op::kleene a} res
+ a destroy
+ set res
+} {Unable to add Kleene's closure to a FA without start/final states}
+
+
+test faop-kleene-${setimpl}-1.4 {kleene, error} {
+ grammar::fa a
+ a state add x
+ a start add x
+ catch {grammar::fa::op::kleene a} res
+ a destroy
+ set res
+} {Unable to add Kleene's closure to a FA without start/final states}
+
+
+test faop-kleene-${setimpl}-1.5 {kleene, error} {
+ grammar::fa a
+ a state add x
+ a final add x
+ catch {grammar::fa::op::kleene a} res
+ a destroy
+ set res
+} {Unable to add Kleene's closure to a FA without start/final states}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code st fin result} {
+ 00 datom x y
+ {grammar::fa @ {x {0 0 {@ y}} y {0 0 {{} f.0}} s.0 {1 0 {{} {x f.0}}} f.0 {0 1 {{} s.0}}}}
+
+ 01 dalt u z
+ {grammar::fa {@ =} {u {0 0 {{} {v w}}} v {0 0 {@ x}} w {0 0 {= y}} x {0 0 {{} z}} y {0 0 {{} z}} z {0 0 {{} f.0}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {{} s.0}}}}
+
+ 02 daltb u z
+ {grammar::fa {@ =} {u {0 0 {{} {v w}}} v {0 0 {@ x}} w {0 0 {= y}} x {0 0 {{} z}} y {0 0 {{} z}} z {0 0 {{} {u f.0}}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {{} s.0}}}}
+
+ 03 dopt u x
+ {grammar::fa @ {u {0 0 {{} {v x}}} v {0 0 {@ w}} w {0 0 {{} x}} x {0 0 {{} f.0}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {{} s.0}}}}
+
+ 04 drep u x
+ {grammar::fa @ {u {0 0 {{} {v x}}} v {0 0 {@ w}} w {0 0 {{} x}} x {0 0 {{} {u f.0}}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {{} s.0}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-kleene-${setimpl}-2.$key {kleene} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ grammar::fa::op::kleene a
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+
+ test faop-kleene-${setimpl}-3.$key {kleene, as method} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ a kleene
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_minimize.test b/tcllib/modules/grammar_fa/tests/faop_minimize.test
new file mode 100644
index 0000000..949d069
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_minimize.test
@@ -0,0 +1,117 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_minimize.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-minimize-${setimpl}-1.0 {minimize, error} {
+ catch {grammar::fa::op::minimize} res
+ set res
+} {wrong # args: should be "grammar::fa::op::minimize fa ?mapvar?"}
+
+
+test faop-minimize-${setimpl}-1.1 {minimize, error} {
+ catch {grammar::fa::op::minimize a b c} res
+ set res
+} {wrong # args: should be "grammar::fa::op::minimize fa ?mapvar?"}
+
+
+test faop-minimize-${setimpl}-1.2 {minimize, error} {
+ catch {grammar::fa::op::minimize a} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code st fin mapres result} {
+ 00 datom x y {}
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+
+ 01 dalt u z {0 {u v w} 1 {x y z}}
+ {grammar::fa {@ =} {0 {1 0 {@ 1 = 1}} 1 {0 1 {}}}}
+
+ 02 dopt u x {0 {u v w x} 1 {u w x}}
+ {grammar::fa @ {0 {1 1 {@ 1}} 1 {0 1 {}}}}
+
+ 03 drep u x {0 {u v w x}}
+ {grammar::fa @ {0 {1 1 {@ 0}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-minimize-${setimpl}-2.$key {minimize, bounded} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ grammar::fa::op::minimize a map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic]
+ a destroy
+ set res
+ } {ok 1 1}
+
+ test faop-minimize-${setimpl}-3.$key {minimize, bounded, as method} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ a minimize map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic]
+ a destroy
+ set res
+ } {ok 1 1}
+}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code mapres result} {
+ 00 datom {0 x 1 y}
+ {grammar::fa @ {0 {0 0 {@ 1}} 1 {0 0 {}}}}
+
+ 01 dalt {0 v 1 x 2 w 3 y 4 {u v} 5 u 6 {u w} 7 z 8 {x z} 9 {y z}}
+ {grammar::fa {@ =} {0 {0 0 {}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {@ 8}} 5 {0 0 {}} 6 {0 0 {= 9}} 7 {0 0 {}} 8 {0 0 {}} 9 {0 0 {}}}}
+
+ 02 dopt {0 {u v} 1 x 2 u 3 v 4 w 5 {w x}}
+ {grammar::fa @ {0 {0 0 {@ 5}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {}} 5 {0 0 {}}}}
+
+ 03 drep {0 {u v w x} 1 x 2 u 3 v 4 w 5 {u v w x}}
+ {grammar::fa @ {0 {0 0 {@ 5}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {}} 5 {0 0 {@ 5}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-minimize-${setimpl}-4.$key {minimize, unbounded} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::minimize a map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic] ; # Never formally det, because of missing start.
+ a destroy
+ set res
+ } {ok 1 0}
+
+ test faop-minimize-${setimpl}-5.$key {minimize, unbounded, as method} {
+ grammar::fa a
+ gen $code
+ a minimize map
+ set res [validate_serial $result a]
+ lappend res [string equal $mapres [dictsort $map]]
+ lappend res [a is deterministic] ; # Never formally det, because of missing start.
+ a destroy
+ set res
+ } {ok 1 0}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_optional.test b/tcllib/modules/grammar_fa/tests/faop_optional.test
new file mode 100644
index 0000000..fcb455f
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_optional.test
@@ -0,0 +1,102 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_optional.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-optional-${setimpl}-1.0 {optional, error} {
+ catch {grammar::fa::op::optional} res
+ set res
+} {wrong # args: should be "grammar::fa::op::optional fa"}
+
+
+test faop-optional-${setimpl}-1.1 {optional, error} {
+ catch {grammar::fa::op::optional a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::optional fa"}
+
+
+test faop-optional-${setimpl}-1.2 {optional, error} {
+ catch {grammar::fa::op::optional a} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-optional-${setimpl}-1.3 {optional, error} {
+ grammar::fa a
+ catch {grammar::fa::op::optional a} res
+ a destroy
+ set res
+} {Unable to make a FA without start/final states optional}
+
+
+test faop-optional-${setimpl}-1.4 {optional, error} {
+ grammar::fa a
+ a state add x
+ a start add x
+ catch {grammar::fa::op::optional a} res
+ a destroy
+ set res
+} {Unable to make a FA without start/final states optional}
+
+
+test faop-optional-${setimpl}-1.5 {optional, error} {
+ grammar::fa a
+ a state add x
+ a final add x
+ catch {grammar::fa::op::optional a} res
+ a destroy
+ set res
+} {Unable to make a FA without start/final states optional}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code st fin result} {
+ 00 datom x y
+ {grammar::fa @ {x {0 0 {@ y}} y {0 0 {{} f.0}} s.0 {1 0 {{} {x f.0}}} f.0 {0 1 {}}}}
+
+ 01 dalt u z
+ {grammar::fa {@ =} {u {0 0 {{} {v w}}} v {0 0 {@ x}} w {0 0 {= y}} x {0 0 {{} z}} y {0 0 {{} z}} z {0 0 {{} f.0}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {}}}}
+
+ 02 daltb u z
+ {grammar::fa {@ =} {u {0 0 {{} {v w}}} v {0 0 {@ x}} w {0 0 {= y}} x {0 0 {{} z}} y {0 0 {{} z}} z {0 0 {{} {u f.0}}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {}}}}
+
+ 03 dopt u x
+ {grammar::fa @ {u {0 0 {{} {v x}}} v {0 0 {@ w}} w {0 0 {{} x}} x {0 0 {{} f.0}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {}}}}
+
+ 04 drep u x
+ {grammar::fa @ {u {0 0 {{} {v x}}} v {0 0 {@ w}} w {0 0 {{} x}} x {0 0 {{} {u f.0}}} s.0 {1 0 {{} {u f.0}}} f.0 {0 1 {}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-optional-${setimpl}-2.$key {optional} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ grammar::fa::op::optional a
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+
+ test faop-optional-${setimpl}-3.$key {optional, as method} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ a optional
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_regex.test b/tcllib/modules/grammar_fa/tests/faop_regex.test
new file mode 100644
index 0000000..961e135
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_regex.test
@@ -0,0 +1,256 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_regex.test,v 1.7 2007/12/03 21:46:25 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-regex-${setimpl}-1.0 {fromRegex, error} {
+ catch {grammar::fa::op::fromRegex} res
+ set res
+} {wrong # args: should be "grammar::fa::op::fromRegex fa regex ?over?"}
+
+
+test faop-regex-${setimpl}-1.1 {fromRegex, error} {
+ catch {grammar::fa::op::fromRegex a b c d} res
+ set res
+} {wrong # args: should be "grammar::fa::op::fromRegex fa regex ?over?"}
+
+
+test faop-regex-${setimpl}-1.2 {fromRegex, error} {
+ catch {grammar::fa::op::fromRegex a b} res
+ set res
+} {Expected . ! ? * | &, or S, got "b"}
+
+
+test faop-regex-${setimpl}-1.3 {fromRegex, error} {
+ catch {grammar::fa::op::fromRegex a {S b}} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreach {n over re fres} {
+ 00 {} {}
+ {grammar::fa {} {}}
+
+ 01 {} {S x}
+ {grammar::fa x {0 {1 0 {x 1}} 1 {0 1 {}}}}
+
+ 02 {} {. {S x} {S y}}
+ {grammar::fa {x y} {0 {1 0 {x 1}} 1 {0 0 {{} 2}} 2 {0 0 {y 3}} 3 {0 1 {}}}}
+
+ 03 {} {| {S x} {S y}}
+ {grammar::fa {x y} {0 {1 0 {{} {2 4}}} 1 {0 1 {}} 2 {0 0 {x 3}} 3 {0 0 {{} 1}} 4 {0 0 {y 5}} 5 {0 0 {{} 1}}}}
+
+ 04 {} {? {S x}}
+ {grammar::fa x {0 {1 0 {{} {2 1}}} 1 {0 1 {}} 2 {0 0 {x 3}} 3 {0 0 {{} 1}}}}
+
+ 05 {} {* {S x}}
+ {grammar::fa x {0 {1 1 {{} 1}} 1 {0 0 {x 2}} 2 {0 0 {{} 0}}}}
+
+ 06 {} {+ {S x}}
+ {grammar::fa x {0 {1 0 {{} 2}} 1 {0 1 {{} 0}} 2 {0 0 {x 3}} 3 {0 0 {{} 1}}}}
+
+ 07 {} {! {S x}}
+ {grammar::fa x {0 {1 0 {{} 2}} 1 {0 1 {}} 2 {0 0 {x 3 {} 1}} 3 {0 0 {x 6}} 6 {0 0 {x 6 {} 1}}}}
+
+ 08 {/ * { } a} {. {S /} {S *} {+ {! {. {S *} {S /}}}} {S *} {S /}}
+ {grammar::fa {{ } a * /} {0 {1 0 {/ 1}} 1 {0 0 {{} 2}} 2 {0 0 {* 3}} 3 {0 0 {{} 4}} 4 {0 0 {{} 6}} 5 {0 0 {{} {4 16}}} 6 {0 0 {{} 12}} 7 {0 0 {{} 5}} 12 {0 0 {{ } 15 {} 7 a 15 * 13 / 15}} 13 {0 0 {{ } 15 {} 7 a 15 * 15 / 14}} 14 {0 0 {{ } 15 a 15 * 15 / 15}} 15 {0 0 {{ } 15 {} 7 a 15 * 15 / 15}} 16 {0 0 {* 17}} 17 {0 0 {{} 18}} 18 {0 0 {/ 19}} 19 {0 1 {}}}}
+
+ 09 {} {. {S x}}
+ {grammar::fa x {0 {1 0 {x 1}} 1 {0 1 {}}}}
+
+ 10 {} {| {S x}}
+ {grammar::fa x {0 {1 0 {x 1}} 1 {0 1 {}}}}
+
+ 11 {} {& {S x}}
+ {grammar::fa x {0 {1 0 {x 1}} 1 {0 1 {}}}}
+
+ 12 {} {& {. {S a} {* {S d}} {S c}} {. {S a} {* {S b}} {S c}}}
+ {grammar::fa {a b c d} {0 {1 0 {{} 2}} 1 {0 1 {}} 2 {0 0 {a 3}} 3 {0 0 {c 4}} 4 {0 0 {{} 1}}}}
+} {
+ set key ${n}
+
+ test faop-regex-${setimpl}-2.$key {fromRegex} {
+ grammar::fa a
+ grammar::fa::op::fromRegex a $re $over
+ set res [validate_serial $fres a]
+ a destroy
+ set res
+
+ } ok
+
+ test faop-regex-${setimpl}-3.$key {fromRegex, as method} {
+ grammar::fa a
+ a fromRegex $re $over
+ set res [validate_serial $fres a]
+ a destroy
+ set res
+ } ok
+}
+
+# -------------------------------------------------------------------------
+
+test faop-regex-${setimpl}-4.0 {toRegexp, error} {
+ catch {grammar::fa::op::toRegexp} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toRegexp fa"}
+
+test faop-regex-${setimpl}-4.1 {toRegexp, error} {
+ catch {grammar::fa::op::toRegexp a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toRegexp fa"}
+
+test faop-regex-${setimpl}-4.2 {toRegexp, error} {
+ catch {grammar::fa::op::toRegexp a} res
+ set res
+} {invalid command name "a"}
+
+test faop-regex-${setimpl}-4.3 {toRegexp} {
+ grammar::fa a
+ a state add 0 1 2
+ a symbol add a
+ a symbol add b
+ a next 0 a --> 1
+ a next 0 b --> 2
+ a next 1 b --> 0
+ a next 2 b --> 0
+ a start add 0
+ a final add 0
+
+ set res [grammar::fa::op::toRegexp a]
+ a destroy
+ set res
+} {* {| {. {S a} {S b}} {. {S b} {S b}}}}
+
+
+test faop-regex-${setimpl}-5.0 {toRegexp2, error} {
+ catch {grammar::fa::op::toRegexp2} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toRegexp2 fa"}
+
+test faop-regex-${setimpl}-5.1 {toRegexp2, error} {
+ catch {grammar::fa::op::toRegexp2 a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toRegexp2 fa"}
+
+test faop-regex-${setimpl}-5.2 {toRegexp2, error} {
+ catch {grammar::fa::op::toRegexp2 a} res
+ set res
+} {invalid command name "a"}
+
+test faop-regex-${setimpl}-5.3 {toRegexp2} {
+ grammar::fa a
+ a state add 0 1 2
+ a symbol add a
+ a symbol add b
+ a next 0 a --> 1
+ a next 0 b --> 2
+ a next 1 b --> 0
+ a next 2 b --> 0
+ a start add 0
+ a final add 0
+
+ set res [grammar::fa::op::toRegexp2 a]
+ a destroy
+ set res
+} {* {| {. {S a} {S b}} {. {S b} {S b}}}}
+
+# -------------------------------------------------------------------------
+
+test faop-regex-${setimpl}-6.0 {toTclRegexp, error} {
+ catch {grammar::fa::op::toTclRegexp} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toTclRegexp re symdict"}
+
+test faop-regex-${setimpl}-6.1 {toTclRegexp, error} {
+ catch {grammar::fa::op::toTclRegexp a b c} res
+ set res
+} {wrong # args: should be "grammar::fa::op::toTclRegexp re symdict"}
+
+test faop-regex-${setimpl}-6.2 {toTclRegexp, error} {
+ catch {grammar::fa::op::toTclRegexp a {}} res
+ set res
+} {invalid command name "a"}
+
+test faop-regex-${setimpl}-6.3 {toTclRegexp} {
+ grammar::fa::op::toTclRegexp {* {| {. {S a} {S b}} {. {S b} {S b}}}} {}
+} {(ab|bb)*}
+
+# -------------------------------------------------------------------------
+
+test faop-regex-${setimpl}-7.0 {simplifyRegexp, error} {
+ catch {grammar::fa::op::simplifyRegexp} res
+ set res
+} {wrong # args: should be "grammar::fa::op::simplifyRegexp RE0"}
+
+test faop-regex-${setimpl}-7.1 {simplifyRegexp, error} {
+ catch {grammar::fa::op::simplifyRegexp a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::simplifyRegexp RE0"}
+
+test faop-regex-${setimpl}-7.2 {simplifyRegexp} {
+ set re {* {. {| {S a} {S b}} {S b}}}
+ grammar::fa::op::simplifyRegexp $re
+} {* {. {| {S a} {S b}} {S b}}}
+
+test faop-regex-${setimpl}-7.3 {simplifyRegexp} {
+ set re {* {| {. {S a} {S b}} {. {S b} {S b}}}}
+ grammar::fa::op::simplifyRegexp $re
+} {* {. {| {S a} {S b}} {S b}}}
+
+# -------------------------------------------------------------------------
+## Two larger examples
+
+test faop-regex-${setimpl}-8.0 {to(Tcl)Regexp, match 2 mod 3, decimal} {
+ set fa [grammar::fa decimal_2_mod_3]
+ $fa state add 0 1 2
+ $fa symbol add 0 1 2 3 4 5 6 7 8 9
+ foreach state [$fa states] {
+ foreach digit [$fa symbols] {
+ $fa next $state $digit --> [expr {(10*$state + $digit) % 3}]
+ }
+ }
+ $fa start add 0
+ $fa final add 2
+ set RE ^([grammar::fa::op::toTclRegexp [grammar::fa::op::toRegexp $fa] {}])\$
+ # Check the generated regex for correctness. Should match all ints 2 mod 3.
+ set res {}
+ for {set n 0} {$n<1000} {incr n} {
+ if {[regexp $RE $n] != ($n % 3 == 2)} {
+ lappend res $n
+ }
+ }
+ $fa destroy
+ set res
+} {}
+
+test faop-regex-${setimpl}-8.1 {to(Tcl)Regexp, match 1 mod 8, octal} {
+
+ set fa [grammar::fa octal_1_mod_3]
+ $fa state add 0 1 2
+ $fa symbol add 0 1 2 3 4 5 6 7
+ foreach state [$fa states] {
+ foreach digit [$fa symbols] {
+ $fa next $state $digit --> [expr {(8*$state + $digit) % 3}]
+ }
+ }
+ $fa start add 0
+ $fa final add 1
+ set RE ^([grammar::fa::op::toTclRegexp [grammar::fa::op::toRegexp $fa] {}])\$
+ set res {}
+ for {set n 0} {$n<4096} {incr n} {
+ if {[regexp $RE [format %o $n]] != ($n % 3 == 1)} {
+ lappend res $n
+ }
+ }
+ $fa destroy
+ set res
+} {}
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_remeps.test b/tcllib/modules/grammar_fa/tests/faop_remeps.test
new file mode 100644
index 0000000..4951fad
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_remeps.test
@@ -0,0 +1,158 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_remeps.test,v 1.5 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-remove-${setimpl}-eps-1.0 {remove-eps, error} {
+ catch {grammar::fa::op::remove_eps} res
+ set res
+} {wrong # args: should be "grammar::fa::op::remove_eps fa"}
+
+
+test faop-remove-${setimpl}-eps-1.1 {remove-eps, error} {
+ catch {grammar::fa::op::remove_eps a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::remove_eps fa"}
+
+
+test faop-remove-${setimpl}-eps-1.2 {remove-eps, error} {
+ catch {grammar::fa::op::remove_eps a} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code result} {
+ 00 x id
+ 01 x- id
+ 02 xe {grammar::fa {} {x {0 0 {}}}}
+ 03 xy id
+ 04 xy- id
+ 05 xye {grammar::fa {} {x {0 0 {}} y {0 0 {}}}}
+ 06 xyee {grammar::fa {} {x {0 0 {}} y {0 0 {}}}}
+ 07 xye- {grammar::fa @ {x {0 0 {@ {x y}}} y {0 0 {@ {x y}}}}}
+ 08 xy-- id
+ 09 xy-= id
+ 10 xyz/ee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {}}}}
+ 11 xyz/e- {grammar::fa @ {x {0 0 {@ y}} y {0 0 {}} z {0 0 {}}}}
+ 12 xyz/-- id
+ 13 xyz/-= id
+ 14 xyz|ee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {}}}}
+ 15 xyz|e- {grammar::fa @ {x {0 0 {@ z}} y {0 0 {}} z {0 0 {}}}}
+ 16 xyz|-- id
+ 17 xyz|-= id
+ 18 xyz+eee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {}}}}
+ 19 xyz+ee- {grammar::fa @ {x {0 0 {@ {x y z}}} y {0 0 {@ {x y z}}} z {0 0 {@ {x y z}}}}}
+ 20 xyz+e-- {grammar::fa @ {x {0 0 {@ z}} y {0 0 {@ z}} z {0 0 {@ {x y}}}}}
+ 21 xyz+e-= {grammar::fa {@ =} {x {0 0 {@ z}} y {0 0 {@ z}} z {0 0 {= {x y}}}}}
+ 22 xyz+--- id
+ 23 xyz+--= id
+ 24 xyz+-=_ id
+ 25 xyz&eee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {}}}}
+ 26 xyz&ee- {grammar::fa @ {x {0 0 {@ z}} y {0 0 {@ z}} z {0 0 {}}}}
+ 27 xyz&e-- {grammar::fa @ {x {0 0 {@ z}} y {0 0 {@ z}} z {0 0 {}}}}
+ 28 xyz&e-= {grammar::fa {@ =} {x {0 0 {= z @ z}} y {0 0 {= z}} z {0 0 {}}}}
+ 29 xyz&--- id
+ 30 xyz&--= id
+ 31 xyz&-=_ id
+ 32 xyz!ee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {}}}}
+ 33 xyz!e- {grammar::fa @ {x {0 0 {@ z}} y {0 0 {@ z}} z {0 0 {}}}}
+ 34 xyz!-- id
+ 35 xyz!-= id
+ 36 xyz!-e {grammar::fa @ {x {0 0 {@ {y z}}} y {0 0 {}} z {0 0 {}}}}
+} {
+ set key ${n}.${code}
+ if {$result eq "id"} {
+ grammar::fa a
+ gen $code
+ set result [a serialize]
+ a destroy
+ }
+
+ test faop-remove-${setimpl}-eps-2.$key {remove-eps} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::remove_eps a
+ set res [a is epsilon-free]
+ lappend res [validate_serial $result a]
+ a destroy
+ set res
+ } {1 ok}
+
+ test faop-remove-${setimpl}-eps-3.$key {second remove eps is null operation} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::remove_eps a
+ set res [a serialize]
+ grammar::fa::op::remove_eps a
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+
+ test faop-remove-${setimpl}-eps-4.$key {remove-eps, as method} {
+ grammar::fa a
+ gen $code
+ a remove_eps
+ set res [a is epsilon-free]
+ lappend res [validate_serial $result a]
+ a destroy
+ set res
+ } {1 ok}
+
+ test faop-remove-${setimpl}-eps-5.$key {second remove eps is null operation, as method} {
+ grammar::fa a
+ gen $code
+ a remove_eps
+ set res [a serialize]
+ a remove_eps
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+}
+
+
+foreach {n code st fin stnew finnew} {
+ 00 datom x y x y
+ 01 dalt u z {u v w} {x y z}
+ 02 dopt u x {u v x} {u w x}
+ 03 drep u x {u v x} {u w x}
+} {
+ test faop-remove-${setimpl}-eps-6.$n.$code {remove epsilon, start/final propagation} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ grammar::fa::op::remove_eps a
+
+ set res {}
+ lappend res [string equal $stnew [lsort [a startstates]]]
+ lappend res [string equal $finnew [lsort [a finalstates]]]
+ a destroy
+ set res
+ } {1 1}
+
+ test faop-remove-${setimpl}-eps-7.$n.$code {remove epsilon, start/final propagation, as method} {
+ grammar::fa a
+ gen $code
+ a start add $st
+ a final add $fin
+ a remove_eps
+
+ set res {}
+ lappend res [string equal $stnew [lsort [a startstates]]]
+ lappend res [string equal $finnew [lsort [a finalstates]]]
+ a destroy
+ set res
+ } {1 1}
+}
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_reverse.test b/tcllib/modules/grammar_fa/tests/faop_reverse.test
new file mode 100644
index 0000000..d997707
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_reverse.test
@@ -0,0 +1,95 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_reverse.test,v 1.5 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-reverse-${setimpl}-1.0 {reverse, error} {
+ catch {grammar::fa::op::reverse} res
+ set res
+} {wrong # args: should be "grammar::fa::op::reverse fa"}
+
+
+test faop-reverse-${setimpl}-1.1 {reverse, error} {
+ catch {grammar::fa::op::reverse a b} res
+ set res
+} {wrong # args: should be "grammar::fa::op::reverse fa"}
+
+
+test faop-reverse-${setimpl}-1.2 {reverse, error} {
+ catch {grammar::fa::op::reverse a} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n code result} {
+ 00 x {grammar::fa {} {x {0 0 {}}}}
+ 01 x- {grammar::fa @ {x {0 0 {@ x}}}}
+ 02 xe {grammar::fa {} {x {0 0 {{} x}}}}
+ 03 xy {grammar::fa {} {x {0 0 {}} y {0 0 {}}}}
+ 04 xy- {grammar::fa @ {x {0 0 {}} y {0 0 {@ x}}}}
+ 05 xye {grammar::fa {} {x {0 0 {}} y {0 0 {{} x}}}}
+ 06 xyee {grammar::fa {} {x {0 0 {{} y}} y {0 0 {{} x}}}}
+ 07 xyz/ee {grammar::fa {} {x {0 0 {}} y {0 0 {{} x}} z {0 0 {{} x}}}}
+ 08 xyz/-= {grammar::fa {@ =} {x {0 0 {}} y {0 0 {@ x}} z {0 0 {= x}}}}
+ 09 xyz|ee {grammar::fa {} {x {0 0 {}} y {0 0 {}} z {0 0 {{} {x y}}}}}
+ 10 xyz|-= {grammar::fa {@ =} {x {0 0 {}} y {0 0 {}} z {0 0 {@ x = y}}}}
+ 11 xyz+eee {grammar::fa {} {x {0 0 {{} z}} y {0 0 {{} x}} z {0 0 {{} y}}}}
+ 12 xyz+-=_ {grammar::fa {@ % =} {x {0 0 {% z}} y {0 0 {@ x}} z {0 0 {= y}}}}
+ 13 xyz&eee {grammar::fa {} {x {0 0 {}} y {0 0 {{} x}} z {0 0 {{} {x y}}}}}
+ 14 xyz&-=_ {grammar::fa {@ % =} {x {0 0 {}} y {0 0 {@ x}} z {0 0 {= x % y}}}}
+ 15 xyz!ee {grammar::fa {} {x {0 0 {}} y {0 0 {{} x}} z {0 0 {{} y}}}}
+ 16 xyz!-= {grammar::fa {@ % =} {x {0 0 {}} y {0 0 {@ x}} z {0 0 {= y}}}}
+} {
+ set key ${n}.${code}
+
+ test faop-reverse-${setimpl}-2.$key {reverse} {
+ grammar::fa a
+ gen $code
+ grammar::fa::op::reverse a
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+
+ test faop-reverse-${setimpl}-3.$key {double reverse is identity} {
+ grammar::fa a
+ gen $code
+ set res [a serialize]
+ grammar::fa::op::reverse a
+ grammar::fa::op::reverse a
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+
+ test faop-reverse-${setimpl}-4.$key {reverse, as method} {
+ grammar::fa a
+ gen $code
+ a reverse
+ set res [validate_serial $result a]
+ a destroy
+ set res
+ } ok
+
+ test faop-reverse-${setimpl}-5.$key {double reverse is identity, for method} {
+ grammar::fa a
+ gen $code
+ set res [a serialize]
+ a reverse
+ a reverse
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_trim.test b/tcllib/modules/grammar_fa/tests/faop_trim.test
new file mode 100644
index 0000000..7fd880b
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_trim.test
@@ -0,0 +1,209 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_trim.test,v 1.7 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+if {![::tcltest::testConstraint runtotal]} {
+ ::tcltest::cleanupTests
+ return
+}
+
+# -------------------------------------------------------------------------
+
+test faop-trim-${setimpl}-1.0 {trim, error} {
+ catch {grammar::fa::op::trim} res
+ set res
+} {wrong # args: should be "grammar::fa::op::trim fa ?what?"}
+
+
+test faop-trim-${setimpl}-1.1 {trim, error} {
+ catch {grammar::fa::op::trim a foo} res
+ set res
+} {Expected !reachable, !useful, !reachable&!useful, !(reachable|useful), !reachable|!useful, or !(reachable&useful), got "foo"}
+
+
+test faop-trim-${setimpl}-1.2 {trim, error} {
+ catch {grammar::fa::op::trim a} res
+ set res
+} {invalid command name "a"}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+if 0 {
+ 00 x
+ 01 x-
+ 02 xy
+ 03 xy-
+ 04 xy-=
+ 05 xyz/-=
+ 06 xyz|-=
+ 07 xyz+-=_
+ 08 xyz&-=_
+ 09 xyz!-=
+ 10 xyz!-e
+}
+
+foreach {n code} {
+ 00 x
+ 01 x-
+ 02 xe
+ 03 xy
+ 04 xy-
+ 05 xye
+ 06 xyee
+ 07 xye-
+ 08 xy--
+ 09 xy-=
+ 10 xyz/ee
+ 11 xyz/e-
+ 12 xyz/--
+ 13 xyz/-=
+ 14 xyz|ee
+ 15 xyz|e-
+ 16 xyz|--
+ 17 xyz|-=
+ 18 xyz+eee
+ 19 xyz+ee-
+ 20 xyz+e--
+ 21 xyz+e-=
+ 22 xyz+---
+ 23 xyz+--=
+ 24 xyz+-=_
+ 25 xyz&eee
+ 26 xyz&ee-
+ 27 xyz&e--
+ 28 xyz&e-=
+ 29 xyz&---
+ 30 xyz&--=
+ 31 xyz&-=_
+ 32 xyz!ee
+ 33 xyz!e-
+ 34 xyz!--
+ 35 xyz!-=
+ 36 xyz!-e
+} {
+ if {[string match xyz* $code]} {
+ set sets {{} x y z {x y} {x z} {y z} {x y z}}
+ set max 2
+ } elseif {[string match xy* $code]} {
+ set sets {{} x y {x y}}
+ set max 1
+ } elseif {[string match x* $code]} {
+ set sets {{} x}
+ set max 0
+ } else {
+ set sets {{}}
+ set max 4
+ }
+
+ # Pre-loop, generate the relevant combinations of input.
+
+ set states [string range $code 0 $max]
+ set combinations {}
+
+ foreach st $sets {
+ lappend combinations !reachable $st {}
+ lappend combinations !useful {} $st
+ }
+ foreach method {
+ !reachable&!useful !(reachable|useful)
+ !reachable|!useful !(reachable&useful)
+ } {
+ foreach st $sets {
+ foreach fin $sets {
+ lappend combinations $method $st $fin
+ }
+ }
+ }
+
+ foreach {method st fin} $combinations {
+ set key $n.$code.([join $st {}],[join $fin {}]).$method
+
+ test faop-trim-${setimpl}-2.$key {trim} {
+ grammar::fa a
+ gen $code
+ a start set $st
+ a final set $fin
+
+ switch -exact -- $method {
+ !reachable {set kept [a reachable_states]}
+ !useful {set kept [a useful_states]}
+ !reachable&!useful -
+ !(reachable|useful) {
+ set kept [struct::set union [a reachable_states] [a useful_states]]
+ }
+ !reachable|!useful -
+ !(reachable&useful) {
+ set kept [struct::set intersect [a reachable_states] [a useful_states]]
+ }
+ }
+ set kept [join [lsort $kept] {}]
+
+ grammar::fa::op::trim a $method
+ set res [expr {$kept eq [join [lsort [a states]] {}]}]
+ a destroy
+ set res
+ } 1 ; # {}
+
+ test faop-trim-${setimpl}-3.$key {second trim is null operation} {
+ grammar::fa a
+ gen $code
+ a start set $st
+ a final set $fin
+ grammar::fa::op::trim a $method
+ set res [a serialize]
+ grammar::fa::op::trim a $method
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok ; # {}
+
+
+ test faop-trim-${setimpl}-3.$key {trim, as method} {
+ grammar::fa a
+ gen $code
+ a start set $st
+ a final set $fin
+
+ switch -exact -- $method {
+ !reachable {set kept [a reachable_states]}
+ !useful {set kept [a useful_states]}
+ !reachable&!useful -
+ !(reachable|useful) {
+ set kept [struct::set union [a reachable_states] [a useful_states]]
+ }
+ !reachable|!useful -
+ !(reachable&useful) {
+ set kept [struct::set intersect [a reachable_states] [a useful_states]]
+ }
+ }
+ set kept [join [lsort $kept] {}]
+
+ a trim $method
+ set res [expr {$kept eq [join [lsort [a states]] {}]}]
+ a destroy
+ set res
+ } 1 ; # {}
+
+ test faop-trim-${setimpl}-4.$key {second trim is null operation, for method} {
+ grammar::fa a
+ gen $code
+ a start set $st
+ a final set $fin
+ a trim $method
+ set res [a serialize]
+ a trim $method
+ set res [validate_serial $res a]
+ a destroy
+ set res
+ } ok ; # {}
+ }
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests
diff --git a/tcllib/modules/grammar_fa/tests/faop_union.test b/tcllib/modules/grammar_fa/tests/faop_union.test
new file mode 100644
index 0000000..86b1c67
--- /dev/null
+++ b/tcllib/modules/grammar_fa/tests/faop_union.test
@@ -0,0 +1,113 @@
+# -*- tcl -*-
+# fa_operations.test: tests for the FA operations.
+#
+# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
+#
+# RCS: @(#) $Id: faop_union.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $
+
+# -------------------------------------------------------------------------
+
+test faop-union-${setimpl}-1.0 {union, error} {
+ catch {grammar::fa::op::union} res
+ set res
+} {wrong # args: should be "grammar::fa::op::union fa fb ?mapvar?"}
+
+
+test faop-union-${setimpl}-1.1 {union, error} {
+ catch {grammar::fa::op::union a b c d} res
+ set res
+} {wrong # args: should be "grammar::fa::op::union fa fb ?mapvar?"}
+
+
+test faop-union-${setimpl}-1.2 {union, error} {
+ catch {grammar::fa::op::union a b} res
+ set res
+} {invalid command name "a"}
+
+
+test faop-union-${setimpl}-1.3 {union, error} {
+ grammar::fa a
+ catch {grammar::fa::op::union a b} res
+ a destroy
+ set res
+} {invalid command name "b"}
+
+
+test faop-union-${setimpl}-1.4 {union, error} {
+ grammar::fa a
+ grammar::fa b
+ catch {grammar::fa::op::union a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to union FAs without start/final states}
+
+
+test faop-union-${setimpl}-1.5 {union, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a start add x
+ catch {grammar::fa::op::union a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to union FAs without start/final states}
+
+
+test faop-union-${setimpl}-1.6 {union, error} {
+ grammar::fa a
+ grammar::fa b
+ a state add x
+ a final add x
+ catch {grammar::fa::op::union a b} res
+ a destroy
+ b destroy
+ set res
+} {Unable to union FAs without start/final states}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+foreach {n fa fb fres rmap} {
+ 0
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+ {grammar::fa = {u {1 0 {= v}} v {0 1 {}}}}
+ {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} f.0}} u {0 0 {= v}} v {0 0 {{} f.0}} s.0 {1 0 {{} {x u}}} f.0 {0 1 {}}}}
+ {}
+
+ 1
+ {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
+ {grammar::fa = {x {1 0 {= y}} y {0 1 {}}}}
+ {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} f.0}} 0 {0 0 {= 1}} 1 {0 0 {{} f.0}} s.0 {1 0 {{} {x 0}}} f.0 {0 1 {}}}}
+ {0 x 1 y}
+} {
+ set key ${n}
+
+ test faop-union-${setimpl}-2.$key {union} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ grammar::fa::op::union a b map
+ set res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+
+ test faop-union-${setimpl}-3.$key {union, as method} {
+ grammar::fa a deserialize $fa
+ grammar::fa b deserialize $fb
+ a union b map
+ set res [validate_serial $fres a]
+ lappend res [string equal $rmap [dictsort $map]]
+ a destroy
+ b destroy
+ set res
+ } {ok 1}
+}
+
+
+# -------------------------------------------------------------------------
+::tcltest::cleanupTests