For testing purposes, can we flag a parser error as a move?

I have a case where I let parser errors handle some behavior in my anagram games. This may not have been ideal, but it worked well enough at the time. I think I did so to try to speed up the parser.

But the problem is I have

rule for printing a parser error:
if the player’s command matches the text “command”:
increment the score;

And now if I UNDO it, there’s nothing to undo, according to Inform.

Is there a way to force Inform to acknowledge “Hey, this is a parser error,” so I can undo things right off the bat?

This occasionally mucks with my scripts for Zarf’s regtest.py.

Fortunately, a workaround is just to have a >z command at the beginning, but if possible, I’d like to dispose of that. Is there any way to, or am I just stuck with my design/architectural choices?

I tried some other non-I6 workarounds and hacks (trying to push time with the advance time rule, using when play begins, using Before printing a parser error…) and I couldn’t find anything that worked other than doing a Z first. I think it’s a pretty good workaround. I expect error messages have the luxury of avoiding going through the turn sequence, so to make them do so (which would probably be necessary to get what you want; for an error to take a turn) is probably not worth it. But I’ll see if anyone else knows better.

-Wade

You can add:

** precommand: z

at the top of your test file so as not to have to add >z to every test. (Or, if you have many test files, you can run regtest.py with -pz to do the same.)

2 Likes

Wow. I didn’t know this! It helped eliminate some duplication in some scripts right away. And it reminded me to revisit the regtest.py options. It’s been a while since I was just glad the thing worked and I could even use regexes.

It also reminds me I never looked at custom check classes either, which I think would help if I wanted to test the ordering of text.

Now I need to go see if there is any option that can apply globally to any chunk of the game’s input. For instance, I use a separate script to parse the complete text, and if it finds a lone period on a line, the text “Runtime error” or two consecutive line breaks.

1 Like