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
|
#!/usr/bin/env raku
use Test;
use JSON::Fast;
use lib $?FILE.IO.dirname; #`[Look for the module inside the same directory as this test file.]
use Bob;
plan 26; #`[This is how many tests we expect to run.]
#`[Check that the class 'Bob' can use all of the methods
needed in the tests (only 'hey' for this one).]
subtest 'Class methods', {
for <hey> -> $method {
can-ok Bob, $method;
}
} or bail-out 'Cannot run expected method(s).';
my @test-cases = from-json($=pod.pop.contents).List;
# Go through the cases and check that Bob gives us the correct responses.
for @test-cases -> %case {
is Bob.hey(%case<input><heyBob>), |%case<expected description>;
}
=head2 Test Cases
=begin code
[
{
"description": "stating something",
"expected": "Whatever.",
"input": {
"heyBob": "Tom-ay-to, tom-aaaah-to."
},
"property": "response"
},
{
"description": "shouting",
"expected": "Whoa, chill out!",
"input": {
"heyBob": "WATCH OUT!"
},
"property": "response"
},
{
"description": "shouting gibberish",
"expected": "Whoa, chill out!",
"input": {
"heyBob": "FCECDFCAAB"
},
"property": "response"
},
{
"description": "asking a question",
"expected": "Sure.",
"input": {
"heyBob": "Does this cryogenic chamber make me look fat?"
},
"property": "response"
},
{
"description": "asking a numeric question",
"expected": "Sure.",
"input": {
"heyBob": "You are, what, like 15?"
},
"property": "response"
},
{
"description": "asking gibberish",
"expected": "Sure.",
"input": {
"heyBob": "fffbbcbeab?"
},
"property": "response"
},
{
"description": "talking forcefully",
"expected": "Whatever.",
"input": {
"heyBob": "Hi there!"
},
"property": "response"
},
{
"description": "using acronyms in regular speech",
"expected": "Whatever.",
"input": {
"heyBob": "It's OK if you don't want to go work for NASA."
},
"property": "response"
},
{
"description": "forceful question",
"expected": "Calm down, I know what I'm doing!",
"input": {
"heyBob": "WHAT'S GOING ON?"
},
"property": "response"
},
{
"description": "shouting numbers",
"expected": "Whoa, chill out!",
"input": {
"heyBob": "1, 2, 3 GO!"
},
"property": "response"
},
{
"description": "no letters",
"expected": "Whatever.",
"input": {
"heyBob": "1, 2, 3"
},
"property": "response"
},
{
"description": "question with no letters",
"expected": "Sure.",
"input": {
"heyBob": "4?"
},
"property": "response"
},
{
"description": "shouting with special characters",
"expected": "Whoa, chill out!",
"input": {
"heyBob": "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"
},
"property": "response"
},
{
"description": "shouting with no exclamation mark",
"expected": "Whoa, chill out!",
"input": {
"heyBob": "I HATE THE DENTIST"
},
"property": "response"
},
{
"description": "statement containing question mark",
"expected": "Whatever.",
"input": {
"heyBob": "Ending with ? means a question."
},
"property": "response"
},
{
"description": "non-letters with question",
"expected": "Sure.",
"input": {
"heyBob": ":) ?"
},
"property": "response"
},
{
"description": "prattling on",
"expected": "Sure.",
"input": {
"heyBob": "Wait! Hang on. Are you going to be OK?"
},
"property": "response"
},
{
"description": "silence",
"expected": "Fine. Be that way!",
"input": {
"heyBob": ""
},
"property": "response"
},
{
"description": "prolonged silence",
"expected": "Fine. Be that way!",
"input": {
"heyBob": " "
},
"property": "response"
},
{
"description": "alternate silence",
"expected": "Fine. Be that way!",
"input": {
"heyBob": "\t\t\t\t\t\t\t\t\t\t"
},
"property": "response"
},
{
"description": "multiple line question",
"expected": "Whatever.",
"input": {
"heyBob": "\nDoes this cryogenic chamber make me look fat?\nNo."
},
"property": "response"
},
{
"description": "starting with whitespace",
"expected": "Whatever.",
"input": {
"heyBob": " hmmmmmmm..."
},
"property": "response"
},
{
"description": "ending with whitespace",
"expected": "Sure.",
"input": {
"heyBob": "Okay if like my spacebar quite a bit? "
},
"property": "response"
},
{
"description": "other whitespace",
"expected": "Fine. Be that way!",
"input": {
"heyBob": "\n\r \t"
},
"property": "response"
},
{
"description": "non-question ending with whitespace",
"expected": "Whatever.",
"input": {
"heyBob": "This is a statement ending with whitespace "
},
"property": "response"
}
]
=end code
|