Exercism: Bash version of the 'Raindrops' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.2 KiB

3 years ago
  1. #!/usr/bin/env bash
  2. # local version: 1.1.0.0
  3. @test "the sound for 1 is 1" {
  4. #[[ $BATS_RUN_SKIPPED == "true" ]] || skip
  5. run bash raindrops.sh 1
  6. (( status == 0 ))
  7. [[ $output == "1" ]]
  8. }
  9. @test "the sound for 3 is Pling" {
  10. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  11. run bash raindrops.sh 3
  12. (( status == 0 ))
  13. [[ $output == "Pling" ]]
  14. }
  15. @test "the sound for 5 is Plang" {
  16. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  17. run bash raindrops.sh 5
  18. (( status == 0 ))
  19. [[ $output == "Plang" ]]
  20. }
  21. @test "the sound for 7 is Plong" {
  22. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  23. run bash raindrops.sh 7
  24. (( status == 0 ))
  25. [[ $output == "Plong" ]]
  26. }
  27. @test "the sound for 6 is Pling as it has a factor 3" {
  28. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  29. run bash raindrops.sh 6
  30. (( status == 0 ))
  31. [[ $output == "Pling" ]]
  32. }
  33. @test "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base" {
  34. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  35. run bash raindrops.sh 8
  36. (( status == 0 ))
  37. [[ $output == "8" ]]
  38. }
  39. @test "the sound for 9 is Pling as it has a factor 3" {
  40. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  41. run bash raindrops.sh 9
  42. (( status == 0 ))
  43. [[ $output == "Pling" ]]
  44. }
  45. @test "the sound for 10 is Plang as it has a factor 5" {
  46. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  47. run bash raindrops.sh 10
  48. (( status == 0 ))
  49. [[ $output == "Plang" ]]
  50. }
  51. @test "the sound for 14 is Plong as it has a factor of 7" {
  52. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  53. run bash raindrops.sh 14
  54. (( status == 0 ))
  55. [[ $output == "Plong" ]]
  56. }
  57. @test "the sound for 15 is PlingPlang as it has factors 3 and 5" {
  58. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  59. run bash raindrops.sh 15
  60. (( status == 0 ))
  61. [[ $output == "PlingPlang" ]]
  62. }
  63. @test "the sound for 21 is PlingPlong as it has factors 3 and 7" {
  64. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  65. run bash raindrops.sh 21
  66. (( status == 0 ))
  67. [[ $output == "PlingPlong" ]]
  68. }
  69. @test "the sound for 25 is Plang as it has a factor 5" {
  70. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  71. run bash raindrops.sh 25
  72. (( status == 0 ))
  73. [[ $output == "Plang" ]]
  74. }
  75. @test "the sound for 27 is Pling as it has a factor 3" {
  76. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  77. run bash raindrops.sh 27
  78. (( status == 0 ))
  79. [[ $output == "Pling" ]]
  80. }
  81. @test "the sound for 35 is PlangPlong as it has factors 5 and 7" {
  82. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  83. run bash raindrops.sh 35
  84. (( status == 0 ))
  85. [[ $output == "PlangPlong" ]]
  86. }
  87. @test "the sound for 49 is Plong as it has a factor 7" {
  88. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  89. run bash raindrops.sh 49
  90. (( status == 0 ))
  91. [[ $output == "Plong" ]]
  92. }
  93. @test "the sound for 52 is 52" {
  94. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  95. run bash raindrops.sh 52
  96. (( status == 0 ))
  97. [[ $output == "52" ]]
  98. }
  99. @test "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7" {
  100. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  101. run bash raindrops.sh 105
  102. (( status == 0 ))
  103. [[ $output == "PlingPlangPlong" ]]
  104. }
  105. @test "the sound for 3125 is Plang as it has a factor 5" {
  106. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  107. run bash raindrops.sh 3125
  108. (( status == 0 ))
  109. [[ $output == "Plang" ]]
  110. }