|
| 1 | +#!/usr/bin/env perl |
| 2 | +use Test2::V0; |
| 3 | + |
| 4 | +use FindBin qw<$Bin>; |
| 5 | +use lib "$Bin/../lib", "$Bin/../local/lib/perl5"; |
| 6 | + |
| 7 | +use TwoBucket qw<measure>; |
| 8 | + |
| 9 | +is( # begin: a6f2b4ba-065f-4dca-b6f0-e3eee51cb661 |
| 10 | + measure( 3, 5, 1, "one" ), |
| 11 | + { goalBucket => "one", moves => 4, otherBucket => 5 }, |
| 12 | + "Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one" |
| 13 | +); # end: a6f2b4ba-065f-4dca-b6f0-e3eee51cb661 |
| 14 | + |
| 15 | +is( # begin: 6c4ea451-9678-4926-b9b3-68364e066d40 |
| 16 | + measure( 3, 5, 1, "two" ), |
| 17 | + { goalBucket => "two", moves => 8, otherBucket => 3 }, |
| 18 | + "Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two" |
| 19 | +); # end: 6c4ea451-9678-4926-b9b3-68364e066d40 |
| 20 | + |
| 21 | +is( # begin: 3389f45e-6a56-46d5-9607-75aa930502ff |
| 22 | + measure( 7, 11, 2, "one" ), |
| 23 | + { goalBucket => "one", moves => 14, otherBucket => 11 }, |
| 24 | + "Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one" |
| 25 | +); # end: 3389f45e-6a56-46d5-9607-75aa930502ff |
| 26 | + |
| 27 | +is( # begin: fe0ff9a0-3ea5-4bf7-b17d-6d4243961aa1 |
| 28 | + measure( 7, 11, 2, "two" ), |
| 29 | + { goalBucket => "two", moves => 18, otherBucket => 7 }, |
| 30 | + "Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two" |
| 31 | +); # end: fe0ff9a0-3ea5-4bf7-b17d-6d4243961aa1 |
| 32 | + |
| 33 | +is( # begin: 0ee1f57e-da84-44f7-ac91-38b878691602 |
| 34 | + measure( 1, 3, 3, "two" ), |
| 35 | + { goalBucket => "two", moves => 1, otherBucket => 0 }, |
| 36 | + "Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two" |
| 37 | +); # end: 0ee1f57e-da84-44f7-ac91-38b878691602 |
| 38 | + |
| 39 | +is( # begin: eb329c63-5540-4735-b30b-97f7f4df0f84 |
| 40 | + measure( 2, 3, 3, "one" ), |
| 41 | + { goalBucket => "two", moves => 2, otherBucket => 2 }, |
| 42 | + "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two" |
| 43 | +); # end: eb329c63-5540-4735-b30b-97f7f4df0f84 |
| 44 | + |
| 45 | +like( # begin: 449be72d-b10a-4f4b-a959-ca741e333b72 |
| 46 | + dies { measure( 6, 15, 5, "one" ) }, |
| 47 | + qr/impossible/, |
| 48 | + "Not possible to reach the goal" |
| 49 | +); # end: 449be72d-b10a-4f4b-a959-ca741e333b72 |
| 50 | + |
| 51 | +is( # begin: aac38b7a-77f4-4d62-9b91-8846d533b054 |
| 52 | + measure( 6, 15, 9, "one" ), |
| 53 | + { goalBucket => "two", moves => 10, otherBucket => 0 }, |
| 54 | + "With the same buckets but a different goal, then it is possible" |
| 55 | +); # end: aac38b7a-77f4-4d62-9b91-8846d533b054 |
| 56 | + |
| 57 | +like( # begin: 74633132-0ccf-49de-8450-af4ab2e3b299 |
| 58 | + dies { measure( 5, 7, 8, "one" ) }, |
| 59 | + qr/impossible/, |
| 60 | + "Goal larger than both buckets is impossible" |
| 61 | +); # end: 74633132-0ccf-49de-8450-af4ab2e3b299 |
| 62 | + |
| 63 | +done_testing; |
0 commit comments