/
tcl_glob.t
113 lines (82 loc) · 2.39 KB
/
tcl_glob.t
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
#!./parrot
# Copyright (C) 2008-2010, Parrot Foundation.
=head1 NAME
t/library/tcl_glob.t
=head1 DESCRIPTION
test tcl-style globs
=head1 SYNOPSIS
% prove t/library/tcl_glob.t
=cut
.sub 'main' :main
load_bytecode 'Test/More.pbc'
.local pmc exports, curr_namespace, test_namespace
curr_namespace = get_namespace
test_namespace = get_namespace ['Test';'More']
exports = split ' ', 'plan diag ok nok is isa_ok'
test_namespace.'export_to'(curr_namespace, exports)
# set our plan
plan(24)
# make sure we can load the library
push_eh load_failed
load_bytecode 'Tcl/Glob.pbc'
pop_eh
ok(1, 'load_bytecode')
is_glob( 'asdf', 'asdf', 'exact match +')
isnt_glob('asdf', 'asd', 'exact match -')
is_glob('asdf', '*', '* entire')
is_glob('asdf', 'a*', '* trailing +')
is_glob('asdf', '*f', '* leading +')
is_glob('asdf', 'a*f', '* mid +')
is_glob('asdf', '*asdf', 'null match')
isnt_glob('asdf', 'f*', '* trailing -')
isnt_glob('asdf', '*a', '* leading -')
isnt_glob('asdf', 'a*a', '* mid +-')
isnt_glob('asdf', 'f*f', '* mid -+')
isnt_glob('asdf', 'f*a', '* mid --')
is_glob('asdf', '????', '? all')
is_glob('asdf', 'as?f', '? single')
isnt_glob('asdf', 'asdf?', '? -')
is_glob('asdf', 'asd[asdf]', '[]')
is_glob('as_f', 'as[A-z]f', '[] ascii order +')
isnt_glob('as_f', 'as[a-z]f', '[] ascii order -')
is_glob('?', '\?', '\?')
is_glob('*', '\*', '\*')
is_glob('[', '\[', '\[')
is_glob(']', '\]', '\]')
is_glob('\\', '\\\\', '\\\\')
load_failed:
.end
.sub 'is_glob'
.param string original
.param string glob
.param string test_description
.local int boolean
boolean = do_glob(original,glob)
is(1, boolean, test_description)
.end
.sub 'isnt_glob'
.param string original
.param string glob
.param string test_description
.local int boolean
boolean = do_glob(original,glob)
is(0, boolean, test_description)
.end
.sub 'do_glob'
.param string original
.param string glob
.local pmc globber
globber = compreg 'Tcl::Glob'
.local pmc rule
rule = globber.'compile'(glob)
.local pmc result
result = rule(original)
.local int boolean
boolean = istrue result
.return(boolean)
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: