line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestML::Library::Standard; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
756
|
use TestML::Base; |
|
24
|
|
|
|
|
23
|
|
|
24
|
|
|
|
|
108
|
|
4
|
|
|
|
|
|
|
extends 'TestML::Library'; |
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
91
|
use TestML::Util; |
|
24
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
16756
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub Get { |
9
|
1
|
|
|
1
|
0
|
1
|
my ($self, $key) = @_; |
10
|
1
|
|
|
|
|
4
|
return $self->runtime->function->getvar($key->str->value); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# sub Set { |
14
|
|
|
|
|
|
|
# my ($self, $key, $value) = @_; |
15
|
|
|
|
|
|
|
# return $self->runtime->function->setvar($key, $value); |
16
|
|
|
|
|
|
|
# } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub GetLabel { |
19
|
3
|
|
|
3
|
0
|
3
|
my ($self) = @_; |
20
|
3
|
|
|
|
|
6
|
return str($self->runtime->get_label); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub Type { |
24
|
13
|
|
|
13
|
0
|
12
|
my ($self, $var) = @_; |
25
|
13
|
|
|
|
|
39
|
return str($var->type); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub Catch { |
29
|
7
|
|
|
7
|
0
|
8
|
my ($self) = @_; |
30
|
7
|
50
|
|
|
|
18
|
my $error = $self->runtime->error |
31
|
|
|
|
|
|
|
or die "Catch called but no TestML error found"; |
32
|
7
|
|
|
|
|
52
|
$error =~ s/ at .* line \d+\.\n\z//; |
33
|
7
|
|
|
|
|
12
|
$self->runtime->{error} = undef; |
34
|
7
|
|
|
|
|
13
|
return str($error); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub Throw { |
38
|
7
|
|
|
7
|
0
|
9
|
my ($self, $msg) = @_; |
39
|
7
|
|
|
|
|
18
|
die $msg->value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub Str { |
43
|
2
|
|
|
2
|
0
|
3
|
my ($self, $object) = @_; |
44
|
2
|
|
|
|
|
6
|
return str($object->str->value); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
# sub Num { |
47
|
|
|
|
|
|
|
# my ($self, $object) = @_; |
48
|
|
|
|
|
|
|
# return num($object->num->value); |
49
|
|
|
|
|
|
|
# } |
50
|
|
|
|
|
|
|
# sub Bool { |
51
|
|
|
|
|
|
|
# my ($self, $object) = @_; |
52
|
|
|
|
|
|
|
# return bool($object->bool->value); |
53
|
|
|
|
|
|
|
# } |
54
|
|
|
|
|
|
|
sub List { |
55
|
8
|
|
|
8
|
0
|
7
|
my $self = shift; |
56
|
8
|
|
|
|
|
24
|
return list([@_]); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub Join { |
60
|
10
|
|
|
10
|
0
|
11
|
my ($self, $list, $separator) = @_; |
61
|
10
|
100
|
|
|
|
20
|
$separator = $separator ? $separator->value : ''; |
62
|
10
|
|
|
|
|
11
|
my @strings = map $_->value, @{$list->list->value}; |
|
10
|
|
|
|
|
34
|
|
63
|
10
|
|
|
|
|
31
|
return str join $separator, @strings; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub Not { |
67
|
9
|
|
|
9
|
0
|
10
|
my ($self, $bool) = @_; |
68
|
9
|
100
|
|
|
|
21
|
return bool($bool->bool->value ? 0: 1); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub Text { |
72
|
16
|
|
|
16
|
0
|
14
|
my ($self, $lines) = @_; |
73
|
16
|
|
|
|
|
28
|
my $value = $lines->list->value; |
74
|
16
|
|
|
|
|
29
|
return str(join $/, map($_->value, @$value), ''); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub Count { |
78
|
2
|
|
|
2
|
0
|
4
|
my ($self, $list) = @_; |
79
|
2
|
|
|
|
|
4
|
return num scalar @{$list->list->value}; |
|
2
|
|
|
|
|
8
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub Lines { |
83
|
22
|
|
|
22
|
0
|
24
|
my ($self, $text) = @_; |
84
|
22
|
|
|
|
|
31
|
return list([ map str($_), split /\n/, $text->value ]); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub Reverse { |
88
|
4
|
|
|
4
|
0
|
6
|
my ($self, $list) = @_; |
89
|
4
|
|
|
|
|
9
|
my $value = $list->list->value; |
90
|
4
|
|
|
|
|
12
|
return list([ reverse @$value ]); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub Sort { |
94
|
8
|
|
|
8
|
0
|
11
|
my ($self, $list) = @_; |
95
|
8
|
|
|
|
|
10
|
my $value = $list->list->value; |
96
|
8
|
|
|
|
|
22
|
return list([ sort { $a->value cmp $b->value } @$value ]); |
|
20
|
|
|
|
|
30
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub Strip { |
100
|
9
|
|
|
9
|
0
|
10
|
my ($self, $string, $part) = @_; |
101
|
9
|
|
|
|
|
15
|
$string = $string->str->value; |
102
|
9
|
|
|
|
|
16
|
$part = $part->str->value; |
103
|
9
|
50
|
|
|
|
23
|
if ((my $i = index($string, $part)) >= 0) { |
104
|
9
|
|
|
|
|
16
|
$string = substr($string, 0, $i) . substr($string, $i + length($part)); |
105
|
|
|
|
|
|
|
} |
106
|
9
|
|
|
|
|
18
|
return str $string; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub Print { |
110
|
0
|
|
|
0
|
0
|
|
my ($self, $string) = @_; |
111
|
0
|
|
|
|
|
|
print STDOUT $string->value; |
112
|
0
|
|
|
|
|
|
return bool(1); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub Chomp { |
116
|
0
|
|
|
0
|
0
|
|
my ($self, $string) = @_; |
117
|
0
|
|
|
|
|
|
my $value = $string->str->value; |
118
|
0
|
|
|
|
|
|
chomp($value); |
119
|
0
|
|
|
|
|
|
return str $value; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# sub Has { |
125
|
|
|
|
|
|
|
# my ($self, $string, $part) = @_; |
126
|
|
|
|
|
|
|
# $string = $string->str->value; |
127
|
|
|
|
|
|
|
# $part = $part->str->value; |
128
|
|
|
|
|
|
|
# return bool(index($string, $part) >= 0); |
129
|
|
|
|
|
|
|
# } |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# sub RunCommand { |
132
|
|
|
|
|
|
|
# require Capture::Tiny; |
133
|
|
|
|
|
|
|
# my ($self, $command) = @_; |
134
|
|
|
|
|
|
|
# $command = $command->value; |
135
|
|
|
|
|
|
|
# chomp($command); |
136
|
|
|
|
|
|
|
# my $sub = sub { |
137
|
|
|
|
|
|
|
# system($command); |
138
|
|
|
|
|
|
|
# }; |
139
|
|
|
|
|
|
|
# my ($stdout, $stderr) = Capture::Tiny::capture($sub); |
140
|
|
|
|
|
|
|
# $self->runtime->function->setvar('_Stdout', $stdout); |
141
|
|
|
|
|
|
|
# $self->runtime->function->setvar('_Stderr', $stderr); |
142
|
|
|
|
|
|
|
# return str(''); |
143
|
|
|
|
|
|
|
# } |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# sub RmPath { |
146
|
|
|
|
|
|
|
# require File::Path; |
147
|
|
|
|
|
|
|
# my ($self, $path) = @_; |
148
|
|
|
|
|
|
|
# $path = $path->value; |
149
|
|
|
|
|
|
|
# File::Path::rmtree($path); |
150
|
|
|
|
|
|
|
# return str(''); |
151
|
|
|
|
|
|
|
# } |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# sub Stdout { |
154
|
|
|
|
|
|
|
# my ($self) = @_; |
155
|
|
|
|
|
|
|
# return $self->runtime->function->getvar('_Stdout'); |
156
|
|
|
|
|
|
|
# } |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# sub Stderr { |
159
|
|
|
|
|
|
|
# my ($self) = @_; |
160
|
|
|
|
|
|
|
# return $self->runtime->function->getvar('_Stderr'); |
161
|
|
|
|
|
|
|
# } |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# sub Chdir { |
164
|
|
|
|
|
|
|
# my ($self, $dir) = @_; |
165
|
|
|
|
|
|
|
# $dir = $dir->value; |
166
|
|
|
|
|
|
|
# chdir $dir; |
167
|
|
|
|
|
|
|
# return str(''); |
168
|
|
|
|
|
|
|
# } |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# sub Read { |
171
|
|
|
|
|
|
|
# my ($self, $file) = @_; |
172
|
|
|
|
|
|
|
# $file = $file->value; |
173
|
|
|
|
|
|
|
# use Cwd; |
174
|
|
|
|
|
|
|
# open FILE, $file or die "Can't open $file for input in " . Cwd::cwd; |
175
|
|
|
|
|
|
|
# my $text = do { local $/; }; |
176
|
|
|
|
|
|
|
# close FILE; |
177
|
|
|
|
|
|
|
# return str($text); |
178
|
|
|
|
|
|
|
# } |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# sub Pass { |
181
|
|
|
|
|
|
|
# my ($self, @args) = @_; |
182
|
|
|
|
|
|
|
# return @args; |
183
|
|
|
|
|
|
|
# } |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# sub Raw { |
186
|
|
|
|
|
|
|
# my $self = shift; |
187
|
|
|
|
|
|
|
# my $point = $self->point |
188
|
|
|
|
|
|
|
# or die "Raw called but there is no point"; |
189
|
|
|
|
|
|
|
# return $self->runtime->block->points->{$point}; |
190
|
|
|
|
|
|
|
# } |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# sub Point { |
193
|
|
|
|
|
|
|
# my ($self, $name) = @_; |
194
|
|
|
|
|
|
|
# $name = $name->value; |
195
|
|
|
|
|
|
|
# $self->runtime->get_point($name); |
196
|
|
|
|
|
|
|
# } |