Jump to content
  • 0

How do you test X16 BASIC programs automatically using Pexpect or Expect?


mobluse
 Share

Question

I found a way to test my mental calculation training program Aritm for X16, C64, VIC20, ZX81, Apple I, PicoMite and other BASIC computers using Pexpect which is a system for automating logins etc. Pexpects is a Python module, but similar systems exist for other programming languages e.g. Expect for Perl.

For X16, C64, and VIC20 I didn't use actual computers or emulators, but a C64 BASIC for console: cbmbasic: https://github.com/mist64/cbmbasic. I only tested one actual computer using USB serial: PicoMite. I tested the ZX81 and Apple I versions using emulators.

I converted the X16 BASIC version to cbmbasic using: sed 's/#1,/ /' aritm-x16.bas > aritm-cbm.bas
and commented one line that had incompatible commands that only affected colors, screen size, and input prompt. cbmbasic doesn't support removing BASIC prompt using a file handle, but does using a poke, but I tried not to use pokes to make the program less dependent on a particular machine.

The test program is currently configured for cbmbasic and Aritm versions for X16, C64, and VIC20 are tested with the same configuration:
https://github.com/mobluse/aritmjs/blob/master/expect-aritm.py

The test configures Aritm to generate all problems and then answers them, but let you answer the last. In order to speed up testing one can change the delay subroutine in the BASIC program.

BASIC dialects are rather incompatible with regards to e.g. precedence rules and floating point precision; so it's important to test. You wouldn't want a program that is supposed to teach you mental calculation to teach you the wrong facts.

One could use the official X16 emulator, but that was more difficult to input to since one would have to send key presses to the emulator window, but that is also doable using another Python module, but I have not tested it with x16emu.

For future testing it would be good if the real X16 had a serial port, but if it doesn't one could send key presses using the PS/2 port and get output to Expect using e.g. morse or DTMF tones from the sound system or QR codes on the screen.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use