diff --git a/platforms/GoSXB/cov.yml b/platforms/GoSXB/cov.yml new file mode 100644 index 0000000..d6d1940 --- /dev/null +++ b/platforms/GoSXB/cov.yml @@ -0,0 +1,463 @@ +--- +'1': 383 +dup: 37 +'2': 216 +2dup: 13 +'3': 69 +3dup: 1 +'0': 398 +"?dup": 2 +over: 1 +'4': 34 +2over: 1 +pick: 1 +tuck: 1 +clear: 2 +drop: 23 +2drop: 1 +3drop: 1 +nip: 14 +":": 52 +'100': 3 +'200': 1 +'300': 1 +'400': 1 +'500': 1 +";": 53 +roll: 4 +rot: 1 +"-rot": 1 +swap: 19 +2swap: 1 +">r": 11 +r>: 11 +r@: 1 +depth: 1 +if: 24 +else: 19 +then: 29 +"-1": 171 +msb: 15 +'5': 37 +"+": 21 +"-5": 10 +"-2": 48 +mid-uint: 68 +"-": 11 +mid-uint+1: 65 +"*": 12 +"-3": 22 +rshift: 11 +or: 5 +u*: 6 +"/": 22 +'7': 17 +"-7": 14 +max-int: 129 +min-int: 128 +"*/": 19 +mod: 21 +"/mod": 21 +"*/mod": 19 +u/mod: 7 +1+: 18 +1-: 17 +2+: 2 +2-: 2 +abs: 4 +negate: 5 +max: 16 +min: 16 +bounds: 2 +'10': 8 +even: 4 +lshift: 6 +f: 3 +1s: 22 +xor: 7 +'8000': 2 +and: 12 +2*: 6 +">>a": 8 +invert: 8 +">>": 5 +0<: 7 +"-4": 1 +!!str '<<': 3 +0s: 16 +'4000': 2 +2/: 6 +u2/: 3 +not: 2 +s>d: 85 +d+: 25 +min-intd: 5 +hi-2int: 6 +max-2int: 5 +min-2int: 7 +lo-2int: 5 +d-: 26 +max-intd: 1 +um*: 14 +m*: 38 +max-uint: 77 +um/mod: 7 +fm/mod: 34 +sm/rem: 30 +'01020304': 4 +lbsplit: 1 +lwsplit: 1 +'0102': 3 +wbsplit: 1 +'04': 1 +'03': 1 +'02': 2 +'01': 2 +bljoin: 1 +bwjoin: 1 +'0304': 1 +wljoin: 1 +wbflip: 1 +lbflip: 1 +lwflip: 1 +"/c": 1 +"/w": 1 +"/l": 1 +"/n": 1 +ca+: 1 +wa+: 1 +la+: 1 +na+: 2 +ca1+: 2 +wa1+: 3 +la1+: 3 +na1+: 2 +"/c*": 1 +"/w*": 2 +"/l*": 2 +"/n*": 1 +aligned: 6 +char+: 6 +cell+: 10 +chars: 13 +cells: 3 +1st: 21 +2nd: 5 +u<: 16 +"@": 33 +"!": 13 +'6': 8 +2@: 4 +2!: 3 +'off': 1 +'on': 1 +1stc: 7 +2ndc: 5 +c@: 10 +c!: 6 +1stw: 9 +2ndw: 5 +w@: 8 +w!: 3 +ffff: 2 +"in": 1 +0>: 17 +ascii: 10 +parse: 1 +test/: 1 +test: 3 +source: 1 +word: 6 +count: 3 +"'": 37 +key?: 1 +0=: 27 +key: 1 +expect: 1 +span: 1 +accept: 1 +bell: 1 +bs: 1 +carret: 1 +linefeed: 1 +a: 8 +char: 1 +"[char]": 1 +control: 1 +.": 1 +test": 3 +".(": 1 +test): 1 +'41': 3 +emit: 1 +type: 1 +cr: 1 +space: 1 +'8': 2 +spaces: 1 +"#line": 1 +0>=: 8 +"#out": 1 +exit?: 1 +s": 32 +test"(41)": 2 +testa": 1 +comp: 1 +aaaaa": 1 +bbbb": 1 +pack: 1 +lcc: 2 +"=": 14 +b: 4 +upc: 2 +abc: 2 +"-trailing": 1 +hex: 5 +base: 5 +decimal: 1 +octal: 1 +123": 1 +"$number": 2 +$xyz": 2 +456": 1 +">number": 2 +3a: 1 +'30': 1 +do: 37 +i: 16 +digit: 4 +loop: 29 +'47': 1 +'67': 2 +'61': 1 +6a: 1 +d#: 1 +h#: 1 +o#: 1 +".": 3 +s.: 3 +u.: 3 +".r": 1 +u.r: 1 +".d": 1 +'15': 1 +".h": 1 +".s": 1 +"?": 1 +"(.)": 3 +0": 2 +-1": 1 +1": 4 +"(u.)": 3 +ffffffff": 1 +"<#": 5 +hold: 2 +'42': 1 +"#>": 4 +ba": 1 +sign: 3 +--": 1 +"#": 2 +01": 1 +"#s": 1 +u#s: 1 +u#>: 1 +"<": 26 +">": 29 +">=": 10 +between: 8 +within: 128 +0<=: 6 +"<=": 10 +0<>: 7 +u<=: 6 +u>: 6 +u>=: 6 +'false': 16 +'true': 4 +'234': 7 +case: 16 +endcase: 16 +of: 28 +endof: 28 +begin: 14 +while: 15 +repeat: 10 +until: 4 +n: 1 +"--": 1 +0,1,..n: 1 +recurse: 1 +"+loop": 8 +j: 8 +leave: 4 +"?leave": 2 +evaluate: 3 +eval: 1 +ge4: 1 +execute: 4 +quit: 1 +abort: 1 +abort": 1 +'111': 6 +'222': 6 +'333': 4 +'999': 4 +'11': 4 +'22': 4 +'33': 4 +'44': 4 +'345': 6 +unloop: 3 +exit: 2 +noop: 1 +catch: 3 +throw: 1 +x123: 3 +y123: 2 +2constant: 3 +x123456: 3 +y123456: 2 +value: 3 +val1: 6 +"-999": 1 +val2: 5 +to: 4 +"-333": 1 +val3: 3 +immediate: 5 +literal: 3 +variable: 1 +v1: 3 +'buffer:': 1 +alias: 1 +al2: 2 +defer: 1 +df1: 7 +behavior: 2 +struct: 2 +field: 2 +fld1: 2 +fld2: 2 +postpone: 4 +nop1: 2 +nop2: 2 +does>: 4 +create: 3 +cr1: 6 +">body": 3 +",": 2 +forget: 2 +forgetme3": 1 +forgetme2": 1 +forgetme1": 1 +da1: 1 +here: 7 +c,: 2 +w,: 1 +l,: 1 +align: 2 +allot: 1 +"[']": 2 +gt1string: 2 +find: 9 +gt2string: 1 +state: 2 +"[": 3 +csr: 2 +"]": 3 +wxt: 2 +supercalafrag: 1 +bd1: 1 +body>: 1 +recursive: 1 +rrv1: 4 +forth: 1 +environment?: 1 +code: 1 +label: 1 +c;: 1 +end-code: 1 +binary: 1 +bsx: 4 +7f: 1 +'80': 1 +ff: 1 +wsx: 4 +7fff: 1 +rdrop: 1 +r+1: 1 +">r@": 1 +dm1": 2 +"$create": 1 +last: 1 +dm1: 2 +">link": 1 +">name": 1 +foobar": 1 +"$tmpstr": 1 +a": 2 +foobaz": 2 +"$2value": 3 +bazbar": 2 +foobaz: 2 +bazbar: 2 +aconcat: 1 +fbbb: 3 +foobazbazbar": 1 +"$hex(": 1 +414243): 1 +abc": 1 +foo": 2 +cicomp: 1 +":temp": 1 +"[:": 1 +";]": 1 +"$empty-wl": 1 +"$env?-wl": 1 +"$sysif": 1 +"$direct": 1 +sqrtrem: 4 +'25': 1 +'31': 1 +"$memtop": 1 +u.0: 1 diff --git a/platforms/GoSXB/gosxb-of816.sh b/platforms/GoSXB/gosxb-of816.sh index 988d00c..644d5f5 100755 --- a/platforms/GoSXB/gosxb-of816.sh +++ b/platforms/GoSXB/gosxb-of816.sh @@ -1,3 +1,4 @@ #!/bin/bash EXEBIN=${GOSXB:-gosxb} +cd `dirname $0` exec ${EXEBIN} -load 0x200000:forth -rom-bank 0x20 -rom-file rom diff --git a/platforms/GoSXB/run-tests.rb b/platforms/GoSXB/run-tests.rb index 3b65983..c16fc95 100755 --- a/platforms/GoSXB/run-tests.rb +++ b/platforms/GoSXB/run-tests.rb @@ -142,6 +142,9 @@ def run_suite(suite, outfile = nil) @coverage[word.downcase] += 1 unless colons[word.downcase] end end + if line =~ /\\.*\s+covers:\s*(\S+)\s*$/ + @coverage[$1.downcase] += 1 + end if prevline =~ /expect:\s*\"(.+)\"\s*$/ unless line.chomp == $1 STDERR.puts prevline diff --git a/test/5.3.4.3.fs b/test/5.3.4.3.fs new file mode 100644 index 0000000..0695268 --- /dev/null +++ b/test/5.3.4.3.fs @@ -0,0 +1,16 @@ +testing 5.3.4.3 Get local arguments + +: s= ( str len str len ) + 2 pick over = if + drop swap comp 0= + else + 2drop 2drop false + then +; + +t{ s" foo bar" bl left-parse-string s" foo" s= >r s" bar" s= r> -> true true }t +t{ s" foo/bar" ascii / left-parse-string s" foo" s= >r s" bar" s= r> -> true true }t + +hex +t{ s" a5,f0" parse-2int -> f0 a5 }t +t{ s" babe,cafe" parse-2int -> cafe babe }t diff --git a/test/5.3.7.1.fs b/test/5.3.7.1.fs new file mode 100644 index 0000000..9888243 --- /dev/null +++ b/test/5.3.7.1.fs @@ -0,0 +1,33 @@ +testing 5.3.7.1 Peek/poke + +\ On the 65816, all memory regions are valid, even if there isn't anything there +\ so these always succeed. We just test for correctness. + +hex +variable foobar +f0e1d2c3 foobar ! + +t{ foobar cpeek -> c3 true }t +t{ foobar 1 ca+ cpeek -> d2 true }t +t{ foobar 2 ca+ cpeek -> e1 true }t +t{ foobar 3 ca+ cpeek -> f0 true }t + +t{ foobar wpeek -> d2c3 true }t +t{ foobar 1 wa+ wpeek -> f0e1 true }t + +t{ foobar lpeek -> f0e1d2c3 true }t + +t{ 01020304 foobar lpoke -> true }t +t{ foobar lpeek -> 01020304 true }t + +t{ abcd foobar wpoke -> true }t +t{ ef01 foobar 1 wa+ wpoke -> true }t +t{ foobar wpeek -> abcd true }t +t{ foobar 1 wa+ wpeek -> ef01 true }t +t{ foobar lpeek -> ef01abcd true }t + +t{ 22 foobar cpoke -> true }t +t{ 33 foobar 2 ca+ cpoke -> true }t +t{ foobar cpeek -> 22 true }t +t{ foobar 2 ca+ cpeek -> 33 true }t +t{ foobar lpeek -> ef33ab22 true }t diff --git a/test/5.3.7.2.fs b/test/5.3.7.2.fs new file mode 100644 index 0000000..cab57a6 --- /dev/null +++ b/test/5.3.7.2.fs @@ -0,0 +1,34 @@ +testing 5.3.7.1 Device-register access + +\ On the 65816, no strictly atomic 16-bit accesses can occur as the data bus is only +\ 8 bits. So the "register access" words are the same as their non-register equivalents. +\ We just test for correctness. + +hex +variable foobar +f0e1d2c3 foobar ! + +t{ foobar rb@ -> c3 }t +t{ foobar 1 ca+ rb@ -> d2 }t +t{ foobar 2 ca+ rb@ -> e1 }t +t{ foobar 3 ca+ rb@ -> f0 }t + +t{ foobar rw@ -> d2c3 }t +t{ foobar 1 wa+ rw@ -> f0e1 }t + +t{ foobar rl@ -> f0e1d2c3 }t + +t{ 01020304 foobar rl! -> }t +t{ foobar rl@ -> 01020304 }t + +t{ abcd foobar rw! -> }t +t{ ef01 foobar 1 wa+ rw! -> }t +t{ foobar rw@ -> abcd }t +t{ foobar 1 wa+ rw@ -> ef01 }t +t{ foobar rl@ -> ef01abcd }t + +t{ 22 foobar rb! -> }t +t{ 33 foobar 2 ca+ rb! -> }t +t{ foobar rb@ -> 22 }t +t{ foobar 2 ca+ rb@ -> 33 }t +t{ foobar rl@ -> ef33ab22 }t diff --git a/test/5.3.7.4.fs b/test/5.3.7.4.fs new file mode 100644 index 0000000..f28dcb1 --- /dev/null +++ b/test/5.3.7.4.fs @@ -0,0 +1,4 @@ +testing 5.3.7.4 System information + +hex +t{ fcode-revision -> 30000 }t diff --git a/test/7.3.1.fs b/test/7.3.1.fs index 63dfb21..db0b3c5 100644 --- a/test/7.3.1.fs +++ b/test/7.3.1.fs @@ -26,6 +26,7 @@ t{ 1 2 3 rot -> 2 3 1 }t t{ 1 2 3 -rot -> 3 1 2 }t t{ 1 2 swap -> 2 1 }t t{ 1 2 3 4 2swap -> 3 4 1 2 }t +t{ 1 2 3 4 5 6 2rot -> 3 4 5 6 1 2 }t testing 7.3.1.4 Return stack t{ 1 2 >r drop r> -> 2 }t \ both >r and r> diff --git a/test/7.3.4.fs b/test/7.3.4.fs index b8fd420..65991a9 100644 --- a/test/7.3.4.fs +++ b/test/7.3.4.fs @@ -11,6 +11,7 @@ t{ bl word test count swap 0> -> 4 true }t testing 7.3.4.2 Console input +\ covers: \ t{ \ -> supercalafrag }t \ since 't{' is a nop this should be fine t{ ' key? 0= -> false }t t{ ' key 0= -> false }t diff --git a/test/7.3.8.fs b/test/7.3.8.fs index 4c78d1e..12f94f0 100644 --- a/test/7.3.8.fs +++ b/test/7.3.8.fs @@ -18,9 +18,21 @@ testing 7.3.8.2 Case statement ENDCASE ; +\ covers: case +\ covers: endof +\ covers: case T{ 1 CS1 -> 111 }T +\ covers: case +\ covers: endof +\ covers: case T{ 2 CS1 -> 222 }T +\ covers: case +\ covers: endof +\ covers: case T{ 3 CS1 -> 333 }T +\ covers: case +\ covers: endof +\ covers: case T{ 4 CS1 -> 999 }T \ Nested CASE's @@ -38,11 +50,29 @@ T{ 4 CS1 -> 999 }T ENDCASE R> DROP ; +\ covers: case +\ covers: endof +\ covers: case T{ -1 1 CS2 -> 100 }T +\ covers: case +\ covers: endof +\ covers: case T{ -1 2 CS2 -> 200 }T +\ covers: case +\ covers: endof +\ covers: case T{ -1 3 CS2 -> -300 }T +\ covers: case +\ covers: endof +\ covers: case T{ -2 1 CS2 -> -99 }T +\ covers: case +\ covers: endof +\ covers: case T{ -2 2 CS2 -> -199 }T +\ covers: case +\ covers: endof +\ covers: case T{ 0 2 CS2 -> 299 }T \ Boolean short circuiting using CASE @@ -55,9 +85,21 @@ T{ 0 2 CS2 -> 299 }T ENDCASE ; +\ covers: case +\ covers: endof +\ covers: case T{ 1 CS3 -> 11 }T +\ covers: case +\ covers: endof +\ covers: case T{ 2 CS3 -> 22 }T +\ covers: case +\ covers: endof +\ covers: case T{ 3 CS3 -> 33 }T +\ covers: case +\ covers: endof +\ covers: case T{ 9 CS3 -> 44 }T \ Empty CASE statements with/without default @@ -167,10 +209,13 @@ DECIMAL : T1 9 ; : C1 1 2 3 ['] T1 CATCH ; +\ covers: CATCH T{ C1 -> 1 2 3 9 0 }T \ No THROW executed : T2 8 0 THROW ; : C2 1 2 ['] T2 CATCH ; +\ covers: catch +\ covers: throw T{ C2 -> 1 2 8 0 }T \ 0 THROW does nothing : T3 7 8 9 99 THROW ; diff --git a/test/7.3.9.fs b/test/7.3.9.fs index 66bac86..c0b49d6 100644 --- a/test/7.3.9.fs +++ b/test/7.3.9.fs @@ -131,7 +131,14 @@ variable csr t{ : cst [ state @ csr ! ] ; -> }t t{ csr @ -> 0 }t -\ todo: compile [compile] compile, +: ctestword compile true ; +create comptest +ctestword +\ covers:compile +t{ comptest @ -> ' true }t +t{ ' false compile, comptest 1 na+ @ -> ' false }t +t{ [compile] hex comptest 2 na+ @ -> ' hex }t + testing 7.3.9.2.3 Dictionary search diff --git a/test/7.5.1.fs b/test/7.5.1.fs new file mode 100644 index 0000000..6148587 --- /dev/null +++ b/test/7.5.1.fs @@ -0,0 +1,8 @@ +testing 7.5.1 Automatic stack display + +t{ showstack -> }t \ expect:"{ 0 : } OK" +5 \ expect:"{ 1 : 5 } OK" +drop +t{ noshowstack -> }t +t{ -> }t \ expect " OK" + diff --git a/test/7.5.3.fs b/test/7.5.3.fs new file mode 100644 index 0000000..7661f01 --- /dev/null +++ b/test/7.5.3.fs @@ -0,0 +1,4 @@ +testing Dictionary + +t{ ' words 0= -> false }t + diff --git a/test/of816-words.fs b/test/of816-words.fs index 39e7ad1..4a95e1b 100644 --- a/test/of816-words.fs +++ b/test/of816-words.fs @@ -76,4 +76,6 @@ hex t{ $memtop @ 0= -> false }t -t{ 123 u.0 -> }t \ expect: "123 OK" \ No newline at end of file +t{ 123 u.0 -> }t \ expect: "123 OK" + +t{ .version -> }t \ expect: /OF816/ diff --git a/test/test-manifest.yaml b/test/test-manifest.yaml index bf0247e..388e663 100644 --- a/test/test-manifest.yaml +++ b/test/test-manifest.yaml @@ -61,6 +61,30 @@ load: - tester.fs - 7.3.9.fs +- name: 7.5.1 Automatic stack display + load: + - tester.fs + - 7.5.1.fs +- name: 7.5.3 Dictionary + load: + - tester.fs + - 7.5.3.fs +- name: 5.3.4.3 Get local arguments + load: + - tester.fs + - 5.3.4.3.fs +- name: 5.3.7.1 Peek/poke + load: + - tester.fs + - 5.3.7.1.fs +- name: 5.3.7.2 Device-register access + load: + - tester.fs + - 5.3.7.2.fs +- name: 5.3.7.4 System-information + load: + - tester.fs + - 5.3.7.4.fs - name: OF816 Words load: - tester.fs diff --git a/utils/covrep.rb b/utils/covrep.rb index b80f60d..8a507dd 100755 --- a/utils/covrep.rb +++ b/utils/covrep.rb @@ -1,10 +1,25 @@ #!/usr/bin/ruby require 'yaml' -index_file = ARGV.shift || usage -File.readable?(index_file) || abort("#{index_file} not found!") +def usage + puts <