Skip to content

Commit 56618ed

Browse files
authored
Sync bob tests (#422)
1 parent 4c64847 commit 56618ed

File tree

3 files changed

+76
-27
lines changed

3 files changed

+76
-27
lines changed

exercises/practice/bob/.meta/example.rkt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
(ormap (lambda (x) (char-alphabetic? x)) (string->list phrase))))
2121

2222
(define (question? phrase)
23-
(char=? #\?
24-
(string-ref phrase
25-
(- (string-length phrase) 1))))
23+
(let ([trimmed (string-trim phrase)])
24+
(and (not (string=? trimmed ""))
25+
(char=? #\? (string-ref trimmed (sub1 (string-length trimmed)))))))

exercises/practice/bob/.meta/tests.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ description = "alternate silence"
7171

7272
[66953780-165b-4e7e-8ce3-4bcb80b6385a]
7373
description = "multiple line question"
74+
include = false
7475

7576
[5371ef75-d9ea-4103-bcfa-2da973ddec1b]
7677
description = "starting with whitespace"
@@ -83,3 +84,7 @@ description = "other whitespace"
8384

8485
[12983553-8601-46a8-92fa-fcaa3bc4a2a0]
8586
description = "non-question ending with whitespace"
87+
88+
[2c7278ac-f955-4eb4-bf8f-e33eb4116a15]
89+
description = "multiple line question"
90+
reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a"

exercises/practice/bob/bob-test.rkt

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,104 @@
99
(test-suite
1010
"bob tests"
1111

12-
(test-equal? "responds to something"
12+
(test-equal? "stating something"
1313
(response-for "To-may-to, tom-aaaah-to.")
1414
"Whatever.")
1515

16-
(test-equal? "responds to shouts"
16+
(test-equal? "shouting"
1717
(response-for "WATCH OUT!")
1818
"Whoa, chill out!")
1919

20-
(test-equal? "responds to questions"
20+
(test-equal? "shouting gibberish"
21+
(response-for "FCECDFCAAB")
22+
"Whoa, chill out!")
23+
24+
(test-equal? "asking a question"
2125
(response-for "Does this cryogenic chamber make me look fat?")
2226
"Sure.")
2327

24-
(test-equal? "responds to forceful talking"
25-
(response-for "Let's go make out behind the gym!")
28+
(test-equal? "asking a numeric question"
29+
(response-for "You are, what, like 15?")
30+
"Sure.")
31+
32+
(test-equal? "asking gibberish"
33+
(response-for "fffbbcbeab?")
34+
"Sure.")
35+
36+
(test-equal? "talking forcefully"
37+
(response-for "Hi there!")
2638
"Whatever.")
2739

28-
(test-equal? "responds to acronyms"
29-
(response-for "It's OK if you don't want to go to the DMV.")
40+
(test-equal? "using acronyms in regular speech"
41+
(response-for "It's OK if you don't want to go work for NASA.")
3042
"Whatever.")
3143

32-
(test-equal? "responds to forceful questions"
33-
(response-for "WHAT THE HELL WERE YOU THINKING?")
44+
(test-equal? "forceful question"
45+
(response-for "WHAT'S GOING ON?")
3446
"Calm down, I know what I'm doing!")
3547

36-
(test-equal? "responds to shouting with special characters"
37-
(response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
48+
(test-equal? "shouting numbers"
49+
(response-for "1, 2, 3 GO!")
3850
"Whoa, chill out!")
3951

40-
(test-equal? "responds to shouting numbers"
41-
(response-for "1, 2 ,3, GO!")
52+
(test-equal? "no letters"
53+
(response-for "1, 2, 3")
54+
"Whatever.")
55+
56+
(test-equal? "question with no letters"
57+
(response-for "4?")
58+
"Sure.")
59+
60+
(test-equal? "shouting with special characters"
61+
(response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
4262
"Whoa, chill out!")
4363

44-
(test-equal? "responds to shouting with no exclamation mark"
45-
(response-for "I HATE YOU")
64+
(test-equal? "shouting with no exclamation mark"
65+
(response-for "I HATE THE DENTIST")
4666
"Whoa, chill out!")
4767

48-
(test-equal? "responds to statement containing question mark"
68+
(test-equal? "statement containing question mark"
4969
(response-for "Ending with ? means a question.")
5070
"Whatever.")
5171

52-
(test-equal? "responds to silence"
72+
(test-equal? "non-letters with question"
73+
(response-for ":) ?")
74+
"Sure.")
75+
76+
(test-equal? "prattling on"
77+
(response-for "Wait! Hang on. Are you going to be OK?")
78+
"Sure.")
79+
80+
(test-equal? "silence"
5381
(response-for "")
5482
"Fine. Be that way!")
5583

56-
(test-equal? "responds to prolonged-silence"
57-
(response-for " ")
84+
(test-equal? "prolonged silence"
85+
(response-for " ")
5886
"Fine. Be that way!")
5987

60-
(test-equal? "responds to only-numbers"
61-
(response-for "1, 2, 3")
88+
(test-equal? "alternate silence"
89+
(response-for "\t\t\t\t\t\t\t\t\t\t")
90+
"Fine. Be that way!")
91+
92+
(test-equal? "multiple line question"
93+
(response-for "\nDoes this cryogenic chamber make\n me look fat?")
94+
"Sure.")
95+
96+
(test-equal? "starting with whitespace"
97+
(response-for " hmmmmmmm...")
6298
"Whatever.")
6399

64-
(test-equal? "responds to number-question"
65-
(response-for "4?")
66-
"Sure.")))
100+
(test-equal? "ending with whitespace"
101+
(response-for "Okay if like my spacebar quite a bit? ")
102+
"Sure.")
103+
104+
(test-equal? "other whitespace"
105+
(response-for "\n\r \t")
106+
"Fine. Be that way!")
107+
108+
(test-equal? "non-question ending with whitespace"
109+
(response-for "This is a statement ending with whitespace ")
110+
"Whatever.")))
67111

68112
(run-tests suite))

0 commit comments

Comments
 (0)