summary refs log tree commit diff stats
path: root/raku/two-fer/two-fer.rakutest
blob: f79c03e9810666a2083f53f03fdaec392c155bbf (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
#!/usr/bin/env raku
use Test;
use JSON::Fast;
use lib $?FILE.IO.dirname; #`[Look for the module inside the same directory as this test file.]
use TwoFer;
plan 3; #`[This is how many tests we expect to run.]

my @test-cases = from-json($=pod.pop.contents).List;
# Go through the cases and check that &two-fer gives us the correct response.
for @test-cases -> %case {
  is do {
    with %case<input><name> {
      .&two-fer;
    }
    else {
      two-fer;
    }
  }, |%case<expected description>;
}

=head2 Test Cases
=begin code
[
  {
    "description": "no name given",
    "expected": "One for you, one for me.",
    "input": {
      "name": null
    },
    "property": "twoFer"
  },
  {
    "description": "a name given",
    "expected": "One for Alice, one for me.",
    "input": {
      "name": "Alice"
    },
    "property": "twoFer"
  },
  {
    "description": "another name given",
    "expected": "One for Bob, one for me.",
    "input": {
      "name": "Bob"
    },
    "property": "twoFer"
  }
]
=end code