kindergarten-garden.t (5410B) - raw
1 #!/usr/bin/env perl 2 use Test2::V0; 3 use JSON::PP; 4 use constant JSON => JSON::PP->new; 5 6 use FindBin qw<$Bin>; 7 use lib $Bin, "$Bin/local/lib/perl5"; 8 9 use KindergartenGarden qw<plants>; 10 11 my @test_cases = do { local $/; @{ JSON->decode(<DATA>) }; }; 12 13 imported_ok qw<plants> or bail_out; 14 15 for my $case (@test_cases) { 16 is( plants( $case->{input} ), 17 $case->{expected}, $case->{description}, ); 18 } 19 20 done_testing; 21 22 __DATA__ 23 [ 24 { 25 "description": "partial garden: garden with single student", 26 "expected": [ 27 "radishes", 28 "clover", 29 "grass", 30 "grass" 31 ], 32 "input": { 33 "diagram": "RC\nGG", 34 "student": "Alice" 35 }, 36 "property": "plants" 37 }, 38 { 39 "description": "partial garden: different garden with single student", 40 "expected": [ 41 "violets", 42 "clover", 43 "radishes", 44 "clover" 45 ], 46 "input": { 47 "diagram": "VC\nRC", 48 "student": "Alice" 49 }, 50 "property": "plants" 51 }, 52 { 53 "description": "partial garden: garden with two students", 54 "expected": [ 55 "clover", 56 "grass", 57 "radishes", 58 "clover" 59 ], 60 "input": { 61 "diagram": "VVCG\nVVRC", 62 "student": "Bob" 63 }, 64 "property": "plants" 65 }, 66 { 67 "description": "partial garden: multiple students for the same garden with three students: second student's garden", 68 "expected": [ 69 "clover", 70 "clover", 71 "clover", 72 "clover" 73 ], 74 "input": { 75 "diagram": "VVCCGG\nVVCCGG", 76 "student": "Bob" 77 }, 78 "property": "plants" 79 }, 80 { 81 "description": "partial garden: multiple students for the same garden with three students: third student's garden", 82 "expected": [ 83 "grass", 84 "grass", 85 "grass", 86 "grass" 87 ], 88 "input": { 89 "diagram": "VVCCGG\nVVCCGG", 90 "student": "Charlie" 91 }, 92 "property": "plants" 93 }, 94 { 95 "description": "full garden: for Alice, first student's garden", 96 "expected": [ 97 "violets", 98 "radishes", 99 "violets", 100 "radishes" 101 ], 102 "input": { 103 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 104 "student": "Alice" 105 }, 106 "property": "plants" 107 }, 108 { 109 "description": "full garden: for Bob, second student's garden", 110 "expected": [ 111 "clover", 112 "grass", 113 "clover", 114 "clover" 115 ], 116 "input": { 117 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 118 "student": "Bob" 119 }, 120 "property": "plants" 121 }, 122 { 123 "description": "full garden: for Charlie", 124 "expected": [ 125 "violets", 126 "violets", 127 "clover", 128 "grass" 129 ], 130 "input": { 131 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 132 "student": "Charlie" 133 }, 134 "property": "plants" 135 }, 136 { 137 "description": "full garden: for David", 138 "expected": [ 139 "radishes", 140 "violets", 141 "clover", 142 "radishes" 143 ], 144 "input": { 145 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 146 "student": "David" 147 }, 148 "property": "plants" 149 }, 150 { 151 "description": "full garden: for Eve", 152 "expected": [ 153 "clover", 154 "grass", 155 "radishes", 156 "grass" 157 ], 158 "input": { 159 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 160 "student": "Eve" 161 }, 162 "property": "plants" 163 }, 164 { 165 "description": "full garden: for Fred", 166 "expected": [ 167 "grass", 168 "clover", 169 "violets", 170 "clover" 171 ], 172 "input": { 173 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 174 "student": "Fred" 175 }, 176 "property": "plants" 177 }, 178 { 179 "description": "full garden: for Ginny", 180 "expected": [ 181 "clover", 182 "grass", 183 "grass", 184 "clover" 185 ], 186 "input": { 187 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 188 "student": "Ginny" 189 }, 190 "property": "plants" 191 }, 192 { 193 "description": "full garden: for Harriet", 194 "expected": [ 195 "violets", 196 "radishes", 197 "radishes", 198 "violets" 199 ], 200 "input": { 201 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 202 "student": "Harriet" 203 }, 204 "property": "plants" 205 }, 206 { 207 "description": "full garden: for Ileana", 208 "expected": [ 209 "grass", 210 "clover", 211 "violets", 212 "clover" 213 ], 214 "input": { 215 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 216 "student": "Ileana" 217 }, 218 "property": "plants" 219 }, 220 { 221 "description": "full garden: for Joseph", 222 "expected": [ 223 "violets", 224 "clover", 225 "violets", 226 "grass" 227 ], 228 "input": { 229 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 230 "student": "Joseph" 231 }, 232 "property": "plants" 233 }, 234 { 235 "description": "full garden: for Kincaid, second to last student's garden", 236 "expected": [ 237 "grass", 238 "clover", 239 "clover", 240 "grass" 241 ], 242 "input": { 243 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 244 "student": "Kincaid" 245 }, 246 "property": "plants" 247 }, 248 { 249 "description": "full garden: for Larry, last student's garden", 250 "expected": [ 251 "grass", 252 "violets", 253 "clover", 254 "violets" 255 ], 256 "input": { 257 "diagram": "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV", 258 "student": "Larry" 259 }, 260 "property": "plants" 261 } 262 ]