Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
Yeah, I'll report is as a bug
Also, I ahve expanded my test suite again, this time with more anagrams. The latest version of th test suite is posted below and (because of the extremely long lines) can also be downloaded at http://people.bu.edu/jenmeyer/kixtart/anagram_test.zip
You will also need the KiXGolf3.kix file and KiXtart in the same directory as the test script. then just paste your Anagram UDF into it, and it'll validate your UDF and spit out the KiXtart golf score.
I'm done with my script, passing all five validation test and achieving a test score of 742 and no way of shortening it.
code:
BREAK ON
DIM $rc, $inputarray, $correctoutput, $outputarray, $line DIM $error1, $error2, $error3, $error4, $error5, $shellcommand
$rc=SETOPTION('Explicit','ON') $rc=SETOPTION('NoVarsInString','ON')
; begin testing with regular array $inputarray='hack,snooped,tables,salt,spiff,feeling,spooned,last,grep,bleats,gas,ablest,fleeing,stable,slat,drive' $correctoutput='feeling fleeing,snooped spooned,last salt slat,ablest bleats stable tables'
$inputarray=SPLIT($inputarray,',') $correctoutput=SPLIT($correctoutput,',')
$outputarray=Anagram($inputarray)
IF UBOUND($outputarray)=UBOUND($correctoutput) FOR $line=0 TO UBOUND($outputarray) ? $outputarray[$line] IF $outputarray[$line]<>$correctoutput[$line] ? 'The output array element '+$outputarray[$line]+' is incorrect' $error1=1 ENDIF NEXT ELSE ? 'The output array has an incorret size of '+UBOUND($outputarray) $error1=1 ENDIF if $error1 color r+/n ? 'UDF failed regular input array test' color w/n else ? 'UDF passed regular input array test' endif ; end testing with regular array
; begin testing with another regular array $inputarray='admirer,parental,whatever,trifles,repost,kixtart,raddle,lifters,tartkiz,atrophied,filters,warez,perseus,paternal,married,with,children,larded,hoes,poster,hose,filets,prenatal,parlante,itself,stifler,aphrodite,stifle,portes,shoe,ladder,peruses,presto' $correctoutput='admirer married,aphrodite atrophied,perseus peruses,filets itself stifle,hoes hose shoe,ladder larded raddle,filters lifters stifler trifles,parental parlante paternal prenatal,portes poster presto repost'
$inputarray=SPLIT($inputarray,',') $correctoutput=SPLIT($correctoutput,',')
$outputarray=Anagram($inputarray)
IF UBOUND($outputarray)=UBOUND($correctoutput) FOR $line=0 TO UBOUND($outputarray) ? $outputarray[$line] IF $outputarray[$line]<>$correctoutput[$line] ? 'The output array element '+$outputarray[$line]+' is incorrect' $error2=1 ENDIF NEXT ELSE ? 'The output array has an incorret size of '+UBOUND($outputarray) $error2=1 ENDIF if $error2 color r+/n ? 'UDF failed another regular input array test' color w/n else ? 'UDF passed another regular input array test' endif ; end testing with another regular array
; begin testing with empty array redim $inputarray[0] $correctoutput=''
$outputarray=Anagram($inputarray)
if $outputarray<>$correctoutput ? 'The output array is not empty' $error3=1 ENDIF if $error3 color r+/n ? 'UDF failed empty input array test' color w/n else ? 'UDF passed empty input array test' endif ; end testing with empty array
; begin testing with empty string $inputarray='' $correctoutput=''
$outputarray=Anagram($inputarray)
IF $outputarray<>$correctoutput ? 'The output array is not empty' $error4=1 ENDIF if $error4 color r+/n ? 'UDF failed empty input string test' color w/n else ? 'UDF passed empty input string test' endif ; end testing with empty string
; begin testing with array of no anagrams $inputarray='test,testing,tester,store' $inputarray=SPLIT($inputarray,',') $correctoutput=''
$outputarray=Anagram($inputarray)
IF UBOUND($outputarray)=UBOUND($correctoutput) FOR $line=0 TO UBOUND($outputarray) ? $outputarray[$line]+' = '+$correctoutput[$line] IF $outputarray[$line]<>$correctoutput[$line] ? 'The output array element '+$outputarray[$line]+' is incorrect' $error5=1 ENDIF NEXT ELSE ? 'The output array has an incorret size of '+UBOUND($outputarray) $error5=1 ENDIF if $error5 color r+/n ? 'UDF failed no anagram input array test' color w/n else ? 'UDF passed no anagram input array test' endif ; end testing with array of no anagrams
IF $error1 or $error2 or $error3 or $error4 or $error5 color r+/n ? 'The Anagram() UDF failed validation' color w/n ELSE ? 'The Anagram() UDF passed validation' ENDIF
$shellcommand=@scriptdir+'\kix32.exe '+@scriptdir+'\Kixgolf3.kix $f='+@scriptname ? $shellcommand shell $shellcommand
; end of the kiXtart Golf validation script
; beginning of the Anagram() UDF and supporting UDFs ;!
;! ;! ; end of the Anagram() UDF and supporting UDFs
_________________________
There are two types of vessels, submarines and targets.
|