summary refs log tree commit diff stats
path: root/raku/raindrops/raindrops.rakutest
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-08-11 15:26:15 +0530
committerAndinus <andinus@nand.sh>2021-08-11 15:26:15 +0530
commit321825828ac918bad28d0597a8616c6dc9802c3c (patch)
tree0b8e9cb1012197750eb58e972736319b2a6abac2 /raku/raindrops/raindrops.rakutest
parent2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff)
downloadexercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz
Add solved exercises
Diffstat (limited to 'raku/raindrops/raindrops.rakutest')
-rw-r--r--raku/raindrops/raindrops.rakutest165
1 files changed, 165 insertions, 0 deletions
diff --git a/raku/raindrops/raindrops.rakutest b/raku/raindrops/raindrops.rakutest
new file mode 100644
index 0000000..a61cfd8
--- /dev/null
+++ b/raku/raindrops/raindrops.rakutest
@@ -0,0 +1,165 @@
+#!/usr/bin/env raku
+use Test;
+use JSON::Fast;
+use lib $?FILE.IO.dirname;
+use Raindrops;
+plan 18;
+
+my @test-cases = from-json($=pod.pop.contents).List;
+for @test-cases -> %case {
+  subtest %case<description>, {
+    plan 2;
+    isa-ok ( my $result := raindrop %case<input><number> ), Str;
+    is $result, %case<expected>, 'Result matches expected';
+  }
+}
+
+=head2 Test Cases
+=begin code
+[
+  {
+    "description": "the sound for 1 is 1",
+    "expected": "1",
+    "input": {
+      "number": 1
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 3 is Pling",
+    "expected": "Pling",
+    "input": {
+      "number": 3
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 5 is Plang",
+    "expected": "Plang",
+    "input": {
+      "number": 5
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 7 is Plong",
+    "expected": "Plong",
+    "input": {
+      "number": 7
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 6 is Pling as it has a factor 3",
+    "expected": "Pling",
+    "input": {
+      "number": 6
+    },
+    "property": "convert"
+  },
+  {
+    "description": "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base",
+    "expected": "8",
+    "input": {
+      "number": 8
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 9 is Pling as it has a factor 3",
+    "expected": "Pling",
+    "input": {
+      "number": 9
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 10 is Plang as it has a factor 5",
+    "expected": "Plang",
+    "input": {
+      "number": 10
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 14 is Plong as it has a factor of 7",
+    "expected": "Plong",
+    "input": {
+      "number": 14
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 15 is PlingPlang as it has factors 3 and 5",
+    "expected": "PlingPlang",
+    "input": {
+      "number": 15
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 21 is PlingPlong as it has factors 3 and 7",
+    "expected": "PlingPlong",
+    "input": {
+      "number": 21
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 25 is Plang as it has a factor 5",
+    "expected": "Plang",
+    "input": {
+      "number": 25
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 27 is Pling as it has a factor 3",
+    "expected": "Pling",
+    "input": {
+      "number": 27
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 35 is PlangPlong as it has factors 5 and 7",
+    "expected": "PlangPlong",
+    "input": {
+      "number": 35
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 49 is Plong as it has a factor 7",
+    "expected": "Plong",
+    "input": {
+      "number": 49
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 52 is 52",
+    "expected": "52",
+    "input": {
+      "number": 52
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7",
+    "expected": "PlingPlangPlong",
+    "input": {
+      "number": 105
+    },
+    "property": "convert"
+  },
+  {
+    "description": "the sound for 3125 is Plang as it has a factor 5",
+    "expected": "Plang",
+    "input": {
+      "number": 3125
+    },
+    "property": "convert"
+  }
+]
+=end code