exercism

Exercism solutions.
git clone git://code.dwrz.net/exercism
Log | Files | Refs

bob-test.el (3463B)


      1 ;;; bob-test.el --- ERT tests for Bob (exercism)
      2 
      3 ;;; Commentary:
      4 ;; Common test data version: 1.2.0 6dc2014
      5 
      6 ;;; Code:
      7 
      8 (load-file "bob.el")
      9 
     10 (ert-deftest responds-to-stating-something ()
     11   (should (string= "Whatever." (response-for "Tom-ay-to, tom-aaaah-to."))))
     12 
     13 (ert-deftest responds-to-shouting ()
     14   (should
     15    (string= "Whoa, chill out!" (response-for "WATCH OUT!"))))
     16 
     17 (ert-deftest responds-to-shouting-gibberish ()
     18   (should
     19    (string= "Whoa, chill out!" (response-for "FCECDFCAAB"))))
     20 
     21 (ert-deftest responds-to-asking-a-question ()
     22   (should
     23    (string= "Sure." (response-for "Does this cryogenic chamber make me look fat?"))))
     24 
     25 (ert-deftest responds-to-asking-a-numeric-question ()
     26   (should
     27    (string= "Sure." (response-for "You are, what, like 15?"))))
     28 
     29 (ert-deftest responds-to-asking-gibberish ()
     30   (should
     31    (string= "Sure." (response-for "fffbbcbeab?"))))
     32 
     33 (ert-deftest responds-to-talking-forcefully ()
     34   (should
     35    (string= "Whatever." (response-for "Let's go make out behind the gym!"))))
     36 
     37 (ert-deftest responds-to-using-acronyms-in-regular-speech ()
     38   (should
     39    (string= "Whatever." (response-for "It's OK if you don't want to go to the DMV."))))
     40 
     41 (ert-deftest responds-to-forceful-question ()
     42   (should
     43    (string= "Calm down, I know what I'm doing!" (response-for "WHAT THE HELL WERE YOU THINKING?"))))
     44 
     45 (ert-deftest responds-to-shouting-numbers ()
     46   (should
     47    (string= "Whoa, chill out!" (response-for "1, 2, 3, GO!"))))
     48 
     49 (ert-deftest responds-to-only-numbers ()
     50   (should
     51    (string= "Whatever." (response-for "1, 2, 3"))))
     52 
     53 (ert-deftest responds-to-questions-with-only-numbers ()
     54   (should
     55    (string= "Sure." (response-for "4?"))))
     56 
     57 (ert-deftest responds-to-shouting-with-special-chars ()
     58   (should
     59    (string= "Whoa, chill out!" (response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))
     60 
     61 (ert-deftest responds-to-shouting-with-no-exclamation-mark ()
     62   (should
     63    (string= "Whoa, chill out!" (response-for "I HATE YOU"))))
     64 
     65 (ert-deftest responds-to-statement-containing-question-mark ()
     66   (should
     67    (string= "Whatever." (response-for "Ending with ? means a question."))))
     68 
     69 (ert-deftest responds-to-non-letters-with-question ()
     70   (should
     71    (string= "Sure." (response-for ":) ?"))))
     72 
     73 (ert-deftest responds-to-prattling-on ()
     74   (should
     75    (string= "Sure." (response-for "Wait! Hang on. Are you going to be OK?"))))
     76 
     77 (ert-deftest responds-to-silence ()
     78   (should
     79    (string= "Fine. Be that way!" (response-for ""))))
     80 
     81 (ert-deftest responds-to-prolonged-silence ()
     82   (should
     83    (string= "Fine. Be that way!" (response-for "    "))))
     84 
     85 (ert-deftest responds-to-alternate-silence ()
     86   (should
     87    (string= "Fine. Be that way!" (response-for "\t\t\t\t\t\t\t\t\t\t"))))
     88 
     89 (ert-deftest responds-to-multiple-line-question ()
     90   (should
     91    (string= "Whatever." (response-for "\nDoes this cryogenic chamber make me look fat?\nno"))))
     92 
     93 (ert-deftest responds-to-starting-with-whitespace ()
     94   (should
     95    (string= "Whatever." (response-for "         hmmmmmmm..."))))
     96 
     97 (ert-deftest responds-to-ending-with-whitespace ()
     98   (should
     99    (string= "Sure." (response-for "Okay if like my  spacebar  quite a bit?   "))))
    100 
    101 (ert-deftest responds-to-other-whitespace ()
    102   (should
    103    (string= "Fine. Be that way!" (response-for "\n\r \t"))))
    104 
    105 (ert-deftest responds-to-non-question-ending-with-whitespace ()
    106   (should
    107    (string= "Whatever." (response-for "This is a statement ending with whitespace      "))))
    108 
    109 (provide 'bob-test)
    110 ;;;bob-test.el ends here