|
| 1 | +;;; bottle-song-test.el --- Bottle Song (exercism) -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;;; Commentary: |
| 4 | + |
| 5 | +;;; Code: |
| 6 | + |
| 7 | + |
| 8 | +(load-file "bottle-song.el") |
| 9 | +(declare-function recite "bottle-song.el" (start-bottles take-down)) |
| 10 | + |
| 11 | + |
| 12 | +(ert-deftest first-generic-verse () |
| 13 | + (let ((expected '("Ten green bottles hanging on the wall," |
| 14 | + "Ten green bottles hanging on the wall," |
| 15 | + "And if one green bottle should accidentally fall," |
| 16 | + "There'll be nine green bottles hanging on the wall."))) |
| 17 | + (should (equal (recite 10 1) expected)))) |
| 18 | + |
| 19 | + |
| 20 | +(ert-deftest last-generic-verse () |
| 21 | + (let ((expected '("Three green bottles hanging on the wall," |
| 22 | + "Three green bottles hanging on the wall," |
| 23 | + "And if one green bottle should accidentally fall," |
| 24 | + "There'll be two green bottles hanging on the wall."))) |
| 25 | + (should (equal (recite 3 1) expected)))) |
| 26 | + |
| 27 | + |
| 28 | +(ert-deftest verse-with-2-bottles () |
| 29 | + (let ((expected '("Two green bottles hanging on the wall," |
| 30 | + "Two green bottles hanging on the wall," |
| 31 | + "And if one green bottle should accidentally fall," |
| 32 | + "There'll be one green bottle hanging on the wall."))) |
| 33 | + (should (equal (recite 2 1) expected)))) |
| 34 | + |
| 35 | + |
| 36 | +(ert-deftest verse-with-1-bottle () |
| 37 | + (let ((expected '("One green bottle hanging on the wall," |
| 38 | + "One green bottle hanging on the wall," |
| 39 | + "And if one green bottle should accidentally fall," |
| 40 | + "There'll be no green bottles hanging on the wall."))) |
| 41 | + (should (equal (recite 1 1) expected)))) |
| 42 | + |
| 43 | + |
| 44 | +(ert-deftest first-two-verses () |
| 45 | + (let ((expected '("Ten green bottles hanging on the wall," |
| 46 | + "Ten green bottles hanging on the wall," |
| 47 | + "And if one green bottle should accidentally fall," |
| 48 | + "There'll be nine green bottles hanging on the wall." |
| 49 | + "" |
| 50 | + "Nine green bottles hanging on the wall," |
| 51 | + "Nine green bottles hanging on the wall," |
| 52 | + "And if one green bottle should accidentally fall," |
| 53 | + "There'll be eight green bottles hanging on the wall."))) |
| 54 | + (should (equal (recite 10 2) expected)))) |
| 55 | + |
| 56 | + |
| 57 | +(ert-deftest last-three-verses () |
| 58 | + (let ((expected '("Three green bottles hanging on the wall," |
| 59 | + "Three green bottles hanging on the wall," |
| 60 | + "And if one green bottle should accidentally fall," |
| 61 | + "There'll be two green bottles hanging on the wall." |
| 62 | + "" |
| 63 | + "Two green bottles hanging on the wall," |
| 64 | + "Two green bottles hanging on the wall," |
| 65 | + "And if one green bottle should accidentally fall," |
| 66 | + "There'll be one green bottle hanging on the wall." |
| 67 | + "" |
| 68 | + "One green bottle hanging on the wall," |
| 69 | + "One green bottle hanging on the wall," |
| 70 | + "And if one green bottle should accidentally fall," |
| 71 | + "There'll be no green bottles hanging on the wall."))) |
| 72 | + (should (equal (recite 3 3) expected)))) |
| 73 | + |
| 74 | + |
| 75 | +(ert-deftest all-verses () |
| 76 | + (let ((expected '("Ten green bottles hanging on the wall," |
| 77 | + "Ten green bottles hanging on the wall," |
| 78 | + "And if one green bottle should accidentally fall," |
| 79 | + "There'll be nine green bottles hanging on the wall." |
| 80 | + "" |
| 81 | + "Nine green bottles hanging on the wall," |
| 82 | + "Nine green bottles hanging on the wall," |
| 83 | + "And if one green bottle should accidentally fall," |
| 84 | + "There'll be eight green bottles hanging on the wall." |
| 85 | + "" |
| 86 | + "Eight green bottles hanging on the wall," |
| 87 | + "Eight green bottles hanging on the wall," |
| 88 | + "And if one green bottle should accidentally fall," |
| 89 | + "There'll be seven green bottles hanging on the wall." |
| 90 | + "" |
| 91 | + "Seven green bottles hanging on the wall," |
| 92 | + "Seven green bottles hanging on the wall," |
| 93 | + "And if one green bottle should accidentally fall," |
| 94 | + "There'll be six green bottles hanging on the wall." |
| 95 | + "" |
| 96 | + "Six green bottles hanging on the wall," |
| 97 | + "Six green bottles hanging on the wall," |
| 98 | + "And if one green bottle should accidentally fall," |
| 99 | + "There'll be five green bottles hanging on the wall." |
| 100 | + "" |
| 101 | + "Five green bottles hanging on the wall," |
| 102 | + "Five green bottles hanging on the wall," |
| 103 | + "And if one green bottle should accidentally fall," |
| 104 | + "There'll be four green bottles hanging on the wall." |
| 105 | + "" |
| 106 | + "Four green bottles hanging on the wall," |
| 107 | + "Four green bottles hanging on the wall," |
| 108 | + "And if one green bottle should accidentally fall," |
| 109 | + "There'll be three green bottles hanging on the wall." |
| 110 | + "" |
| 111 | + "Three green bottles hanging on the wall," |
| 112 | + "Three green bottles hanging on the wall," |
| 113 | + "And if one green bottle should accidentally fall," |
| 114 | + "There'll be two green bottles hanging on the wall." |
| 115 | + "" |
| 116 | + "Two green bottles hanging on the wall," |
| 117 | + "Two green bottles hanging on the wall," |
| 118 | + "And if one green bottle should accidentally fall," |
| 119 | + "There'll be one green bottle hanging on the wall." |
| 120 | + "" |
| 121 | + "One green bottle hanging on the wall," |
| 122 | + "One green bottle hanging on the wall," |
| 123 | + "And if one green bottle should accidentally fall," |
| 124 | + "There'll be no green bottles hanging on the wall."))) |
| 125 | + (should (equal (recite 10 10) expected)))) |
| 126 | + |
| 127 | + |
| 128 | +(provide 'bottle-song-test) |
| 129 | +;;; bottle-song-test.el ends here |
0 commit comments