Filing system testing, BASIC, line numbers and version control

Discuss all aspects of programming here. From 8-bit through to modern architectures.
Post Reply
Coeus
Posts: 1035
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Filing system testing, BASIC, line numbers and version control

Post by Coeus » Sat Jan 13, 2018 8:09 pm

So, after having asked previously, I think, and not hearing of anything I decided I should write some simple BASIC programs to act as a filing system test suite. This was primarily to replace manual testing in VDFS on B-Em but could potentially be useful for other new/changed filing systems so it occurred to be that perhaps I should publish them.

From that I wondered about GitHub, which of course included version control and but one of the disadvantages of BASIC having line numbers is that if you make a change that requires the program to be renumbered then large sections will appear to change as far as line-oriented version tracking is concerned when what has actually happened is lines have been inserted or deleted earlier in the program.

So then I started thinking that maybe I should try to work without the line numbers and check-in a file that starts with "AUTO" to get BASIC to assign the line numbers. The snag with that is that I have some test cases where the correct behaviour is to raise an error so I have some ON ERROR constructs to trap and silence the expected error and, at the same time, report the failure to cause an error trap as this is a test fail. Here's an example:

Code: Select all

  200REM Now test if the filing system will let us open the file for
  210REM reading while it is already open for writing.
  220ON ERROR GOTO 270
  230G%=OPENINF$
  240PRINT "fail: allowed file open for read while already open for write"
  250R$="Failed"
  260CLOSE#G%
  270ON ERROR OFF
  280CLOSE#F%
Is there an easy to way to get something like that not to use line numbers? It seems to me ON ERROR PROChandler doesn't work because that is the wrong way round - I want to execute code if the error does not occur.

And, if anyone realises they know of an existing filing system test suite or thinks what I have done so far may be useful then do let me know.

User avatar
sweh
Posts: 1962
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by sweh » Sun Jan 14, 2018 12:09 am

You could try something like

Code: Select all

E%=0
ON ERROR E%=1
IF E%=0 THEN _command_you_want_to_test
ON ERROR OFF
IF E%=1 THEN PRINT "Error happened"
IF E%=0 THEN PRINT "Command was successful"
Rgds
Stephen

User avatar
BigEd
Posts: 2099
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by BigEd » Sun Jan 14, 2018 8:06 am

Does
ON ERROR PROChandler : ENDProc
do the job? Or
ON ERROR PROChandler : RETURN
which is to say, each test would be encapsulated in a procedure or a subroutine, and the idea is to deal with the error and then bale out so the next test can run.

[Edit: no, it doesn't, as an error loses all nesting state]
Last edited by BigEd on Sun Jan 14, 2018 3:55 pm, edited 1 time in total.

User avatar
Lardo Boffin
Posts: 1279
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by Lardo Boffin » Sun Jan 14, 2018 12:27 pm

You could always go with ISO Pascal or BCPL? No line numbers!

If you do BASIC and need PROC based error handling read this thread:-

viewtopic.php?f=2&t=11973#top
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Viglen twin 40/80 5.25" discs, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master, Datacentre + HDD, pi co-proc

Coeus
Posts: 1035
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by Coeus » Sun Jan 14, 2018 3:31 pm

sweh wrote:You could try something like

Code: Select all

E%=0
ON ERROR E%=1
IF E%=0 THEN _command_you_want_to_test
ON ERROR OFF
IF E%=1 THEN PRINT "Error happened"
IF E%=0 THEN PRINT "Command was successful"
That looks useful. It had not occurred to me that the statement after the words ON ERROR does not have to be any kind of transfer of control and that you can then just let it run on afterwards through that does mean you have to what you have done and distinguish first time through, when the hander is set, from second time, when the hander fires.

Thanks.

Coeus
Posts: 1035
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by Coeus » Sun Jan 14, 2018 3:51 pm

Lardo Boffin wrote:You could always go with ISO Pascal or BCPL? No line numbers!
That's an interesting idea.

I do remember years ago being a little frustrated by Pascal primarily, I think, because it didn't have "string" as a data type but used "array of characters" instead and then I seem to remember one could not declare a formal parameter of a procedure without the bounds being known at compile time. The combination meant that variable length strings were just not possible.

At the time I just assumed this was something you could get away with in a educational language but not in a "proper" one but it may just be the age of Pascal - perhaps it dates from the days of batch processing with fixed length fields and fixed length records etc.

I am not sure how much of a restriction this would be in this case.

I also remember tinkering with BCPL. I remember working in "words" seemed odd at the time but may just be a case of getting into it.
Lardo Boffin wrote:If you do BASIC and need PROC based error handling read this thread:-

viewtopic.php?f=2&t=11973#top
Very interesting. I had already found using ON ERROR inside a procedure didn't work and assumed it must be the interpreter clearing whichever stack it used for those and confirmed by checking the source but I did not know about ON ERROR LOCAL in BASIC 4 or think about simulating it.

User avatar
Lardo Boffin
Posts: 1279
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by Lardo Boffin » Sun Jan 14, 2018 5:50 pm

Coeus wrote:
Lardo Boffin wrote:You could always go with ISO Pascal or BCPL? No line numbers!
I also remember tinkering with BCPL. I remember working in "words" seemed odd at the time but may just be a case of getting into it.
BCPL doesn’t have native string handling but I implemented some of the functions in the form of a library that can be used:-

viewtopic.php?f=2&t=13158
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Viglen twin 40/80 5.25" discs, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master, Datacentre + HDD, pi co-proc

User avatar
jgharston
Posts: 3215
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by jgharston » Sun Jan 14, 2018 5:56 pm

I'm on s tablet so forgive the typing.

That's the standard method, as used in my test progtasms at
http://mdfs.net/Software/BBCBasic/Testing/

OK=_true
On error ok=false
If ok then do something

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
jgharston
Posts: 3215
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by jgharston » Sun Jan 14, 2018 6:03 pm

And there's filing systrm test programs at http://mdfs.net/Apps/Filing/Testing/ and
Last edited by jgharston on Sun Jan 14, 2018 6:06 pm, edited 1 time in total.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

SteveF
Posts: 510
Joined: Fri Aug 28, 2015 8:34 pm
Contact:

Re: Filing system testing, BASIC, line numbers and version control

Post by SteveF » Sun Jan 14, 2018 6:04 pm

It may be redundant given the other suggestions in this thread, but FWIW I've enhanced beebasm's putbasic code to make line numbers optional. You can specify them on just lines which need them, so your source file could look something like this:

Code: Select all

PRINT "Code here without line numbers"
ON ERROR GOTO 1000
PRINT "More code"
END
1000PRINT "This line has a specific number"
PRINT "No line number here"
The only restriction is that the line numbers (both implicit and explicit) are in the right order, so if there were more than 999 lines before the '1000PRINT' line, that would fail.

You can get the code from: https://github.com/ZornsLemma/beebasm/t ... ed-updates

Post Reply