summary refs log tree commit diff stats
path: root/raku/acronym/acronym.rakutest
diff options
context:
space:
mode:
Diffstat (limited to 'raku/acronym/acronym.rakutest')
-rw-r--r--raku/acronym/acronym.rakutest89
1 files changed, 89 insertions, 0 deletions
diff --git a/raku/acronym/acronym.rakutest b/raku/acronym/acronym.rakutest
new file mode 100644
index 0000000..fad0fe4
--- /dev/null
+++ b/raku/acronym/acronym.rakutest
@@ -0,0 +1,89 @@
+#!/usr/bin/env raku
+use Test;
+use JSON::Fast;
+use lib $?FILE.IO.dirname;
+use Acronym;
+plan 9;
+
+my @test-cases = from-json($=pod[*-1].contents).List;
+for @test-cases -> %case {
+  is abbreviate(%case<input><phrase>), |%case<expected description>;
+}
+
+=head2 Test Cases
+=begin code
+[
+  {
+    "description": "basic",
+    "expected": "PNG",
+    "input": {
+      "phrase": "Portable Network Graphics"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "lowercase words",
+    "expected": "ROR",
+    "input": {
+      "phrase": "Ruby on Rails"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "punctuation",
+    "expected": "FIFO",
+    "input": {
+      "phrase": "First In, First Out"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "all caps word",
+    "expected": "GIMP",
+    "input": {
+      "phrase": "GNU Image Manipulation Program"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "punctuation without whitespace",
+    "expected": "CMOS",
+    "input": {
+      "phrase": "Complementary metal-oxide semiconductor"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "very long abbreviation",
+    "expected": "ROTFLSHTMDCOALM",
+    "input": {
+      "phrase": "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "consecutive delimiters",
+    "expected": "SIMUFTA",
+    "input": {
+      "phrase": "Something - I made up from thin air"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "apostrophes",
+    "expected": "HC",
+    "input": {
+      "phrase": "Halley's Comet"
+    },
+    "property": "abbreviate"
+  },
+  {
+    "description": "underscore emphasis",
+    "expected": "TRNT",
+    "input": {
+      "phrase": "The Road _Not_ Taken"
+    },
+    "property": "abbreviate"
+  }
+]
+=end code