Po-man's code coverage for HP 48, 50g, etc.
|
05-07-2014, 05:38 PM
(This post was last modified: 05-08-2014 01:03 PM by HP67.)
Post: #1
|
|||
|
|||
Po-man's code coverage for HP 48, 50g, etc.
I had a relatively complicated CASE statement at the end of some calculations and I didn't have test cases that I knew would drive each case condition. I realized if I just started testing I didn't have a good way to see if each case was exercised.
Instead of the usual display statement I decided to use the user flags since the 48 has 64 and the 50g has 128, plenty for my purposes. First I wrote a small RPL program to clear all the user flags with a FOR NEXT loop. I realize you can whip up two flag words with one of them cleared and just STOF or even save and restore the flags in a variable, but this little piece of code is just as simple to use since the calculator displays the VARS and you just hit a soft menu button. Chef's choice. Then I added code to set the flag as part of each case THEN clause. 1 SF for the first condition, 2 SF for the second, etc. Next I wrote a small program to run through the user flags and display the number of each flag that was set. Finally I tested my program with a bunch of data and after each test I ran my display program. When all the flags were set I knew I had covered all the code in the CASE statement. I like using flags for testing and code coverage because unlike display statements they don't affect the stack and can be left in "production" code. The 48 even displays the first 5 in the annunciator area which is really great. I thought the 50g did that too but in my testing I didn't see any change in the display. I know there are some real heavy-duty RPL and assembly developers on the forums but I haven't seen debugging articles or info. So I hope somebody finds this useful. It ain't OVER 'till it's 2 PICK |
|||
05-13-2014, 11:07 PM
Post: #2
|
|||
|
|||
RE: Po-man's code coverage for HP 48, 50g, etc.
The trick seems to be suitable for the WP 34S, two. Checking the flags is easy with the STATUS functionality. Clearing all flags is just a matter of executing a single command (CFALL).
Marcus von Cube Wehrheim, Germany http://www.mvcsys.de http://wp34s.sf.net http://mvcsys.de/doc/basic-compare.html |
|||
05-14-2014, 06:01 AM
(This post was last modified: 05-14-2014 06:01 AM by HP67.)
Post: #3
|
|||
|
|||
RE: Po-man's code coverage for HP 48, 50g, etc.
Thanks, Marcus! Excellent news.
It ain't OVER 'till it's 2 PICK |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)