summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/grammar_fa/tests/fa_symbols_at.test
diff options
context:
space:
mode:
Diffstat (limited to 'tcllib/modules/grammar_fa/tests/fa_symbols_at.test')
-rw-r--r--tcllib/modules/grammar_fa/tests/fa_symbols_at.test138
1 files changed, 138 insertions, 0 deletions
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