diff options
Diffstat (limited to 'raku/bob/bob.rakutest')
-rw-r--r-- | raku/bob/bob.rakutest | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/raku/bob/bob.rakutest b/raku/bob/bob.rakutest new file mode 100644 index 0000000..a540719 --- /dev/null +++ b/raku/bob/bob.rakutest @@ -0,0 +1,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 |