@@ -10,7 +10,7 @@ import Test.Hspec
1010import Sm.Internal
1111import Data.Array
1212
13- testAi gameData field time = (" test" , Nothing )
13+ testAi gameData field time = (" test" , return () )
1414cfg = Cfg {gameId = " GameId" , player = Just 1 , ai = testAi}
1515
1616testPlayers = array (0 , 1 ) [
@@ -45,9 +45,7 @@ testStep result [] = result
4545testStep result _ = result
4646
4747
48- sm (x: xs) cfg = testStep s xs
49- where
50- (s, _) = smStep (smCreate cfg) x
48+ sm xs cfg = testStep (smCreate cfg) xs
5149
5250
5351main :: IO ()
@@ -381,13 +379,13 @@ main = hspec $ do
381379 parseInput (
382380 FieldEndState gameData Draw 3 2
383381 ([[" 7" ," 11" ," 13" ],[" 2" ," 3" ," 5" ]]) )
384- cfg " + ENDFIELD" `stateShouldBe` (QuitState gameData Nothing , [] )
382+ cfg " + ENDFIELD" `stateShouldBe` (QuitState gameData Nothing field , [] )
385383
386384 it " Valid input (quit)" $ do
387385 parseInput (
388386 FieldEndState gameData (Winner 0 ) 3 2
389387 ([[" 7" ," 11" ," 13" ],[" 2" ," 3" ," 5" ]]) )
390- cfg " + ENDFIELD" `stateShouldBe` (QuitState gameData (Just 0 ), [] )
388+ cfg " + ENDFIELD" `stateShouldBe` (QuitState gameData (Just 0 ) field , [] )
391389
392390 it " Invalid input" $ do
393391 parseInput (FieldEndState gameData (Move 3000 ) 3 2 [[" 7" ," 11" ," 13" ],[" 2" ," 3" ," 5" ]]) cfg " + asd" `stateShouldBe` (ErrorState " Protocoll error: Expected end of board, but got \" + asd\" " , [] )
@@ -411,10 +409,10 @@ main = hspec $ do
411409
412410 describe " Parsing in player end state (+ QUIT)" $ do
413411 it " Valid input" $ do
414- parseInput (QuitState gameData (Just 0 )) cfg " + QUIT" `stateShouldBe` (EndState gameData (Just 0 ), [] )
412+ parseInput (QuitState gameData (Just 0 ) field ) cfg " + QUIT" `stateShouldBe` (EndState gameData (Just 0 ) field , [] )
415413
416414 it " Invalid input" $ do
417- parseInput (QuitState gameData (Just 0 )) cfg " + asd" `stateShouldBe` (ErrorState " Protocoll error: Expected quit, but got \" + asd\" " , [] )
415+ parseInput (QuitState gameData (Just 0 ) field ) cfg " + asd" `stateShouldBe` (ErrorState " Protocoll error: Expected quit, but got \" + asd\" " , [] )
418416
419417
420418
@@ -433,40 +431,20 @@ main = hspec $ do
433431 " + WAIT" , -- OKWAIT
434432 " + WAIT" , -- OKWAIT
435433 " + MOVE 3000" ,
436- " + FIELD 12,12" ,
437- " + 12 * * * * * * * * * * * *" ,
438- " + 11 * * * * * * * * * * * *" ,
439- " + 10 * * * * * * * * * * * *" ,
440- " + 9 * * * * * * * * * * * *" ,
441- " + 8 * * * * * * * * * * * *" ,
442- " + 7 * * * * * W B * * * * *" ,
443- " + 6 * * * * * B W * * * * *" ,
444- " + 5 * * * * * * * * * * * *" ,
445- " + 4 * * * * * * * * * * * *" ,
446- " + 3 * * * * * * * * * * * *" ,
447- " + 2 * * * * * * * * * * * *" ,
448- " + 1 * * * * * * * * * * * *" ,
434+ " + FIELD 3,2" ,
435+ " + 2 2 3 5" ,
436+ " + 1 7 11 13" ,
449437 " + ENDFIELD" , -- THINKING
450438 " + OKTHINK" , -- PLAY ...
451439 " + MOVEOK" ,
452440 " + WAIT" , -- OKWAIT
453441 " + WAIT" , -- OKWAIT
454442 " + GAMEOVER 0 Hans Peter" ,
455- " + FIELD 12,12" ,
456- " + 12 * * * * * * * * * * * *" ,
457- " + 11 * * * * * * * * * * * *" ,
458- " + 10 * * * * * * * * * * * *" ,
459- " + 9 * * * * * * * * * * * *" ,
460- " + 8 * * * * * * * * * * * *" ,
461- " + 7 * * * * * W B * * * * *" ,
462- " + 6 * * * * * B W * * * * *" ,
463- " + 5 * * * * * * * * * * * *" ,
464- " + 4 * * * * * * * * * * * *" ,
465- " + 3 * * * * * * * * * * * *" ,
466- " + 2 * * * * * * * * * * * *" ,
467- " + 1 * * * * * * * * * * * *" ,
443+ " + FIELD 3,2" ,
444+ " + 2 2 3 5" ,
445+ " + 1 7 11 13" ,
468446 " + ENDFIELD" ,
469- " + QUIT" ] cfg `shouldBe` SmEnd gameData (Just 1 )
447+ " + QUIT" ] cfg `shouldBe` SmEnd gameData (Just 1 ) field
470448
471449 it " Valid input (instant gameover)" $ do
472450 sm [
@@ -479,13 +457,11 @@ main = hspec $ do
479457 " + 1 Horst 1" ,
480458 " + ENDPLAYERS" ,
481459 " + GAMEOVER 0 Hans Peter" ,
482- " + FIELD 4,4" ,
483- " + 4 a b c d" ,
484- " + 3 e f g h" ,
485- " + 2 i j k l" ,
486- " + 1 m n o p" ,
460+ " + FIELD 3,2" ,
461+ " + 2 2 3 5" ,
462+ " + 1 7 11 13" ,
487463 " + ENDFIELD" ,
488- " + QUIT" ] cfg `shouldBe` SmEnd gameData (Just 1 )
464+ " + QUIT" ] cfg `shouldBe` SmEnd gameData (Just 1 ) field
489465
490466 it " Invalid input (missing last field)" $ do
491467 sm [
@@ -498,10 +474,8 @@ main = hspec $ do
498474 " + 1 Horst 1" ,
499475 " + ENDPLAYERS" ,
500476 " + GAMEOVER 0 Hans Peter" ,
501- " + FIELD 4,4" ,
502- " + 4 a b c d" ,
503- " + 3 e f g h" ,
504- " + 2 i j k l" ,
477+ " + FIELD 3,2" ,
478+ " + 2 2 3 5" ,
505479 " + ENDFIELD" ,
506480 " + QUIT" ] cfg `shouldBe` SmError " Protocoll error: Expected board row, but got \" + ENDFIELD\" "
507481
@@ -516,12 +490,10 @@ main = hspec $ do
516490 " + 1 Horst 1" ,
517491 " + ENDPLAYERS" ,
518492 " + GAMEOVER 0 Hans Peter" ,
519- " + FIELD 4,4" ,
520- " + 3 e f g h" ,
521- " + 2 i j k l" ,
522- " + 1 m n o p" ,
493+ " + FIELD 3,2" ,
494+ " + 1 7 11 13" ,
523495 " + ENDFIELD" ,
524- " + QUIT" ] cfg `shouldBe` SmError " Unexpected row number. Caussed by \" + 3 e f g h \" "
496+ " + QUIT" ] cfg `shouldBe` SmError " Unexpected row number. Caussed by \" + 1 7 11 13 \" "
525497
526498 it " Invalid input (missing other players)" $ do
527499 sm [
@@ -533,11 +505,9 @@ main = hspec $ do
533505 " + TOTAL 2" ,
534506 " + ENDPLAYERS" ,
535507 " + GAMEOVER 0 Hans Peter" ,
536- " + FIELD 4,4" ,
537- " + 4 a b c d" ,
538- " + 3 e f g h" ,
539- " + 2 i j k l" ,
540- " + 1 m n o p" ,
508+ " + FIELD 3,2" ,
509+ " + 2 2 3 5" ,
510+ " + 1 7 11 13" ,
541511 " + ENDFIELD" ,
542512 " + QUIT" ] cfg `shouldBe` SmError " Protocoll error: Expected oponent info, but got \" + ENDPLAYERS\" "
543513
@@ -553,11 +523,9 @@ main = hspec $ do
553523 " + 1 Horst 1" ,
554524 " + ENDPLAYERS" ,
555525 " + GAMEOVER 0 Hans Peter" ,
556- " + FIELD 4,4" ,
557- " + 4 a b c d" ,
558- " + 3 e f g h" ,
559- " + 2 i j k l" ,
560- " + 1 m n o p" ,
526+ " + FIELD 3,2" ,
527+ " + 2 2 3 5" ,
528+ " + 1 7 11 13" ,
561529 " + ENDFIELD" ,
562530 " + QUIT" ] cfg `shouldBe` SmError " Player already defined. Caussed by \" + 1 Horst 1\" "
563531
@@ -573,10 +541,8 @@ main = hspec $ do
573541 " + 2 Player 1 1" ,
574542 " + ENDPLAYERS" ,
575543 " + GAMEOVER 0 Hans Peter" ,
576- " + FIELD 4,4" ,
577- " + 4 a b c d" ,
578- " + 3 e f g h" ,
579- " + 2 i j k l" ,
580- " + 1 m n o p" ,
544+ " + FIELD 3,2" ,
545+ " + 2 2 3 5" ,
546+ " + 1 7 11 13" ,
581547 " + ENDFIELD" ,
582548 " + QUIT" ] cfg `shouldBe` SmError " Protocoll error: Expected end of oponent list, but got \" + 2 Player 1 1\" "
0 commit comments