Automated Testing

version 1/090116 by Roger Carbol

  • Home page
  • Beginning
  • Previous



  • Part 9 -- The Magical Glulx Stuff

    Include (-

    #ifndef TIMER_DELAY;
    Constant TIMER_DELAY 10;
    #endif;

    [ HandleGlkEvent ev context abortres newcmd cmdlen ;
    context = 0; ! suppress ignored warning
    switch (ev-->0) {
        evtype_Timer:
            FollowRulebook( (+glulx timed activity rules+) );
            if ( FollowRulebook( (+command-counting rules +) ) && RulebookSucceeded())
            {
                FollowRulebook( (+command-showing rules+) );
                if ( FollowRulebook( (+command-pasting rules+) )) return 2;
            }
        }
    ];

    -) before "Glulx.i6t".

    Glulx replacement command is some indexed text that varies.

    The glulx timed activity rules is a rulebook.
    A glulx timed activity rule (this is the default command replacement by timer rule):
        if testcontroller is unstable:
            say "[line break][line break][second custom style][unicode failure sign] ABORT: [index of testcontroller] [testname of testcontroller], step [current-step of testcontroller][roman type] -- Things have gone horribly wrong. It is likely the parser did not recognize one or more words in your command.[line break]";
            stop the test;
        change the glulx replacement command to command of testcontroller;
        now testcontroller is unstable;
        rule succeeds.

    The command-counting rules are a rulebook.
    A command-counting rule (this is the ordinary checking for content rule):
        if the number of characters in the glulx replacement command is 0, rule fails;
        rule succeeds.

    The command-showing rules are a rulebook.
    A command-showing rule (this is the print text to the input prompt rule):
        say input-style-for-glulx;
        say Glulx replacement command;
        say roman type;
        start capturing text.

    To say input-style-for-Glulx:
        (- glk_set_style(style_Input); -)

    The command-pasting rules are a rulebook.
    A command-pasting rule (this is the glue replacement command into parse buffer rule):
        change the text of the player's command to the Glulx replacement command;
        rule succeeds.

    Use timer delay of at least 10 translates as (- Constant TIMER_DELAY = {N}; -).

    Include (-
    [ StartTimer msec ;
    glk_request_timer_events(msec);
    ]; -)

    To start timer: (-
    StartTimer(TIMER_DELAY); -)

    To stop timer: (-
    StartTimer(0); -)

    [I suspect this is a horrible hack; sorry.]
    To reboot: (- glk_request_timer_events(0); GL__M(##Restart, 1);
    @restart; GL__M(##Restart, 2); -).

    Automated Testing ends here.