|
| 1 | +#!/usr/bin/env raku |
| 2 | +use Test; |
| 3 | +use lib $?FILE.IO.parent(2).add('lib'); |
| 4 | +use HighScores; |
| 5 | + |
| 6 | +cmp-ok( # begin: 1035eb93-2208-4c22-bab8-fef06769a73c |
| 7 | + HighScores.new( scores => [30, 50, 20, 70] ).scores, |
| 8 | + "eqv", |
| 9 | + [30, 50, 20, 70], |
| 10 | + "List of scores", |
| 11 | +); # end: 1035eb93-2208-4c22-bab8-fef06769a73c |
| 12 | + |
| 13 | +cmp-ok( # begin: 6aa5dbf5-78fa-4375-b22c-ffaa989732d2 |
| 14 | + HighScores.new( scores => [100, 0, 90, 30] ).latest, |
| 15 | + "==", |
| 16 | + 30, |
| 17 | + "Latest score", |
| 18 | +); # end: 6aa5dbf5-78fa-4375-b22c-ffaa989732d2 |
| 19 | + |
| 20 | +cmp-ok( # begin: b661a2e1-aebf-4f50-9139-0fb817dd12c6 |
| 21 | + HighScores.new( scores => [40, 100, 70] ).personal-best, |
| 22 | + "==", |
| 23 | + 100, |
| 24 | + "Personal best", |
| 25 | +); # end: b661a2e1-aebf-4f50-9139-0fb817dd12c6 |
| 26 | + |
| 27 | +cmp-ok( # begin: 3d996a97-c81c-4642-9afc-80b80dc14015 |
| 28 | + HighScores.new( scores => [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] ).personal-top-three, |
| 29 | + "==", |
| 30 | + 3, |
| 31 | + "Top 3 scores: Personal top three from a list of scores", |
| 32 | +); # end: 3d996a97-c81c-4642-9afc-80b80dc14015 |
| 33 | + |
| 34 | +cmp-ok( # begin: 1084ecb5-3eb4-46fe-a816-e40331a4e83a |
| 35 | + HighScores.new( scores => [20, 10, 30] ).personal-top-three, |
| 36 | + "==", |
| 37 | + 3, |
| 38 | + "Top 3 scores: Personal top highest to lowest", |
| 39 | +); # end: 1084ecb5-3eb4-46fe-a816-e40331a4e83a |
| 40 | + |
| 41 | +cmp-ok( # begin: e6465b6b-5a11-4936-bfe3-35241c4f4f16 |
| 42 | + HighScores.new( scores => [40, 20, 40, 30] ).personal-top-three, |
| 43 | + "==", |
| 44 | + 3, |
| 45 | + "Top 3 scores: Personal top when there is a tie", |
| 46 | +); # end: e6465b6b-5a11-4936-bfe3-35241c4f4f16 |
| 47 | + |
| 48 | +cmp-ok( # begin: f73b02af-c8fd-41c9-91b9-c86eaa86bce2 |
| 49 | + HighScores.new( scores => [30, 70] ).personal-top-three, |
| 50 | + "==", |
| 51 | + 2, |
| 52 | + "Top 3 scores: Personal top when there are less than 3", |
| 53 | +); # end: f73b02af-c8fd-41c9-91b9-c86eaa86bce2 |
| 54 | + |
| 55 | +cmp-ok( # begin: 16608eae-f60f-4a88-800e-aabce5df2865 |
| 56 | + HighScores.new( scores => [40] ).personal-top-three, |
| 57 | + "==", |
| 58 | + 1, |
| 59 | + "Top 3 scores: Personal top when there is only one", |
| 60 | +); # end: 16608eae-f60f-4a88-800e-aabce5df2865 |
| 61 | + |
| 62 | +cmp-ok( # begin: 2df075f9-fec9-4756-8f40-98c52a11504f |
| 63 | + ( given HighScores.new( scores => [70, 50, 20, 30] ) { sink .personal-top-three; .latest } ), |
| 64 | + "==", |
| 65 | + 30, |
| 66 | + "Top 3 scores: Latest score after personal top scores", |
| 67 | +); # end: 2df075f9-fec9-4756-8f40-98c52a11504f |
| 68 | + |
| 69 | +cmp-ok( # begin: 809c4058-7eb1-4206-b01e-79238b9b71bc |
| 70 | + ( given HighScores.new( scores => [30, 50, 20, 70] ) { sink .personal-top-three; .scores } ), |
| 71 | + "eqv", |
| 72 | + [30, 50, 20, 70], |
| 73 | + "Top 3 scores: Scores after personal top scores", |
| 74 | +); # end: 809c4058-7eb1-4206-b01e-79238b9b71bc |
| 75 | + |
| 76 | +cmp-ok( # begin: ddb0efc0-9a86-4f82-bc30-21ae0bdc6418 |
| 77 | + ( given HighScores.new( scores => [20, 70, 15, 25, 30] ) { sink .personal-best; .latest } ), |
| 78 | + "==", |
| 79 | + 30, |
| 80 | + "Top 3 scores: Latest score after personal best", |
| 81 | +); # end: ddb0efc0-9a86-4f82-bc30-21ae0bdc6418 |
| 82 | + |
| 83 | +cmp-ok( # begin: 6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364 |
| 84 | + ( given HighScores.new( scores => [20, 70, 15, 25, 30] ) { sink .personal-best; .scores } ), |
| 85 | + "eqv", |
| 86 | + [20, 70, 15, 25, 30], |
| 87 | + "Top 3 scores: Scores after personal best", |
| 88 | +); # end: 6a0fd2d1-4cc4-46b9-a5bb-2fb667ca2364 |
| 89 | + |
| 90 | +done-testing; |
0 commit comments