|
| 1 | +import measure from require 'two_bucket' |
| 2 | + |
| 3 | +describe 'two-bucket', -> |
| 4 | + it 'Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one', -> |
| 5 | + result = measure bucketOne: 3, bucketTwo: 5, goal: 1, startBucket: 'one' |
| 6 | + expected = moves: 4, goalBucket: 'one', otherBucket: 5 |
| 7 | + assert.are.same expected, result |
| 8 | + |
| 9 | + pending 'Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two', -> |
| 10 | + result = measure bucketOne: 3, bucketTwo: 5, goal: 1, startBucket: 'two' |
| 11 | + expected = moves: 8, goalBucket: 'two', otherBucket: 3 |
| 12 | + assert.are.same expected, result |
| 13 | + |
| 14 | + pending 'Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one', -> |
| 15 | + result = measure bucketOne: 7, bucketTwo: 11, goal: 2, startBucket: 'one' |
| 16 | + expected = moves: 14, goalBucket: 'one', otherBucket: 11 |
| 17 | + assert.are.same expected, result |
| 18 | + |
| 19 | + pending 'Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two', -> |
| 20 | + result = measure bucketOne: 7, bucketTwo: 11, goal: 2, startBucket: 'two' |
| 21 | + expected = moves: 18, goalBucket: 'two', otherBucket: 7 |
| 22 | + assert.are.same expected, result |
| 23 | + |
| 24 | + pending 'Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two', -> |
| 25 | + result = measure bucketOne: 1, bucketTwo: 3, goal: 3, startBucket: 'two' |
| 26 | + expected = moves: 1, goalBucket: 'two', otherBucket: 0 |
| 27 | + assert.are.same expected, result |
| 28 | + |
| 29 | + pending 'Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two', -> |
| 30 | + result = measure bucketOne: 2, bucketTwo: 3, goal: 3, startBucket: 'one' |
| 31 | + expected = moves: 2, goalBucket: 'two', otherBucket: 2 |
| 32 | + assert.are.same expected, result |
| 33 | + |
| 34 | + pending 'Measure using bucket one much bigger than bucket two', -> |
| 35 | + result = measure bucketOne: 5, bucketTwo: 1, goal: 2, startBucket: 'one' |
| 36 | + expected = moves: 6, goalBucket: 'one', otherBucket: 1 |
| 37 | + assert.are.same expected, result |
| 38 | + |
| 39 | + pending 'Measure using bucket one much smaller than bucket two', -> |
| 40 | + result = measure bucketOne: 3, bucketTwo: 15, goal: 9, startBucket: 'one' |
| 41 | + expected = moves: 6, goalBucket: 'two', otherBucket: 0 |
| 42 | + assert.are.same expected, result |
| 43 | + |
| 44 | + pending 'Not possible to reach the goal', -> |
| 45 | + assert.has.errors -> measure bucketOne: 6, bucketTwo: 15, goal: 5, startBucket: 'one' |
| 46 | + |
| 47 | + pending 'With the same buckets but a different goal, then it is possible', -> |
| 48 | + result = measure bucketOne: 6, bucketTwo: 15, goal: 9, startBucket: 'one' |
| 49 | + expected = moves: 10, goalBucket: 'two', otherBucket: 0 |
| 50 | + assert.are.same expected, result |
| 51 | + |
| 52 | + pending 'Goal larger than both buckets is impossible', -> |
| 53 | + assert.has.errors -> measure bucketOne: 5, bucketTwo: 7, goal: 8, startBucket: 'one' |
0 commit comments