simon987 / Much-Assembly-Required

Assembly programming game
https://muchassemblyrequired.com
GNU General Public License v3.0
925 stars 87 forks source link

Adding tests is really hard #227

Closed kevinramharak closed 4 years ago

kevinramharak commented 4 years ago

Hey Simon,

I was trying to add tests for each instruction because i am not confident they all work 100% correctly, but it is really hard to add tests for some instructions. For example the CallInstruction expects a CPU instance and the CPU instance either uses the GameServer singleton (which does not exist in tests) or you can give it a fake config, but then you need to give it a Cubot instance.

The more complicated the instruction becomes the hard it is to test. I know you have some refactoring in mind. Any ideas on how to make testing easier to implement?

simon987 commented 4 years ago

 Any ideas on how to make testing easier to implement?

It's definitely planned to add Fakes for Cubot & CPU etc. Even better would be to abstract all the Assembler/CPU code to allow for different ISAs. I'll keep you updated on my progress

simon987 commented 4 years ago

I added some helper functions, let me know what you think.

Example:

https://github.com/simon987/Much-Assembly-Required/blob/ad0124508c57a11010a61b3903f2cd4fafbbd9ec/src/test/java/net/simon987/mar/server/assembly/instruction/CallInstructionTest.java#L12-L30

kevinramharak commented 4 years ago

That seems way easier. Expressing the assembly in java is hard. This would make it trivial