@@ -2106,21 +2106,54 @@ func TestThreadStepSameLabel(t *testing.T) {
21062106 }
21072107}
21082108
2109- // TestHelpCoversMenuKeys: every NORMAL key that runs a menu command or a channel-pane step appears in the ? help .
2110- func TestHelpCoversMenuKeys ( t * testing. T ) {
2111- var all string // every key and description of the help as one text
2109+ // helpWords is the words the help rows document, and the rows as one text. A key text "r 1-9" documents r1 to r9 .
2110+ func helpWords ( rows [][ 2 ] string ) ( map [ string ] bool , string ) {
2111+ var all string
21122112 words := map [string ]bool {}
2113- for _ , s := range helpSections {
2114- for _ , k := range s .keys {
2115- for _ , f := range strings .Fields (k [0 ]) {
2116- words [f ] = true
2117- }
2118- for _ , f := range strings .Fields (k [1 ]) {
2119- words [strings .Trim (f , "()," )] = true
2113+ for _ , k := range rows {
2114+ fs := strings .Fields (k [0 ])
2115+ for i , f := range fs {
2116+ words [f ] = true
2117+ if lo , hi , ok := strings .Cut (f , "-" ); ok && i > 0 && len (lo ) == 1 && len (hi ) == 1 && lo [0 ] >= '0' && lo [0 ] <= hi [0 ] && hi [0 ] <= '9' {
2118+ for d := lo [0 ]; d <= hi [0 ]; d ++ {
2119+ words [fs [i - 1 ]+ string (d )] = true
2120+ }
21202121 }
2121- all += " " + k [0 ] + " " + k [1 ]
21222122 }
2123+ for _ , f := range strings .Fields (k [1 ]) {
2124+ words [strings .Trim (f , "()," )] = true
2125+ }
2126+ all += " " + k [0 ] + " " + k [1 ]
2127+ }
2128+ return words , all
2129+ }
2130+
2131+ // TestHelpRangeRowCoversKeys: the row "r 1-9" covers r1 to r9 and nothing outside it (negative control for TestHelpCoversMenuKeys).
2132+ func TestHelpRangeRowCoversKeys (t * testing.T ) {
2133+ words , _ := helpWords ([][2 ]string {{"r 1-9" , "react" }})
2134+ for _ , k := range []string {"r1" , "r5" , "r9" } {
2135+ if ! words [k ] {
2136+ t .Errorf ("%s not covered by the row r 1-9" , k )
2137+ }
2138+ }
2139+ for _ , k := range []string {"r0" , "r10" , "x1" } {
2140+ if words [k ] {
2141+ t .Errorf ("%s wrongly covered by the row r 1-9" , k )
2142+ }
2143+ }
2144+ words , _ = helpWords ([][2 ]string {{"r" , "react" }}) // no range row: r1 is not documented
2145+ if words ["r1" ] {
2146+ t .Error ("r1 covered without a range row" )
2147+ }
2148+ }
2149+
2150+ // TestHelpCoversMenuKeys: every NORMAL key that runs a menu command or a channel-pane step appears in the ? help.
2151+ func TestHelpCoversMenuKeys (t * testing.T ) {
2152+ var rows [][2 ]string
2153+ for _ , s := range helpSections {
2154+ rows = append (rows , s .keys ... )
21232155 }
2156+ words , all := helpWords (rows )
21242157 checked := 0
21252158 for _ , b := range normalBindings {
21262159 key := bindingText (b .keys )
0 commit comments