Page 1 of 1

You cannot test too much

Posted: Mon Sep 27, 2021 4:24 am
by dunbarx
Where have I heard that before?

I made a scrabble scoring and tile tracking program, and found that my code threw an error when I invoked one of its features. That feature allows the player to modify an earlier play, assuming that he later discovered that he entered that earlier play incorrectly.

But this happened only once, and I could not replicate it. Then I remembered that the error occurred when I entered the string "or" for the incorrect string. The string "or" was in the local variable "it", and this line of code barked:

Code: Select all

do "put" && toUpper(it) && "into line" && tLine && "of fld" && tTarget -- 'it" contained "or"
The string "or" threw LC into a fit, and it is easy to see why. Fixing it only required that I:

Code: Select all

do "put" && quote & toUpper(it) & quote && "into line" && tLine && "of fld" && tTarget
make sure that a string as reserved as "or" is, is explicitly made a literal.

Craig