summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/pt/tests/char.tests
blob: 594aae1da0917af4843178a309508b2d73d4cf43 (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# -*- tcl -*-
# Testsuite for char.
# Called by the ../char.test driver file.

test char-1.0.0 {char, wrong#args} -constraints tcl8.5minus -body {
    char
} -returnCodes error \
    -result {wrong # args: should be "char subcommand ?argument ...?"}

test char-1.0.1 {char, wrong#args} -constraints tcl8.6plus -body {
    char
} -returnCodes error \
    -result {wrong # args: should be "char subcommand ?arg ...?"}

test char-1.1 {char, bogus method} -body {
    char bogus
} -returnCodes error \
    -result {unknown or ambiguous subcommand "bogus": must be quote, or unquote}

test char-1.2.0 {char, wrong#args} -constraints tcl8.5minus -body {
    char quote
} -returnCodes error \
    -result {wrong # args: should be "char quote subcommand ?argument ...?"}

test char-1.2.1 {char, wrong#args} -constraints tcl8.6plus -body {
    char quote
} -returnCodes error \
    -result {wrong # args: should be "char quote subcommand ?arg ...?"}

test char-1.3 {char, bogus method} -body {
    char quote bogus
} -returnCodes error \
    -result {unknown or ambiguous subcommand "bogus": must be comment, cstring, string, or tcl}

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

test char-2.0.0 {char tcl, wrong#args} -constraints tcl8.5minus -body {
    char quote tcl
} -returnCodes error -result {wrong # args: should be "char quote tcl ch ..."}

test char-2.0.1 {char tcl, wrong#args} -constraints tcl8.6plus -body {
    char quote tcl
} -returnCodes error -result {wrong # args: should be "char quote tcl ch ?arg ...?"}

test char-2.1 {char tcl, single char} -body {
    char quote tcl A
} -result A

test char-2.2 {char tcl, multi char} -body {
    char quote tcl A B
} -result {A B}

foreach {n label input expected} {
    0 obrace    \{     \\173
    1 obrckt    \[     \\133
    2 dquote    \"     \\42
    3 escape    \033   \\33
    4 lf        \n     \\n
    5 space     { }    \\40
    6 backslash \\     \\134
    7 A         A      A
    8 del       \177   \\177
    9 circast   \u229b \\u229b
} {
    test char-2.3.$n "char tcl, map $label" -body {
	char quote tcl $input
    } -result $expected

    # collect table columns for string and multi-arg tests.
    lappend ll $label
    lappend li $input
    lappend le $expected
}

test char-2.4 "char tcl, map string" -body {
    char quote tcl [join $li {}]
} -result [join $le {}]

test char-2.5 "char tcl, map multiple" -body {
    char quote tcl {*}$li
} -result $le

unset -nocomplain n label input expected ll li le

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

test char-3.0.0 {char string, wrong#args} -constraints tcl8.5minus -body {
    char quote string
} -returnCodes error -result {wrong # args: should be "char quote string ch ..."}

test char-3.0.1 {char string, wrong#args} -constraints tcl8.6plus -body {
    char quote string
} -returnCodes error -result {wrong # args: should be "char quote string ch ?arg ...?"}

test char-3.1 {char string, single char} -body {
    char quote string A
} -result A

test char-3.2 {char string, multi char} -body {
    char quote string A B
} -result {A B}

foreach {n label input expected} {
    0 obrace    \{     \{
    1 obrckt    \[     \[
    2 dquote    \"     \"
    3 escape    \033   <ESC>
    4 lf        \n     <LF>
    5 space     { }    <SPACE>
    6 backslash \\     \\
    7 A         A      A
    8 del       \177   <DEL>
    9 circast   \u229b \u229b
} {
    test char-3.3.$n "char string, map $label" -body {
	char quote string $input
    } -result $expected

    # collect table columns for string and multi-arg tests.
    lappend ll $label
    lappend li $input
    lappend le $expected
}

test char-3.4 "char string, map string" -body {
    char quote string [join $li {}]
} -result [join $le {}]

test char-3.5 "char string, map multiple" -body {
    char quote string {*}$li
} -result $le

unset -nocomplain n label input expected ll li le

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

test char-4.0.0 {char cstring, wrong#args} -constraints tcl8.5minus -body {
    char quote cstring
} -returnCodes error -result {wrong # args: should be "char quote cstring ch ..."}

test char-4.0.1 {char cstring, wrong#args} -constraints tcl8.6plus -body {
    char quote cstring
} -returnCodes error -result {wrong # args: should be "char quote cstring ch ?arg ...?"}

test char-4.1 {char cstring, single char} -body {
    char quote cstring A
} -result A

test char-4.2 {char cstring, multi char} -body {
    char quote cstring A B
} -result {A B}

foreach {n label input expected} {
    0 obrace    \{     \\173
    1 obrckt    \[     \[
    2 dquote    \"     \\\"
    3 escape    \033   \\33
    4 lf        \n     \\n
    5 space     { }    { }
    6 backslash \\     \\\\
    7 A         A      A
    8 del       \177   \\177
    9 circast   \u229b \\342\\212\\233
} {
    test char-4.3.$n "char cstring, map $label" -body {
	char quote cstring $input
    } -result $expected

    # collect table columns for string and multi-arg tests.
    lappend ll $label
    lappend li $input
    lappend le $expected
}

test char-4.4 "char cstring, map string" -body {
    char quote cstring [join $li {}]
} -result [join $le {}]

test char-4.5 "char cstring, map multiple" -body {
    char quote cstring {*}$li
} -result $le

unset -nocomplain n label input expected ll li le

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

test char-5.0.0 {char comment, wrong#args} -constraints tcl8.5minus -body {
    char quote comment
} -returnCodes error -result {wrong # args: should be "char quote comment ch ..."}

test char-5.0.1 {char comment, wrong#args} -constraints tcl8.6plus -body {
    char quote comment
} -returnCodes error -result {wrong # args: should be "char quote comment ch ?arg ...?"}

test char-5.1 {char comment, single char} -body {
    char quote comment A
} -result A

test char-5.2 {char comment, multi char} -body {
    char quote comment A B
} -result {A B}

foreach {n label input expected} {
    0 obrace    \{     \\\{
    1 obrckt    \[     \[
    2 dquote    \"     \\\"
    3 escape    \033   \\33
    4 lf        \n     \\n
    5 space     { }    <blank>
    6 backslash \\     \\
    7 A         A      A
    8 del       \177   \\177
    9 circast   \u229b \\u229b
} {
    test char-5.3.$n "char comment, map $label" -body {
	char quote comment $input
    } -result $expected

    # collect table columns for string and multi-arg tests.
    lappend ll $label
    lappend li $input
    lappend le $expected
}

test char-5.4 "char comment, map string" -body {
    char quote comment [join $li {}]
} -result [join $le {}]

test char-5.5 "char comment, map multiple" -body {
    char quote comment {*}$li
} -result $le

unset -nocomplain n label input expected ll li le

#----------------------------------------------------------------------
return