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
|
# -*- 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
|