File: faop_concat.test

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (113 lines) | stat: -rw-r--r-- 3,058 bytes parent folder | download | duplicates (10)
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
108
109
110
111
112
113
# -*- tcl -*-
# fa_operations.test:  tests for the FA operations.
#
# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
#
# RCS: @(#) $Id: faop_concat.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $

# -------------------------------------------------------------------------

test faop-concat-${setimpl}-1.0 {concat, error} {
    catch {grammar::fa::op::concatenate} res
    set res
} {wrong # args: should be "grammar::fa::op::concatenate fa fb ?mapvar?"}


test faop-concat-${setimpl}-1.1 {concat, error} {
    catch {grammar::fa::op::concatenate a b c d} res
    set res
} {wrong # args: should be "grammar::fa::op::concatenate fa fb ?mapvar?"}


test faop-concat-${setimpl}-1.2 {concat, error} {
    catch {grammar::fa::op::concatenate a b} res
    set res
} {invalid command name "a"}


test faop-concat-${setimpl}-1.3 {concat, error} {
    grammar::fa a
    catch {grammar::fa::op::concatenate a b} res
    a destroy
    set res
} {invalid command name "b"}


test faop-concat-${setimpl}-1.4 {concat, error} {
    grammar::fa a
    grammar::fa b
    catch {grammar::fa::op::concatenate a b} res
    a destroy
    b destroy
    set res
} {Unable to concatenate FAs without start/final states}


test faop-concat-${setimpl}-1.5 {concat, error} {
    grammar::fa a
    grammar::fa b
    a state add x
    a start add x
    catch {grammar::fa::op::concatenate a b} res
    a destroy
    b destroy
    set res
} {Unable to concatenate FAs without start/final states}


test faop-concat-${setimpl}-1.6 {concat, error} {
    grammar::fa a
    grammar::fa b
    a state add x
    a final add x
    catch {grammar::fa::op::concatenate a b} res
    a destroy
    b destroy
    set res
} {Unable to concatenate FAs without start/final states}


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


foreach {n fa fb fres rmap} {
    0
    {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
    {grammar::fa = {u {1 0 {= v}} v {0 1 {}}}}
    {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} m.0}} u {0 0 {= v}} v {0 0 {{} f.0}} s.0 {1 0 {{} x}} f.0 {0 1 {}} m.0 {0 0 {{} u}}}}
    {}

    1
    {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}
    {grammar::fa = {x {1 0 {= y}} y {0 1 {}}}}
    {grammar::fa {= @} {x {0 0 {@ y}} y {0 0 {{} m.0}} 0 {0 0 {= 1}} 1 {0 0 {{} f.0}} s.0 {1 0 {{} x}} f.0 {0 1 {}} m.0 {0 0 {{} 0}}}}
    {0 x 1 y}
} {
    set key ${n}

    test faop-concat-${setimpl}-2.$key {concat} {
	grammar::fa a deserialize $fa
	grammar::fa b deserialize $fb
	grammar::fa::op::concatenate a b map
	set res [validate_serial $fres a]
	lappend res [string equal $rmap [dictsort $map]]
	a destroy
	b destroy
	set res
    } {ok 1}

    test faop-concat-${setimpl}-3.$key {concat, as method} {
	grammar::fa a deserialize $fa
	grammar::fa b deserialize $fb
	a concatenate b map
	set res [validate_serial $fres a]
	lappend res [string equal $rmap [dictsort $map]]
	a destroy
	b destroy
	set res
    } {ok 1}
}


# -------------------------------------------------------------------------
::tcltest::cleanupTests