Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 204 lines (171 sloc) 6.238 kb
2013578 @masak [t] added new test file
authored
1 use v6;
819042b @masak added &count to Test::Ix and test file
authored
2 use Test::Ix;
8fe205e @masak added test and code to pass it
authored
3 use Druid::Game;
2013578 @masak [t] added new test file
authored
4
5 my @tests =
6 'the player to move' => [
7 'is vertical at the beginning of the game',
8 'is horizontal after the first move',
9 'alternates with every move',
10 ],
11 'a sarsen move' => [
12 'must have a certain syntax',
13 'must be within the limits of the board',
14 'can be made directly on the ground',
15 'can be made on top of the same color',
16 'can not be made on top of another color',
17 ],
18 'a lintel move' => [
19 'must have a certain syntax',
20 'must be within the limits of the board',
21 'can not be made directly on the ground',
22 'must be made two units apart',
23 'must have support at both ends',
24 'can not have less than two friendly stones under it',
25 'can not have more than two friendly stones under it',
26 'can form a bridge',
27 'can claim enemy territory',
28 ],
29 'swapping' => [
30 'changes the location of the piece on the board',
31 'makes the piece belong to horizontal instead',
a811452 @masak [01-game-rules.t] added some more stubbed tests
authored
32 'is allowed as the second move',
33 'is not allowed as the first move',
34 'is not allowed after the second move',
2013578 @masak [t] added new test file
authored
35 ],
36 'passing' => [
37 'does not change the board',
38 "makes it the other player's turn",
39 ],
40 'resigning' => [
41 'does not change the board',
42 'ends the game',
43 ],
44 'a chain' => [
45 "wins the game if it connects a player's edges",
46 "does not win the game if it connects the enemy's edges",
47 ]
48 ;
5f22c50 @masak added vim filetype line
authored
49
8aa498a @masak added run-tests
authored
50 plan count-tests(@tests);
51 run-tests(@tests);
819042b @masak added &count to Test::Ix and test file
authored
52
939ce2a @masak [t] made use of the new &before convention
authored
53 sub before {
8fe205e @masak added test and code to pass it
authored
54 my Druid::Game $game .= new(:size(3));
55 $game.init();
939ce2a @masak [t] made use of the new &before convention
authored
56 return $game;
57 }
58
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
59 sub the-player-to-move-is-vertical-at-the-beginning-of-the-game {
60 is $^game.player-to-move, 1,
8fe205e @masak added test and code to pass it
authored
61 "the player to move is vertical at the beginning of the game";
2b8ab6e @masak added the test stub subs
authored
62 }
63
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
64 sub the-player-to-move-is-horizontal-after-the-first-move {
65 $^game.make-move('a1');
900406c @masak implemented third test; satisfied immediately
authored
66 is $game.player-to-move, 2,
bd5d6aa @masak specified second test
authored
67 "the player to move is horizontal after the first move";
2b8ab6e @masak added the test stub subs
authored
68 }
69
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
70 sub the-player-to-move-alternates-with-every-move {
71 $^game; # must mention it outside of the gather
900406c @masak implemented third test; satisfied immediately
authored
72 my @move-order = gather for ^10 {
73 take 0+$game.player-to-move;
e2cbb4d @masak [Druid::Game] s/make_move/make-move/
authored
74 $game.make-move('a1');
900406c @masak implemented third test; satisfied immediately
authored
75 take 0+$game.player-to-move;
e2cbb4d @masak [Druid::Game] s/make_move/make-move/
authored
76 $game.make-move('b1');
6c3638e @masak implemented fourth test, passed right away
authored
77 };
900406c @masak implemented third test; satisfied immediately
authored
78 is @move-order, [(1, 2) xx 10],
79 "the player to move alternates with every move";
2b8ab6e @masak added the test stub subs
authored
80 }
81
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
82 sub a-sarsen-move-must-have-a-certain-syntax {
83 ok !defined $^game.make-move("1a"),
6c3638e @masak implemented fourth test, passed right away
authored
84 "a sarsen move must have a certain syntax";
2b8ab6e @masak added the test stub subs
authored
85 }
86
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
87 sub a-sarsen-move-must-be-within-the-limits-of-the-board {
88 ok !defined $^game.make-move("a5"),
304fbbe @masak implemented fifth test -- passed right away
authored
89 "a sarsen move must be within the limits of the board";
2b8ab6e @masak added the test stub subs
authored
90 }
91
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
92 sub a-sarsen-move-can-be-made-directly-on-the-ground {
93 ok defined $^game.make-move("b2"),
51e73c3 @masak implemented sixthtest -- passed right away
authored
94 "a sarsen move can be made directly on the ground";
2b8ab6e @masak added the test stub subs
authored
95 }
96
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
97 sub a-sarsen-move-can-be-made-on-top-of-the-same-color {
98 $^game.make-move($_) for <b2 a1>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
99 ok defined $game.make-move("b2"),
cca0299 @masak implemented seventh test; passed right away
authored
100 "a sarsen move can be made on top of the same color";
2b8ab6e @masak added the test stub subs
authored
101 }
102
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
103 sub a-sarsen-move-can-not-be-made-on-top-of-another-color {
104 $^game.make-move($_) for <b2 a1>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
105 ok !defined $game.make-move("a1"),
2d0467e @masak implemented eighth test; it fails
authored
106 "a sarsen move can not be made on top of another color";
2b8ab6e @masak added the test stub subs
authored
107 }
108
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
109 sub a-lintel-move-must-have-a-certain-syntax {
110 ok !defined $^game.make-move("a3-3c"),
8e50a9e @masak wrote ninth test -- passes right away
authored
111 "a lintel move must have a certain syntax";
2b8ab6e @masak added the test stub subs
authored
112 }
113
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
114 sub a-lintel-move-must-be-within-the-limits-of-the-board {
115 ok !defined $^game.make-move("a4-c4"),
fb0414c @masak implemented tenth test; passed right away
authored
116 "a lintel move must be within the limits of the board";
2b8ab6e @masak added the test stub subs
authored
117 }
118
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
119 sub a-lintel-move-can-not-be-made-directly-on-the-ground {
120 ok !defined $^game.make-move("a1-c1"),
f0790ff @masak implemented eleventh test
authored
121 "a lintel move can not be made directly on the ground";
2b8ab6e @masak added the test stub subs
authored
122 }
123
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
124 sub a-lintel-move-must-be-made-two-units-apart {
125 $^game.make-move($_) for <a1 a3 b1>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
126 ok !defined $game.make-move("a1-b1"),
1777a96 @masak added twelfth test; causes Druid::Game to die
authored
127 "a lintel move must be made two units apart";
2b8ab6e @masak added the test stub subs
authored
128 }
129
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
130 sub a-lintel-move-must-have-support-at-both-ends {
131 $^game.make-move($_) for <a1 a3>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
132 ok !defined $game.make-move("a1-c1"),
723ad33 @masak added thirteenth test -- passes right away
authored
133 "a lintel move must have support at both ends";
2b8ab6e @masak added the test stub subs
authored
134 }
135
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
136 sub a-lintel-move-can-not-have-less-than-two-friendly-stones-under-it {
137 $^game.make-move($_) for <a1 b1 a3 c1>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
138 ok !defined $game.make-move('a1-c1'),
fd5536d @masak implemented fourteenth test
authored
139 "a lintel move can not have less than two friendly stones under it";
2b8ab6e @masak added the test stub subs
authored
140 }
141
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
142 sub a-lintel-move-can-not-have-more-than-two-friendly-stones-under-it {
143 $^game.make-move($_) for <a1 a3 b1 b3 c1 c3>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
144 ok !defined $game.make-move('a1-c1'),
a18200c @masak added fifteenth test; passed right away
authored
145 "a lintel move can not have more than two friendly stones under it";
2b8ab6e @masak added the test stub subs
authored
146 }
147
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
148 sub a-lintel-move-can-form-a-bridge {
149 $^game.make-move($_) for <a2 a1 c2 c1>;
6c14d8b @masak replaced ~~ Failure with !defined
authored
150 ok defined $game.make-move('a2-c2'), "a lintel move can form a bridge";
2b8ab6e @masak added the test stub subs
authored
151 }
152
b3a1deb @masak replaced explicit param lists with placeholder vars
authored
153 sub a-lintel-move-can-claim-enemy-territory {
154 $^game.make-move($_) for <a1 a3 b1 c1>;
ddce1bf @masak wrote seventeenth test; passes right away
authored
155 ok defined $game.make-move('a1-c1'),
156 "a lintel move can claim enemy territory";
2b8ab6e @masak added the test stub subs
authored
157 }
158
159 sub swapping-changes-the-location-of-the-piece-on-the-board {
160 ok 0, "swapping changes the location of the piece on the board";
161 }
162
163 sub swapping-makes-the-piece-belong-to-horizontal-instead {
164 ok 0, "swapping makes the piece belong to horizontal instead";
165 }
166
a811452 @masak [01-game-rules.t] added some more stubbed tests
authored
167 sub swapping-is-allowed-as-the-second-move {
168 ok 0, "swapping is allowed as the second move";
169 }
170
171 sub swapping-is-not-allowed-as-the-first-move {
172 ok 0, "swapping is not allowed as the first move";
173 }
174
175 sub swapping-is-not-allowed-after-the-second-move {
176 ok 0, "swapping is not allowed after the second move";
177 }
178
2b8ab6e @masak added the test stub subs
authored
179 sub passing-does-not-change-the-board {
180 ok 0, "passing does not change the board";
181 }
182
183 sub passing-makes-it-the-other-player's-turn {
184 ok 0, "passing makes it the other player's turn";
185 }
186
187 sub resigning-does-not-change-the-board {
188 ok 0, "resigning does not change the board";
189 }
190
191 sub resigning-ends-the-game {
192 ok 0, "resigning ends the game";
193 }
194
195 sub a-chain-wins-the-game-if-it-connects-a-player's-edges {
196 ok 0, "a chain wins the game if it connects a player's edges";
197 }
198
199 sub a-chain-does-not-win-the-game-if-it-connects-the-enemy's-edges {
200 ok 0, "a chain does not win the game if it connects the enemy's edges";
201 }
202
5f22c50 @masak added vim filetype line
authored
203 # vim: filetype=perl6
Something went wrong with that request. Please try again.