summary refs log tree commit diff stats
path: root/raku/acronym/acronym.rakutest
blob: fad0fe43c1c7d6326f62ea4722e15ff83f962876 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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