emilybache / Tennis-Refactoring-Kata

This is a Refactoring Kata based on the rules of Tennis
https://youtu.be/XifUs1FhWRc
MIT License
737 stars 1.27k forks source link

C: TennisGame4: Deuce, GameServer #120

Closed nitsanavni closed 11 months ago

nitsanavni commented 1 year ago

here's the current test report:

$ ./TennisGame4Test 
[==========] Running 34 test(s).
[ RUN      ] checkRealisticTennisGame
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] checkRealisticTennisGame
[ RUN      ] Love-All
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Love-All
[ RUN      ] Fifteen-All
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Fifteen-All
[ RUN      ] Thirty-All
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Thirty-All
[ RUN      ] Deuce
[       OK ] Deuce
[ RUN      ] Deuce
[       OK ] Deuce
[ RUN      ] Fifteen-Love
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Fifteen-Love
[ RUN      ] Love-Fifteen
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Love-Fifteen
[ RUN      ] Thirty-Love
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Thirty-Love
[ RUN      ] Love-Thirty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Love-Thirty
[ RUN      ] Forty-Love
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Forty-Love
[ RUN      ] Love-Forty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Love-Forty
[ RUN      ] Win for player1
[       OK ] Win for player1
[ RUN      ] Win for player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Win for player2
[ RUN      ] Thirty-Fifteen
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Thirty-Fifteen
[ RUN      ] Fifteen-Thirty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Fifteen-Thirty
[ RUN      ] Forty-Fifteen
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Forty-Fifteen
[ RUN      ] Fifteen-Forty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Fifteen-Forty
[ RUN      ] Win for player1
[       OK ] Win for player1
[ RUN      ] Win for player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Win for player2
[ RUN      ] Forty-Thirty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Forty-Thirty
[ RUN      ] Thirty-Forty
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Thirty-Forty
[ RUN      ] Win for player1
[       OK ] Win for player1
[ RUN      ] Win for player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Win for player2
[ RUN      ] Advantage player1
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player1
[ RUN      ] Advantage player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player2
[ RUN      ] Advantage player1
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player1
[ RUN      ] Advantage player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player2
[ RUN      ] Advantage player1
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player1
[ RUN      ] Advantage player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Advantage player2
[ RUN      ] Win for player1
[       OK ] Win for player1
[ RUN      ] Win for player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Win for player2
[ RUN      ] Win for player1
[       OK ] Win for player1
[ RUN      ] Win for player2
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] Win for player2
[==========] 34 test(s) run.
[  PASSED  ] 7 test(s).
[  FAILED  ] 27 test(s), listed below:
[  FAILED  ] checkRealisticTennisGame
[  FAILED  ] Love-All
[  FAILED  ] Fifteen-All
[  FAILED  ] Thirty-All
[  FAILED  ] Fifteen-Love
[  FAILED  ] Love-Fifteen
[  FAILED  ] Thirty-Love
[  FAILED  ] Love-Thirty
[  FAILED  ] Forty-Love
[  FAILED  ] Love-Forty
[  FAILED  ] Win for player2
[  FAILED  ] Thirty-Fifteen
[  FAILED  ] Fifteen-Thirty
[  FAILED  ] Forty-Fifteen
[  FAILED  ] Fifteen-Forty
[  FAILED  ] Win for player2
[  FAILED  ] Forty-Thirty
[  FAILED  ] Thirty-Forty
[  FAILED  ] Win for player2
[  FAILED  ] Advantage player1
[  FAILED  ] Advantage player2
[  FAILED  ] Advantage player1
[  FAILED  ] Advantage player2
[  FAILED  ] Advantage player1
[  FAILED  ] Advantage player2
[  FAILED  ] Win for player2
[  FAILED  ] Win for player2

 27 FAILED TEST(S)

here's the chat history to create this working starting position:

./chat "let's write this in C

we can use function pointer for this chain of responsibility pattern

just start me off with the deuce one, I'll complete the rest later

here's the original java:

---

$(cat ../java/src/main/java/TennisGame4.java )"
./chat "add the TennisGame_Create and TennisGame_WonPoint functions to this file:

$(cat TennisGame4.c )

according to this java impl:

$(cat ../java/src/main/java/TennisGame4.java )"
./chat "add the TennisGame_GetScore function to this file:

$(cat TennisGame4.c )

according to this java impl:

$(cat ../java/src/main/java/TennisGame4.java )"
./chat "add the TennisGame_GetScore (for now we only support the deuce) function to this file:

$(cat TennisGame4.c )

according to this java impl:

$(cat ../java/src/main/java/TennisGame4.java )"
./chat "write an h file for this C file, I think we only need the create, wonPoint, and getscore

$(cat TennisGame4.c )
"
./chat "can we forward declare the struct?

$(cat TennisGame4.h )"
../chat "let's add only the GameServer resolver as implemented in java to the following C code:

$(cat ../TennisGame4.c )

here's the original java:

$(cat ../../java/src/main/java/TennisGame4.java )"
codecop commented 11 months ago

Nitsan thank you. I am confused. Tests are failing? Is this an improvement? Is it a port? Or is it an experiment using chat bot (which would not belong into this template repo). Please advise

emilybache commented 11 months ago

The TennisGame4 is not workign in C. I tried to translate it and got stuck - I think I pushed what I had though. Nitsan was hoping to pair with me to fix this and get help from ChatGPT but that unfortunately hasn't happened. This is not an improvement on the code I had already (which also doesn't work but at least I understand) so I havn't merged it.

codecop commented 11 months ago

Finished the C code, see PR #127

emilybache commented 11 months ago

Thanks to you both for your help! This issue is now resolved with Peter's recent PR