increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 160 forks source link

(Enhancement) Add 'TESTS' section to PuzzleScript files #412

Closed vir3lsa closed 7 years ago

vir3lsa commented 7 years ago

It'd be really useful to be able to add test cases to PuzzleScript files. It would give much greater confidence that rule changes haven't broken anything. Something like:

=======
TESTS
=======

test that crates can be pushed right

given
.....
.pc..
.....

when [right 0.1 right]
then
.....
...pc
.....

This could be further enhanced, of course, but a basic before-and-after system with the ability to simulate keyboard input would be a great start.

A new 'TEST' link in the editor would run all tests found in the TESTS section and print results to the console.

vir3lsa commented 7 years ago

I'm going to start looking at this but wanted an issue to track work against.

increpare commented 7 years ago

This is way outside the scope of complexity that I want to support (and I feel like it's not crazy useful - though I haven't made very big games w/ puzzlescript myself). (Feel free to do it in a branch of your own, of course!)

vir3lsa commented 7 years ago

Ah, sure, I'd do it in a separate branch, then you can see what you think of it. It won't be useful for everyone, but it'll definitely help with my dabblings - currently I pretty much have to run through the whole game to make sure everything still works. Being able to do that at the click of a button is a much more attractive prospect!

increpare commented 7 years ago

understood! There's already a unit testing system for the engine - if you play a game in the editor and press ctrl+j it spits replay info to the console - that you can paste into tests/resources/testdata.js and run with tests/index.html. But that's for fixed source code. But it might be a starting point (though it's not very 'code-integrated') - dunno!

On Fri, Oct 6, 2017 at 7:56 PM, richlocke87 notifications@github.com wrote:

Ah, sure, I'd do it in a separate branch, then you can see what you think of it. It won't be useful for everyone, but it'll definitely help with my dabblings - currently I pretty much have to run through the whole game to make sure everything still works. Being able to do that at the click of a button is a much more attractive prospect!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/increpare/PuzzleScript/issues/412#issuecomment-334841209, or mute the thread https://github.com/notifications/unsubscribe-auth/AAca4DMc8rJxe22T91EQDyUHOWmcKeRXks5spnfggaJpZM4Pwvg4 .

vir3lsa commented 7 years ago

Oh, interesting! Thanks - this is definitely useful to see. Simulating inputs and stuff - good to see how that's done. And some of those test names are inspired. "Damn I'm huge" is a particular highlight.

Yeah, this isn't all that far from what I want to do. Time to get coding!