summary refs log tree commit diff stats
path: root/raku/nucleotide-count/nucleotide-count.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/nucleotide-count/nucleotide-count.rakutest
parent2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff)
downloadexercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz
Add solved exercises
Diffstat (limited to 'raku/nucleotide-count/nucleotide-count.rakutest')
-rw-r--r--raku/nucleotide-count/nucleotide-count.rakutest95
1 files changed, 95 insertions, 0 deletions
diff --git a/raku/nucleotide-count/nucleotide-count.rakutest b/raku/nucleotide-count/nucleotide-count.rakutest
new file mode 100644
index 0000000..51e405a
--- /dev/null
+++ b/raku/nucleotide-count/nucleotide-count.rakutest
@@ -0,0 +1,95 @@
+#!/usr/bin/env raku
+use Test;
+use JSON::Fast;
+use lib $?FILE.IO.dirname;
+use NucleotideCount;
+plan 5;
+
+my @test-cases = from-json($=pod.pop.contents).List;
+for @test-cases -> %case {
+  given %case<expected> {
+    when .<error>.so {
+      throws-like
+        { nucleotide-count %case<input><strand> },
+        Exception,
+        message => /
+          $( %case<expected><error> )
+          || 'Constraint type check failed in binding to parameter'
+        /,
+        %case<description>;
+    }
+
+    default {
+      cmp-ok nucleotide-count(%case<input><strand>),
+        '~~', %case<expected>.Bag, %case<description>;
+    }
+  }
+}
+
+=head2 Test Cases
+=begin code
+[
+  {
+    "description": "count all nucleotides in a strand: empty strand",
+    "expected": {
+      "A": 0,
+      "C": 0,
+      "G": 0,
+      "T": 0
+    },
+    "input": {
+      "strand": ""
+    },
+    "property": "nucleotideCounts"
+  },
+  {
+    "description": "count all nucleotides in a strand: can count one nucleotide in single-character input",
+    "expected": {
+      "A": 0,
+      "C": 0,
+      "G": 1,
+      "T": 0
+    },
+    "input": {
+      "strand": "G"
+    },
+    "property": "nucleotideCounts"
+  },
+  {
+    "description": "count all nucleotides in a strand: strand with repeated nucleotide",
+    "expected": {
+      "A": 0,
+      "C": 0,
+      "G": 7,
+      "T": 0
+    },
+    "input": {
+      "strand": "GGGGGGG"
+    },
+    "property": "nucleotideCounts"
+  },
+  {
+    "description": "count all nucleotides in a strand: strand with multiple nucleotides",
+    "expected": {
+      "A": 20,
+      "C": 12,
+      "G": 17,
+      "T": 21
+    },
+    "input": {
+      "strand": "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"
+    },
+    "property": "nucleotideCounts"
+  },
+  {
+    "description": "count all nucleotides in a strand: strand with invalid nucleotides",
+    "expected": {
+      "error": "Invalid nucleotide in strand"
+    },
+    "input": {
+      "strand": "AGXXACT"
+    },
+    "property": "nucleotideCounts"
+  }
+]
+=end code