Skip to content

Commit bb681f9

Browse files
BethanyGcmccandless
authored andcommitted
Bob: sync expected test results and input data with problem-specifications (exercism#1784)
* Bob: sync expected test results and input data with problem-specifications.
1 parent ec506df commit bb681f9

3 files changed

Lines changed: 41 additions & 40 deletions

File tree

exercises/bob/bob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def hey(phrase):
1+
def response(hey_bob):
22
pass

exercises/bob/bob_test.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,101 @@
11
import unittest
22

3-
from bob import hey
3+
from bob import response
44

55

66
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.0
77

88
class BobTest(unittest.TestCase):
99
def test_stating_something(self):
10-
self.assertEqual(hey("Tom-ay-to, tom-aaaah-to."), "Whatever.")
10+
self.assertEqual(response("Tom-ay-to, tom-aaaah-to."), "Whatever.")
1111

1212
def test_shouting(self):
13-
self.assertEqual(hey("WATCH OUT!"), "Whoa, chill out!")
13+
self.assertEqual(response("WATCH OUT!"), "Whoa, chill out!")
1414

1515
def test_shouting_gibberish(self):
16-
self.assertEqual(hey("FCECDFCAAB"), "Whoa, chill out!")
16+
self.assertEqual(response("FCECDFCAAB"), "Whoa, chill out!")
1717

1818
def test_asking_a_question(self):
1919
self.assertEqual(
20-
hey("Does this cryogenic chamber make me look fat?"), "Sure.")
20+
response("Does this cryogenic chamber make me look fat?"), "Sure.")
2121

2222
def test_asking_a_numeric_question(self):
23-
self.assertEqual(hey("You are, what, like 15?"), "Sure.")
23+
self.assertEqual(response("You are, what, like 15?"), "Sure.")
2424

2525
def test_asking_gibberish(self):
26-
self.assertEqual(hey("fffbbcbeab?"), "Sure.")
26+
self.assertEqual(response("fffbbcbeab?"), "Sure.")
2727

2828
def test_talking_forcefully(self):
2929
self.assertEqual(
30-
hey("Let's go make out behind the gym!"), "Whatever.")
30+
response("Let's go make out behind the gym!"), "Whatever.")
3131

3232
def test_using_acronyms_in_regular_speech(self):
3333
self.assertEqual(
34-
hey("It's OK if you don't want to go to the DMV."),
34+
response("It's OK if you don't want to go to the DMV."),
3535
"Whatever.")
3636

3737
def test_forceful_question(self):
3838
self.assertEqual(
39-
hey("WHAT THE HELL WERE YOU THINKING?"),
39+
response("WHAT THE HELL WERE YOU THINKING?"),
4040
"Calm down, I know what I'm doing!"
4141
)
4242

4343
def test_shouting_numbers(self):
44-
self.assertEqual(hey("1, 2, 3 GO!"), "Whoa, chill out!")
44+
self.assertEqual(response("1, 2, 3 GO!"), "Whoa, chill out!")
4545

4646
def test_no_letters(self):
47-
self.assertEqual(hey("1, 2, 3"), "Whatever.")
47+
self.assertEqual(response("1, 2, 3"), "Whatever.")
4848

4949
def test_question_with_no_letters(self):
50-
self.assertEqual(hey("4?"), "Sure.")
50+
self.assertEqual(response("4?"), "Sure.")
5151

5252
def test_shouting_with_special_characters(self):
5353
self.assertEqual(
54-
hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"),
54+
response("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"),
5555
"Whoa, chill out!")
5656

5757
def test_shouting_with_no_exclamation_mark(self):
58-
self.assertEqual(hey("I HATE THE DMV"), "Whoa, chill out!")
58+
self.assertEqual(response("I HATE THE DMV"), "Whoa, chill out!")
5959

6060
def test_statement_containing_question_mark(self):
6161
self.assertEqual(
62-
hey("Ending with ? means a question."), "Whatever.")
62+
response("Ending with ? means a question."), "Whatever.")
6363

6464
def test_non_letters_with_question(self):
65-
self.assertEqual(hey(":) ?"), "Sure.")
65+
self.assertEqual(response(":) ?"), "Sure.")
6666

6767
def test_prattling_on(self):
6868
self.assertEqual(
69-
hey("Wait! Hang on. Are you going to be OK?"), "Sure.")
69+
response("Wait! Hang on. Are you going to be OK?"), "Sure.")
7070

7171
def test_silence(self):
72-
self.assertEqual(hey(""), "Fine. Be that way!")
72+
self.assertEqual(response(""), "Fine. Be that way!")
7373

7474
def test_prolonged_silence(self):
75-
self.assertEqual(hey(" "), "Fine. Be that way!")
75+
self.assertEqual(response(" "), "Fine. Be that way!")
7676

7777
def test_alternate_silence(self):
78-
self.assertEqual(hey("\t\t\t\t\t\t\t\t\t\t"), "Fine. Be that way!")
78+
self.assertEqual(response("\t\t\t\t\t\t\t\t\t\t"),
79+
"Fine. Be that way!")
7980

8081
def test_multiple_line_question(self):
8182
self.assertEqual(
82-
hey("\nDoes this cryogenic chamber make me look fat?\nNo."),
83-
"Whatever.")
83+
response("\nDoes this cryogenic chamber make me look fat?\n"
84+
"No."), "Whatever.")
8485

8586
def test_starting_with_whitespace(self):
86-
self.assertEqual(hey(" hmmmmmmm..."), "Whatever.")
87+
self.assertEqual(response(" hmmmmmmm..."), "Whatever.")
8788

8889
def test_ending_with_whitespace(self):
8990
self.assertEqual(
90-
hey("Okay if like my spacebar quite a bit? "), "Sure.")
91+
response("Okay if like my spacebar quite a bit? "), "Sure.")
9192

9293
def test_other_whitespace(self):
93-
self.assertEqual(hey("\n\r \t"), "Fine. Be that way!")
94+
self.assertEqual(response("\n\r \t"), "Fine. Be that way!")
9495

9596
def test_non_question_ending_with_whitespace(self):
9697
self.assertEqual(
97-
hey("This is a statement ending with whitespace "),
98+
response("This is a statement ending with whitespace "),
9899
"Whatever.")
99100

100101

exercises/bob/example.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
def hey(stimulus):
2-
stimulus = stimulus.strip()
1+
def response(hey_bob):
2+
hey_bob = hey_bob.strip()
33

4-
if _is_silence(stimulus):
4+
if _is_silence(hey_bob):
55
return 'Fine. Be that way!'
6-
if _is_shouting(stimulus):
7-
if _is_question(stimulus):
6+
if _is_shouting(hey_bob):
7+
if _is_question(hey_bob):
88
return "Calm down, I know what I'm doing!"
99
else:
1010
return 'Whoa, chill out!'
11-
elif _is_question(stimulus):
11+
elif _is_question(hey_bob):
1212
return 'Sure.'
1313
else:
1414
return 'Whatever.'
1515

1616

17-
def _is_silence(stimulus):
18-
return stimulus == ''
17+
def _is_silence(hey_bob):
18+
return hey_bob == ''
1919

2020

21-
def _is_shouting(stimulus):
22-
return stimulus.isupper()
21+
def _is_shouting(hey_bob):
22+
return hey_bob.isupper()
2323

2424

25-
def _is_question(stimulus):
26-
return stimulus.endswith('?')
25+
def _is_question(hey_bob):
26+
return hey_bob.endswith('?')

0 commit comments

Comments
 (0)