@@ -628,4 +628,113 @@ mod integration_tests {
628628 assert_eq ! ( "!" , res. stdout) ;
629629 assert ! ( res. stderr. is_empty( ) ) ;
630630 }
631+
632+ //ref: https://github.com/your-diary/piet_programming_language/issues/1#issuecomment-2407660388
633+ #[ test]
634+ fn test40 ( ) {
635+ //ref: https://github.com/JanEricNitschke/TicTacToe/blob/main/tictactoe_piet/input1.txt
636+ let stdin = "0\n 1\n 2\n 3\n 4\n 5\n 6\n " ;
637+
638+ let expected_stdout = r#"
639+ ---
640+ ---
641+ ---
642+ Input:
643+ X--
644+ ---
645+ ---
646+ Input:
647+ XO-
648+ ---
649+ ---
650+ Input:
651+ XOX
652+ ---
653+ ---
654+ Input:
655+ XOX
656+ O--
657+ ---
658+ Input:
659+ XOX
660+ OX-
661+ ---
662+ Input:
663+ XOX
664+ OXO
665+ ---
666+ Input:
667+ Win for X!
668+ XOX
669+ OXO
670+ X--
671+ "# ;
672+
673+ let res = run ( "./test_images/tictactoe.png" , Some ( stdin) ) ;
674+ if !res. success ( ) {
675+ println ! ( "{}" , res. stderr) ;
676+ }
677+ assert ! ( res. success( ) ) ;
678+ assert_eq ! ( expected_stdout. trim_start( ) , res. stdout) ;
679+ assert ! ( res. stderr. is_empty( ) ) ;
680+ }
681+
682+ //ref: https://github.com/your-diary/piet_programming_language/issues/1#issuecomment-2407660388
683+ //similar to `test40()` but with a different input
684+ #[ test]
685+ fn test41 ( ) {
686+ //ref: https://github.com/JanEricNitschke/TicTacToe/blob/main/tictactoe_piet/input2.txt
687+ let stdin = "0\n 4\n 8\n 1\n 7\n 6\n 2\n 5\n 3\n " ;
688+
689+ let expected_stdout = r#"
690+ ---
691+ ---
692+ ---
693+ Input:
694+ X--
695+ ---
696+ ---
697+ Input:
698+ X--
699+ -O-
700+ ---
701+ Input:
702+ X--
703+ -O-
704+ --X
705+ Input:
706+ XO-
707+ -O-
708+ --X
709+ Input:
710+ XO-
711+ -O-
712+ -XX
713+ Input:
714+ XO-
715+ -O-
716+ OXX
717+ Input:
718+ XOX
719+ -O-
720+ OXX
721+ Input:
722+ XOX
723+ -OO
724+ OXX
725+ Input:
726+ Draw
727+ XOX
728+ XOO
729+ OXX
730+ "# ;
731+
732+ let res = run ( "./test_images/tictactoe.png" , Some ( stdin) ) ;
733+ if !res. success ( ) {
734+ println ! ( "{}" , res. stderr) ;
735+ }
736+ assert ! ( res. success( ) ) ;
737+ assert_eq ! ( expected_stdout. trim_start( ) , res. stdout) ;
738+ assert ! ( res. stderr. is_empty( ) ) ;
739+ }
631740}
0 commit comments