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