24 lines
15 KiB
Perl
24 lines
15 KiB
Perl
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use Test::More;
|
|
use DDG::Test::Goodie;
|
|
|
|
zci answer_type => "fen_viewer";
|
|
zci is_cached => 1;
|
|
|
|
ddg_goodie_test(
|
|
[qw( DDG::Goodie::FenViewer )],
|
|
'FEN rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' => test_zci("rnbqkbnr\npppppppp\n - - - -\n- - - - \n - - - -\n- - - - \nPPPPPPPP\nRNBQKBNR", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="black knight">♞</a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="black queen">♛</a></td><td id="E8"><a href="#" class="black king">♚</a></td><td id="F8"><a href="#" class="black bishop">♝</a></td><td id="G8"><a href="#" class="black knight">♞</a></td><td id="H8"><a href="#" class="black rook">♜</a></td></tr><tr><td id="A7"><a href="#" class="black pawn">♟</a></td><td id="B7"><a href="#" class="black pawn">♟</a></td><td id="C7"><a href="#" class="black pawn">♟</a></td><td id="D7"><a href="#" class="black pawn">♟</a></td><td id="E7"><a href="#" class="black pawn">♟</a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="empty"></a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="empty"></a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="empty"></a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="empty"></a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="empty"></a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="white pawn">♙</a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="white pawn">♙</a></td><td id="E2"><a href="#" class="white pawn">♙</a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A1"><a href="#" class="white rook">♖</a></td><td id="B1"><a href="#" class="white knight">♘</a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white king">♔</a></td><td id="F1"><a href="#" class="white bishop">♗</a></td><td id="G1"><a href="#" class="white knight">♘</a></td><td id="H1"><a href="#" class="white rook">♖</a></td></tr></table></div>'),
|
|
'fen rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1 ' => test_zci("rnbqkbnr\npppppppp\n - - - -\n- - - - \n - -P- -\n- - - - \nPPPP PPP\nRNBQKBNR", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="black knight">♞</a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="black queen">♛</a></td><td id="E8"><a href="#" class="black king">♚</a></td><td id="F8"><a href="#" class="black bishop">♝</a></td><td id="G8"><a href="#" class="black knight">♞</a></td><td id="H8"><a href="#" class="black rook">♜</a></td></tr><tr><td id="A7"><a href="#" class="black pawn">♟</a></td><td id="B7"><a href="#" class="black pawn">♟</a></td><td id="C7"><a href="#" class="black pawn">♟</a></td><td id="D7"><a href="#" class="black pawn">♟</a></td><td id="E7"><a href="#" class="black pawn">♟</a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="empty"></a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="empty"></a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="empty"></a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="white pawn">♙</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="empty"></a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="white pawn">♙</a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="white pawn">♙</a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A1"><a href="#" class="white rook">♖</a></td><td id="B1"><a href="#" class="white knight">♘</a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white king">♔</a></td><td id="F1"><a href="#" class="white bishop">♗</a></td><td id="G1"><a href="#" class="white knight">♘</a></td><td id="H1"><a href="#" class="white rook">♖</a></td></tr></table></div>'),
|
|
# Two examples from the last world championship
|
|
'fen r1b1r1k1/2qn1ppp/1ppp4/p3p3/P2PP3/R4N1P/1PP2PP1/2BQR1K1 b - - 0 14 ' => test_zci("r-b-r-k-\n- qn-ppp\n ppp - -\np - p - \nP- PP- -\nR - -N-P\n PP- PP-\n- BQR K ", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="empty"></a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="empty"></a></td><td id="E8"><a href="#" class="black rook">♜</a></td><td id="F8"><a href="#" class="empty"></a></td><td id="G8"><a href="#" class="black king">♚</a></td><td id="H8"><a href="#" class="empty"></a></td></tr><tr><td id="A7"><a href="#" class="empty"></a></td><td id="B7"><a href="#" class="empty"></a></td><td id="C7"><a href="#" class="black queen">♛</a></td><td id="D7"><a href="#" class="black knight">♞</a></td><td id="E7"><a href="#" class="empty"></a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="black pawn">♟</a></td><td id="C6"><a href="#" class="black pawn">♟</a></td><td id="D6"><a href="#" class="black pawn">♟</a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="black pawn">♟</a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="black pawn">♟</a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="white pawn">♙</a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="white pawn">♙</a></td><td id="E4"><a href="#" class="white pawn">♙</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="white rook">♖</a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="white knight">♘</a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A2"><a href="#" class="empty"></a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="empty"></a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="empty"></a></td></tr><tr><td id="A1"><a href="#" class="empty"></a></td><td id="B1"><a href="#" class="empty"></a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white rook">♖</a></td><td id="F1"><a href="#" class="empty"></a></td><td id="G1"><a href="#" class="white king">♔</a></td><td id="H1"><a href="#" class="empty"></a></td></tr></table></div>'),
|
|
'fen 5rk1/4R1p1/3q1p2/p1p2P1p/P3Q2P/5pP1/2P2P1K/8 w - - 0 35' => test_zci(" - - rk-\n- - R p \n - q p -\np p -P-p\nP- -Q- P\n- - -pP \n -P- P K\n- - - - ", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="empty"></a></td><td id="B8"><a href="#" class="empty"></a></td><td id="C8"><a href="#" class="empty"></a></td><td id="D8"><a href="#" class="empty"></a></td><td id="E8"><a href="#" class="empty"></a></td><td id="F8"><a href="#" class="black rook">♜</a></td><td id="G8"><a href="#" class="black king">♚</a></td><td id="H8"><a href="#" class="empty"></a></td></tr><tr><td id="A7"><a href="#" class="empty"></a></td><td id="B7"><a href="#" class="empty"></a></td><td id="C7"><a href="#" class="empty"></a></td><td id="D7"><a href="#" class="empty"></a></td><td id="E7"><a href="#" class="white rook">♖</a></td><td id="F7"><a href="#" class="empty"></a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="empty"></a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="black queen">♛</a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="black pawn">♟</a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="black pawn">♟</a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="black pawn">♟</a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="white pawn">♙</a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A4"><a href="#" class="white pawn">♙</a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="white queen">♕</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="black pawn">♟</a></td><td id="G3"><a href="#" class="white pawn">♙</a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="empty"></a></td><td id="B2"><a href="#" class="empty"></a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="empty"></a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="empty"></a></td><td id="H2"><a href="#" class="white king">♔</a></td></tr><tr><td id="A1"><a href="#" class="empty"></a></td><td id="B1"><a href="#" class="empty"></a></td><td id="C1"><a href="#" class="empty"></a></td><td id="D1"><a href="#" class="empty"></a></td><td id="E1"><a href="#" class="empty"></a></td><td id="F1"><a href="#" class="empty"></a></td><td id="G1"><a href="#" class="empty"></a></td><td id="H1"><a href="#" class="empty"></a></td></tr></table></div>'),
|
|
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' => undef,
|
|
'fen' => undef,
|
|
'fen ' => undef,
|
|
);
|
|
|
|
done_testing;
|