1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
# -*- 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
|