# -*- tcl -*- # fa_operations.test: tests for the FA operations. # # Copyright (c) 2004-2007 by Andreas Kupries # # 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