Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stewan Lheureux
Échecs féeriques
Commits
5e390757
Commit
5e390757
authored
Mar 30, 2020
by
Théo Winterhalter
Browse files
Corrige positionC3
Merci Guillaume Paquelet
parent
ee24d0d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/ts/pawn-move-validation.spec.ts
View file @
5e390757
...
...
@@ -19,7 +19,7 @@ const positionB3 : Position = position(1, 2) // B3
const
positionB5
:
Position
=
position
(
1
,
4
)
// B5
const
positionB6
:
Position
=
position
(
1
,
5
)
// B6
const
positionC3
:
Position
=
position
(
2
,
1
)
// C3
const
positionC3
:
Position
=
position
(
2
,
2
)
// C3
const
positionC4
:
Position
=
position
(
2
,
3
)
// C4
const
positionC5
:
Position
=
position
(
2
,
4
)
// C5
const
positionC6
:
Position
=
position
(
2
,
5
)
// C6
...
...
@@ -91,28 +91,28 @@ export class TestBlackPawnMoves {
testPawnCanMoveForward
()
{
putPiece
(
chessboard
,
positionA7
,
pieces
.
blackPawn
);
let
singleForward
:
Move
=
{
from
:
positionA7
,
to
:
positionA6
,
isValid
:
true
};
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
singleForward
)).
toBeTruthy
();
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
singleForward
)).
toBeTruthy
();
}
@
Test
(
"
Pawns cannot move backward
"
)
testPawnCannotMoveBackward
()
{
putPiece
(
chessboard
,
positionA7
,
pieces
.
blackPawn
);
let
singleForward
:
Move
=
{
from
:
positionA7
,
to
:
positionA8
,
isValid
:
true
};
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
singleForward
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
singleForward
)).
not
.
toBeTruthy
();
}
@
Test
(
"
When in the initial position, paws can move 2 squares forward
"
)
testPawnInitialMove
()
{
putPiece
(
chessboard
,
positionA7
,
pieces
.
blackPawn
);
let
doubleForward
:
Move
=
{
from
:
positionA7
,
to
:
positionA5
,
isValid
:
true
};
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
doubleForward
)).
toBeTruthy
();
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
doubleForward
)).
toBeTruthy
();
}
@
Test
(
"
When a paws has already moved, it cannot move 2 squares forward
"
)
testCannotMoveTwoSquaresIfAlreadyMoved
()
{
putPiece
(
chessboard
,
positionC6
,
pieces
.
blackPawn
);
let
doubleForward
:
Move
=
{
from
:
positionC6
,
to
:
positionC4
,
isValid
:
true
}
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
doubleForward
)).
not
.
toBeTruthy
();
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
doubleForward
)).
not
.
toBeTruthy
();
}
@
Test
(
"
When in the initial position, pawns cannot move 3 squares forward
"
)
...
...
@@ -130,7 +130,7 @@ export class TestBlackPawnMoves {
Expect
(
isPossible
.
blackPawnMove
(
chessboard
,
singleForward
)).
not
.
toBeTruthy
();
}
@
Test
(
"
Pawns cannot capture an empty square
"
)
@
Test
(
"
Pawns cannot capture an empty square
"
)
testPawnCannotCaptureEmptySquare
()
{
putPiece
(
chessboard
,
positionA7
,
pieces
.
blackPawn
);
let
diagonalCapture
:
Move
=
{
from
:
positionA7
,
to
:
positionB6
,
isValid
:
true
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment