Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a float that does not occur after a numeric string #99

Closed
wants to merge 1 commit into from

Conversation

Wolfe-Lyon
Copy link

@Wolfe-Lyon Wolfe-Lyon commented Aug 28, 2017

In some cases, a floating point number in a basic program may occur after a non-numeric character. For example the basic loader for Trap Door contains the following sequence of bytes:

0,0,70,0,253,50,52,53,55,53,32,8,14,143,71,52,51,51...

The LIST command (and snapinfo.py prior to the current change) will show this as:

0 CLEAR 24575 {0x08}...

However the true program as processed by the basic interpreter is:

0 CLEAR 25498.1...

The changes in this pull request should enable snapinfo.py to display the hidden floating point number.

Changes:

  • If a float is present and does not follow immediately after a numeric string, it will always be printed. The existing behaviour, whereby a float may or may not be printed depending upon whether or not it agrees with the numeric string when it follows immediately after such has been preserved.
  • A new unit test (test_floating_point_number_after_non_number) has been added to test the new functionality.
  • The existing unit test test_all_tokens has been modified to remove a "hidden" floating point number that was present in line 290.

@codecov-io
Copy link

Codecov Report

Merging #99 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #99   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          35     35           
  Lines        9741   9743    +2     
=====================================
+ Hits         9741   9743    +2
Impacted Files Coverage Δ
skoolkit/basic.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7eb76e...4345e46. Read the comment docs.

@skoolkid
Copy link
Owner

Well spotted! However, there are a couple of problems with this patch:

  • It shows the value of the floating point number even when it matches the numeric string that is followed by spaces and non-printable characters (e.g. '10 PRINT 1 {0x08}{1}')
  • It shows the value of the floating point number placeholders in DEF FN statements

I've committed a fix in 014414d. It also fixes another bug I noticed while in that area of code: if a fake floating point number was zero, its value was not being shown.

@skoolkid skoolkid closed this Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants