#This file is part of SECONDO. # #Copyright (C) 2004, University in Hagen, Department of Computer Science, #Database Systems for New Applications. # #SECONDO is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2 of the License, or #(at your option) any later version. # #SECONDO is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with SECONDO; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # a test for the chess algebra # run with : TestRunner -i chess.test # clean up what may be left over from e.g. a segfault #setup create database chesstest; open database chesstest; let gamestype = [const rel(tuple([x: int])) value ((1))]; derive games = gamestype feed extendstream [Match: readpgn('test.pgn')] project[Match] consume; derive games2 = gamestype feed extendstream [Match: readpgn('test2.pgn')] project[Match] consume; ####################################################################### # tests for getposition operator ####################################################################### #testcase test_getposition_neg #yields ((rel (tuple ((Result position))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getposition[ -1 ]] project[Result] consume; #testcase test_getposition_80 #yields ((rel (tuple ((Result position))))\ ((undef)\ ((80 (\ ("-" "-" "-" "-" "r" "-" "-" "-")\ ("-" "b" "q" "-" "r" "-" "k" "p")\ ("-" "-" "-" "-" "p" "-" "p" "-")\ ("-" "p" "P" "-" "R" "p" "P" "-")\ ("p" "P" "-" "-" "-" "-" "-" "-")\ ("P" "-" "-" "-" "Q" "-" "-" "B")\ ("-" "-" "-" "-" "-" "P" "-" "P")\ ("-" "-" "-" "-" "R" "-" "K" "-"))))\ ((80 (\ ("-" "-" "-" "-" "r" "-" "k" "-")\ ("-" "-" "-" "-" "-" "p" "-" "n")\ ("R" "-" "p" "-" "-" "-" "p" "-")\ ("-" "-" "-" "p" "-" "b" "-" "p")\ ("-" "-" "p" "P" "-" "-" "-" "-")\ ("-" "-" "-" "-" "P" "P" "q" "P")\ ("-" "-" "-" "Q" "-" "N" "P" "-")\ ("-" "-" "-" "-" "R" "-" "K" "-"))))\ (undef))) query games feed extend[Result: .Match getposition[ 80 ]] project[Result] consume; #testcase test_getposition_200 #yields ((rel (tuple ((Result position))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getposition[ 200 ]] project[Result] consume; #testcase test_getposition_0 #yields \ (\ (rel\ (tuple\ (\ (Result position))))\ (\ (\ (0\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (0\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (0\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (0\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R")))))) query games feed extend[Result: .Match getposition[ 0 ]] project[Result] consume; #testcase test_getposition_1 #yields \ (\ (rel\ (tuple\ (\ (Result position))))\ (\ (\ (1\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (1\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "-" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (1\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "-" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (1\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R")))))) query games feed extend[Result: .Match getposition[ 1 ]] project[Result] consume; #testcase test_getposition_2 #yields \ (\ (rel\ (tuple\ (\ (Result position))))\ (\ (\ (2\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (2\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "-" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (2\ (\ ("r" "n" "b" "q" "k" "b" "-" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "n" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "-" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (2\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R")))))) query games feed extend[Result: .Match getposition[ 2 ]] project[Result] consume; #testcase test_getposition_20 #yields \ (\ (rel\ (tuple\ (\ (Result position))))\ (\ (\ (20\ (\ ("r" "-" "-" "q" "k" "-" "-" "r")\ ("-" "p" "p" "-" "-" "p" "p" "p")\ ("p" "-" "-" "b" "-" "-" "n" "-")\ ("-" "-" "p" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "P" "-" "Q" "-" "P")\ ("P" "P" "P" "-" "N" "P" "P" "-")\ ("R" "-" "B" "-" "-" "R" "K" "-"))))\ (\ (20\ (\ ("r" "-" "b" "q" "k" "-" "-" "r")\ ("p" "-" "-" "-" "-" "p" "p" "p")\ ("-" "p" "p" "b" "p" "n" "-" "-")\ ("-" "-" "-" "-" "-" "-" "N" "-")\ ("-" "-" "P" "P" "p" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "P" "-")\ ("P" "P" "-" "-" "-" "P" "B" "P")\ ("R" "-" "B" "Q" "-" "R" "K" "-"))))\ (\ (20\ (\ ("r" "n" "-" "-" "-" "r" "k" "-")\ ("-" "b" "p" "-" "-" "p" "p" "p")\ ("p" "p" "-" "q" "-" "n" "-" "-")\ ("-" "-" "-" "p" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("P" "-" "N" "-" "P" "N" "-" "-")\ ("-" "P" "-" "-" "B" "P" "P" "P")\ ("R" "-" "-" "Q" "K" "-" "-" "R"))))\ (\ (20\ (\ ("r" "-" "b" "q" "r" "-" "k" "-")\ ("p" "p" "p" "-" "-" "p" "p" "p")\ ("-" "b" "n" "p" "-" "n" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "P" "-" "-" "P" "-" "-" "-")\ ("-" "-" "P" "P" "-" "N" "-" "-")\ ("P" "-" "B" "N" "-" "P" "P" "P")\ ("R" "-" "B" "Q" "-" "R" "K" "-")))))) query games feed extend[Result: .Match getposition[ 20 ]] project[Result] consume; ####################################################################### # tests for getmove operator ####################################################################### #testcase getmove_neg #yields ((rel (tuple ((Result chessmove))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getmove[ -1 ]] project[Result] consume; #testcase getmove_0 #yields ((rel (tuple ((Result chessmove))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getmove[ 0 ]] project[Result] consume; #testcase getmove_200 #yields ((rel (tuple ((Result chessmove))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getmove[ 200 ]] project[Result] consume; #testcase getmove_1 #yields ((rel (tuple ((Result chessmove))))\ (((1 "Pawn" "none" "e" 2 "e" 4 FALSE))\ ((1 "Pawn" "none" "d" 2 "d" 4 FALSE))\ ((1 "Pawn" "none" "d" 2 "d" 4 FALSE))\ ((1 "Pawn" "none" "e" 2 "e" 4 FALSE)))) query games feed extend[Result: .Match getmove[ 1 ]] project[Result] consume; #testcase getmove_2 #yields ((rel (tuple ((Result chessmove))))\ (((2 "pawn" "none" "e" 7 "e" 5 FALSE))\ ((2 "pawn" "none" "e" 7 "e" 6 FALSE))\ ((2 "knight" "none" "g" 8 "f" 6 FALSE))\ ((2 "pawn" "none" "e" 7 "e" 5 FALSE)))) query games feed extend[Result: .Match getmove[ 2 ]] project[Result] consume; #testcase getmove_3 #yields ((rel (tuple ((Result chessmove))))\ (((3 "Knight" "none" "g" 1 "f" 3 FALSE))\ ((3 "Knight" "none" "g" 1 "f" 3 FALSE))\ ((3 "Knight" "none" "g" 1 "f" 3 FALSE))\ ((3 "Knight" "none" "g" 1 "f" 3 FALSE)))) query games feed extend[Result: .Match getmove[ 3 ]] project[Result] consume; #testcase getmove_4 #yields ((rel (tuple ((Result chessmove))))\ (((4 "knight" "none" "b" 8 "c" 6 FALSE))\ ((4 "knight" "none" "g" 8 "f" 6 FALSE))\ ((4 "pawn" "none" "e" 7 "e" 6 FALSE))\ ((4 "knight" "none" "b" 8 "c" 6 FALSE)))) query games feed extend[Result: .Match getmove[ 4 ]] project[Result] consume; ####################################################################### # tests for pieces operator ####################################################################### #testcase pieces_pos0 #yields ((rel (tuple ((Result material))))\ (((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1))))) query games feed extend[Result: .Match getposition[ 0 ] pieces] project[Result] consume; #testcase pieces_pos1 #yields ((rel (tuple ((Result material))))\ (((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1))))) query games feed extend[Result: .Match getposition[ 1 ] pieces] project[Result] consume; #testcase pieces_pos2 #yields ((rel (tuple ((Result material))))\ (((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1))))) query games feed extend[Result: .Match getposition[ 2 ] pieces] project[Result] consume; #testcase pieces_pos20 #yields ((rel (tuple ((Result material))))\ (((("Pawn" 8) ("Knight" 1) ("Bishop" 1) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 1) ("bishop" 1) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 7) ("Knight" 1) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 1) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 7) ("Knight" 2) ("Bishop" 1) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 7) ("knight" 2) ("bishop" 1) ("rook" 2) ("queen" 1) ("king" 1)))\ ((("Pawn" 8) ("Knight" 2) ("Bishop" 2) ("Rook" 2) ("Queen" 1) ("King" 1)\ ("pawn" 8) ("knight" 2) ("bishop" 2) ("rook" 2) ("queen" 1) ("king" 1))))) query games feed extend[Result: .Match getposition[ 20 ] pieces] project[Result] consume; #testcase pieces_pos_neg #yields ((rel (tuple ((Result material))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getposition[ -1 ] pieces] project[Result] consume; #testcase pieces_pos_200 #yields ((rel (tuple ((Result material))))\ ((undef)\ (undef)\ (undef)\ (undef))) query games feed extend[Result: .Match getposition[ 200 ] pieces] project[Result] consume; ####################################################################### # tests for moveNo operator ####################################################################### #testcase moveNo_pos0 #yields ((rel (tuple ((Result int))))\ ((0) (0) (0) (0))) query games feed extend[Result: .Match getposition[ 0 ] moveNo] project[Result] consume; #testcase moveNo_pos1 #yields ((rel (tuple ((Result int))))\ ((1) (1) (1) (1))) query games feed extend[Result: .Match getposition[ 1 ] moveNo] project[Result] consume; #testcase moveNo_pos2 #yields ((rel (tuple ((Result int))))\ ((2) (2) (2) (2))) query games feed extend[Result: .Match getposition[ 2 ] moveNo] project[Result] consume; #testcase moveNo_move1 #yields ((rel (tuple ((Result int))))\ ((1) (1) (1) (1))) query games feed extend[Result: .Match getmove[ 1 ] moveNo] project[Result] consume; #testcase moveNo_move2 #yields ((rel (tuple ((Result int))))\ ((2) (2) (2) (2))) query games feed extend[Result: .Match getmove[ 2 ] moveNo] project[Result] consume; #testcase pos_neg #yields ((rel (tuple ((Result int))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getmove[ -1 ] moveNo] project[Result] consume; #testcase pos_200 #yields ((rel (tuple ((Result int))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getmove[ 200 ] moveNo] project[Result] consume; #testcase moveNo_neg #yields ((rel (tuple ((Result int))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getmove[ -1 ] moveNo] project[Result] consume; #testcase moveNo_0 #yields ((rel (tuple ((Result int))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getmove[ 0 ] moveNo] project[Result] consume; #testcase moveNo_200 #yields ((rel (tuple ((Result int))))\ ((undef)(undef)(undef)(undef))) query games feed extend[Result: .Match getmove[ 200 ] moveNo] project[Result] consume; ####################################################################### # tests for getkey operator ####################################################################### #testcase getkey_Event #yields ((rel (tuple ((Event string))))\ (("37th Olympiad")\ ("37th Olympiad")\ ("37th Olympiad")\ ("37th Olympiad"))) query games feed extend[Event: .Match getkey ["Event"]] project [Event] consume; #testcase getkey_Site #yields ((rel (tuple ((Site string))))\ (("Turin ITA")\ ("Turin ITA")\ ("Turin ITA")\ ("Turin ITA"))) query games feed extend[Site: .Match getkey ["Site"]] project [Site] consume; #testcase getkey_Date #yields ((rel (tuple ((Date string))))\ (("2006.05.30")\ ("2006.06.02")\ ("2006.06.03")\ ("2006.06.04"))) query games feed extend[Date: .Match getkey ["Date"]] project [Date] consume; #testcase getkey_Round #yields ((rel (tuple ((Round string))))\ (("9")\ ("11")\ ("12")\ ("13"))) query games feed extend[Round: .Match getkey ["Round"]] project [Round] consume; #testcase getkey_White #yields ((rel (tuple ((White string))))\ (("Mas,H")\ ("Korchnoi,V")\ ("Paragua,M")\ ("Ghaem Maghami,E"))) query games feed extend[White: .Match getkey ["White"]] project [White] consume; #testcase getkey_Black #yields ((rel (tuple ((Black string))))\ (("Korchnoi,V")\ ("Berg,E")\ ("Korchnoi,V")\ ("Korchnoi,V"))) query games feed extend[Black: .Match getkey ["Black"]] project [Black] consume; #testcase getkey_Result #yields ((rel (tuple ((Result string))))\ (("1-0")\ ("1-0")\ ("0-1")\ ("1/2-1/2"))) query games feed extend[Result: .Match getkey ["Result"]] project [Result] consume; #testcase getkey_WhiteElo #yields ((rel (tuple ((WhiteElo string))))\ (("2412")\ ("2607")\ ("2617")\ ("2584"))) query games feed extend[WhiteElo: .Match getkey ["WhiteElo"]] project [WhiteElo] consume; #testcase getkey_BlackElo #yields ((rel (tuple ((BlackElo string))))\ (("2607")\ ("2539")\ ("2607")\ ("2607"))) query games feed extend[BlackElo: .Match getkey ["BlackElo"]] project [BlackElo] consume; #testcase getkey_ECO #yields ((rel (tuple ((ECO string))))\ (("C68")\ ("D02")\ ("E12")\ ("C54"))) query games feed extend[ECO: .Match getkey ["ECO"]] project [ECO] consume; #testcase getkey_Error #yields ((rel (tuple ((ECO string))))\ (("key blablabla not found")\ ("key blablabla not found")\ ("key blablabla not found")\ ("key blablabla not found"))) query games feed extend[ECO: .Match getkey ["blablabla"]] project [ECO] consume; ####################################################################### # tests for positions operator ####################################################################### #testcase positions0-9 #yields \ (\ (rel\ (tuple\ (\ (Pos position))))\ (\ (\ (0\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "P" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (1\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "p" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (2\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "N" "R"))))\ (\ (3\ (\ ("r" "n" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "-" "R"))))\ (\ (4\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "n" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "B" "-" "R"))))\ (\ (5\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("p" "p" "p" "p" "-" "p" "p" "p")\ ("-" "-" "n" "-" "-" "-" "-" "-")\ ("-" "B" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "-" "-" "R"))))\ (\ (6\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("-" "p" "p" "p" "-" "p" "p" "p")\ ("p" "-" "n" "-" "-" "-" "-" "-")\ ("-" "B" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "-" "-" "R"))))\ (\ (7\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("-" "p" "p" "p" "-" "p" "p" "p")\ ("p" "-" "B" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "-" "-" "R"))))\ (\ (8\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("-" "p" "p" "-" "-" "p" "p" "p")\ ("p" "-" "p" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "K" "-" "-" "R"))))\ (\ (9\ (\ ("r" "-" "b" "q" "k" "b" "n" "r")\ ("-" "p" "p" "-" "-" "p" "p" "p")\ ("p" "-" "p" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "-" "-" "N" "-" "-")\ ("P" "P" "P" "P" "-" "P" "P" "P")\ ("R" "N" "B" "Q" "-" "R" "K" "-"))))\ )) query games feed extendstream[Pos: .Match positions] project[Pos] head[10] consume; ####################################################################### # tests for moves operator ####################################################################### #testcase moves1-10 #yields \ (\ (rel\ (tuple\ (\ (Moves chessmove))))\ (\ ((1 "Pawn" "none" "e" 2 "e" 4 FALSE))\ ((2 "pawn" "none" "e" 7 "e" 5 FALSE))\ ((3 "Knight" "none" "g" 1 "f" 3 FALSE))\ ((4 "knight" "none" "b" 8 "c" 6 FALSE))\ ((5 "Bishop" "none" "f" 1 "b" 5 FALSE))\ ((6 "pawn" "none" "a" 7 "a" 6 FALSE))\ ((7 "Bishop" "knight" "b" 5 "c" 6 FALSE))\ ((8 "pawn" "Bishop" "d" 7 "c" 6 FALSE))\ ((9 "King" "none" "e" 1 "g" 1 FALSE))\ ((10 "bishop" "none" "c" 8 "g" 4 FALSE))\ )\ ) query games feed extendstream[Moves: .Match moves] project [Moves] head [10] consume; #testcase move_check #yields \ (\ (rel\ (tuple\ (\ (Moves chessmove))))\ (\ ((33 "Queen" "none" "f" 3 "a" 3 TRUE))\ )\ ) query games feed reduce [TRUE, 2] head[1] extendstream[Moves: .Match moves] project[Moves] reduce [TRUE, 33] head[1] consume; #testcase move_queenside_c #yields \ (\ (rel\ (tuple\ (\ (Moves chessmove))))\ (\ ((21 "King" "none" "e" 1 "c" 1 FALSE))\ )\ ) query games2 feed head[1] extendstream[Moves: .Match moves] project[Moves] reduce [TRUE, 21] head[1] consume; #testcase move_enpassent #yields \ (\ (rel\ (tuple\ (\ (Moves chessmove))))\ (\ ((57 "Pawn" "pawn" "e" 5 "f" 6 FALSE))\ )\ ) query games2 feed reduce [TRUE, 2] head[1] extendstream[Moves: .Match moves] project[Moves] reduce [TRUE, 57] head[1] consume; ####################################################################### # test for agent operator ####################################################################### #testcase agent #yields \ (\ (rel\ (tuple\ (\ (Agent string))))\ (\ ("Pawn")("pawn")("Knight")("pawn")("Pawn")("pawn")("Knight")("knight")\ ("Knight")("pawn")("Bishop")("pawn")("Pawn")("pawn")("Bishop")("knight")\ ("Pawn")("knight")("Queen")("pawn")("King")("bishop")("Knight")\ ("queen")("Knight")("pawn")("Pawn")("rook")("Pawn")("pawn")\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Agent: .Move agent] project [Agent] head[30] consume; ####################################################################### # test for captured operator ####################################################################### #testcase captured ####################################################################### #yields \ (\ (rel\ (tuple\ (\ (Captured string))))\ (\ ("none")("none")("none")("none")("none")("Pawn")("pawn")("none")\ ("none")("none")("none")("none")("none")("none")("none")("none")\ ("none")("none")("none")("none")("none")("none")("none")("none")\ ("knight")("Knight")("none")("none")("pawn")("Pawn")\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Captured: .Move captured] project [Captured] head[30] consume; ####################################################################### # test for startrow operator ####################################################################### #testcase startrow #yields \ (\ (rel\ (tuple\ (\ (Startrow int))))\ (\ (2)(7)(1)(7)(2)(5)(3)(8)\ (1)(7)(1)(7)(2)(7)(1)(8)\ (2)(6)(1)(7)(1)(8)(4)(8)\ (3)(6)(3)(8)(4)(6)\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Startrow: .Move startrow] project [Startrow] head[30] consume; ####################################################################### # test for endrow operator ####################################################################### #testcase endrow #yields \ (\ (rel\ (tuple\ (\ (Endrow int))))\ (\ (4)(5)(3)(6)(4)(4)(4)(6)\ (3)(6)(3)(6)(4)(6)(2)(6)\ (3)(5)(2)(5)(1)(7)(3)(7)\ (5)(5)(4)(8)(5)(5)\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Endrow: .Move endrow] project [Endrow] head[30] consume; ####################################################################### # test for startfile operator ####################################################################### #testcase startfile #yields \ (\ (rel\ (tuple\ (\ (Startfile string))))\ (\ ("e")("c")("g")("d")("d")("c")("f")("g")\ ("b")("a")("c")("e")("g")("h")("f")("b")\ ("h")("c")("d")("g")("e")("c")("d")("d")\ ("f")("d")("h")("h")("h")("h")\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Startfile: .Move startfile] project [Startfile] head[30] consume; ####################################################################### # test for endfile operator ####################################################################### #testcase endfile #yields \ (\ (rel\ (tuple\ (\ (Endfile string))))\ (\ ("e")("c")("f")("d")("d")("d")("d")("f")\ ("c")("a")("e")("e")("g")("h")("g")("c")\ ("h")("e")("e")("g")("c")("d")("f")("c")\ ("e")("e")("h")("g")("g")("g")\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Endfile: .Move endfile] project [Endfile] head[30] consume; ####################################################################### # test for check operator ####################################################################### #testcase check #yields \ (\ (rel\ (tuple\ (\ (Check bool))))\ (\ (FALSE)\ (TRUE)\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Check: .Move check] project [Check] reduce [TRUE, 30] head[2] consume; ####################################################################### # test for captures operator ####################################################################### #testcase check #yields \ (\ (rel\ (tuple\ (\ (Captures bool))))\ (\ (FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(TRUE)(TRUE)(FALSE)\ (FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)\ (FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)(FALSE)\ (TRUE)(TRUE)(FALSE)(FALSE)(TRUE)(TRUE)\ )\ ) query games2 feed head[1] extendstream[Move: .Match moves] project[Move] extend [Captures: .Move captures] project [Captures] head[30] consume; ####################################################################### # test for range operator ####################################################################### #testcase range #yields \ (\ (rel\ (tuple\ (\ (Result position))))\ (\ (\ (20\ (\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "p" "p" "-" "-" "p" "p" "-")\ ("-" "-" "-" "b" "-" "-" "n" "-")\ ("-" "-" "p" "-" "p" "-" "-" "-")\ ("-" "-" "-" "-" "P" "-" "-" "-")\ ("-" "-" "-" "P" "-" "Q" "-" "-")\ ("-" "P" "P" "-" "N" "P" "P" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-"))))\ (\ (20\ (\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "-" "-" "-" "-" "p" "p" "-")\ ("-" "p" "p" "b" "p" "n" "-" "-")\ ("-" "-" "-" "-" "-" "-" "N" "-")\ ("-" "-" "P" "P" "p" "-" "-" "-")\ ("-" "-" "-" "-" "-" "-" "P" "-")\ ("-" "P" "-" "-" "-" "P" "B" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-"))))\ (\ (20\ (\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "b" "p" "-" "-" "p" "p" "-")\ ("-" "p" "-" "q" "-" "n" "-" "-")\ ("-" "-" "-" "p" "-" "-" "-" "-")\ ("-" "-" "-" "P" "-" "-" "-" "-")\ ("-" "-" "N" "-" "P" "N" "-" "-")\ ("-" "P" "-" "-" "B" "P" "P" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-"))))\ (\ (20\ (\ ("-" "-" "-" "-" "-" "-" "-" "-")\ ("-" "p" "p" "-" "-" "p" "p" "-")\ ("-" "b" "n" "p" "-" "n" "-" "-")\ ("-" "-" "-" "-" "p" "-" "-" "-")\ ("-" "P" "-" "-" "P" "-" "-" "-")\ ("-" "-" "P" "P" "-" "N" "-" "-")\ ("-" "-" "B" "N" "-" "P" "P" "-")\ ("-" "-" "-" "-" "-" "-" "-" "-")))))) query games feed extend[Result: .Match getposition[ 20 ] posrange ["b", 2, "g", 7]] project[Result] consume; ####################################################################### # test for includes operator ####################################################################### #testcase range #yields \ (\ (rel\ (tuple\ (\ (Result bool))))\ ((TRUE)(TRUE)(TRUE)(TRUE))) query games feed extend[Result1: .Match getposition[ 20 ] posrange ["b", 2, "g", 7]] extend[Result2: .Match getposition[ 20 ]] extend[Result: .Result2 includes [.Result1]] project[Result] consume;