File: faop_minimize.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 (117 lines) | stat: -rw-r--r-- 3,407 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
114
115
116
117
# -*- tcl -*-
# fa_operations.test:  tests for the FA operations.
#
# Copyright (c) 2004-2007 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
#
# RCS: @(#) $Id: faop_minimize.test,v 1.4 2007/04/12 03:43:15 andreas_kupries Exp $

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

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


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


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


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


foreach {n code st fin mapres result} {
    00 datom x y {}
    {grammar::fa @ {x {1 0 {@ y}} y {0 1 {}}}}

    01 dalt  u z {0 {u v w} 1 {x y z}}
    {grammar::fa {@ =} {0 {1 0 {@ 1 = 1}} 1 {0 1 {}}}}

    02 dopt  u x {0 {u v w x} 1 {u w x}}
    {grammar::fa @ {0 {1 1 {@ 1}} 1 {0 1 {}}}}

    03 drep  u x {0 {u v w x}}
    {grammar::fa @ {0 {1 1 {@ 0}}}}
} {
    set key ${n}.${code}

    test faop-minimize-${setimpl}-2.$key {minimize, bounded} {
	grammar::fa a
	gen $code
	a start add $st
	a final add $fin
	grammar::fa::op::minimize a map
	set res [validate_serial $result a]
	lappend res [string equal $mapres [dictsort $map]]
	lappend res [a is deterministic]
	a destroy
	set res
    } {ok 1 1}

    test faop-minimize-${setimpl}-3.$key {minimize, bounded, as method} {
	grammar::fa a
	gen $code
	a start add $st
	a final add $fin
	a minimize map
	set res [validate_serial $result a]
	lappend res [string equal $mapres [dictsort $map]]
	lappend res [a is deterministic]
	a destroy
	set res
    } {ok 1 1}
}


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


foreach {n code mapres result} {
    00 datom {0 x 1 y}
    {grammar::fa @ {0 {0 0 {@ 1}} 1 {0 0 {}}}}

    01 dalt  {0 v 1 x 2 w 3 y 4 {u v} 5 u 6 {u w} 7 z 8 {x z} 9 {y z}}
    {grammar::fa {@ =} {0 {0 0 {}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {@ 8}} 5 {0 0 {}} 6 {0 0 {= 9}} 7 {0 0 {}} 8 {0 0 {}} 9 {0 0 {}}}}

    02 dopt  {0 {u v} 1 x 2 u 3 v 4 w 5 {w x}}
    {grammar::fa @ {0 {0 0 {@ 5}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {}} 5 {0 0 {}}}}

    03 drep  {0 {u v w x} 1 x 2 u 3 v 4 w 5 {u v w x}}
    {grammar::fa @ {0 {0 0 {@ 5}} 1 {0 0 {}} 2 {0 0 {}} 3 {0 0 {}} 4 {0 0 {}} 5 {0 0 {@ 5}}}}
} {
    set key ${n}.${code}

    test faop-minimize-${setimpl}-4.$key {minimize, unbounded} {
	grammar::fa a
	gen $code
	grammar::fa::op::minimize a map
	set res [validate_serial $result a]
	lappend res [string equal $mapres [dictsort $map]]
        lappend res [a is deterministic] ; # Never formally det, because of missing start.
	a destroy
	set res
    } {ok 1 0}

    test faop-minimize-${setimpl}-5.$key {minimize, unbounded, as method} {
	grammar::fa a
	gen $code
	a minimize map
	set res [validate_serial $result a]
	lappend res [string equal $mapres [dictsort $map]]
        lappend res [a is deterministic] ; # Never formally det, because of missing start.
	a destroy
	set res
    } {ok 1 0}
}


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