On Sun, Mar 1, 2020 at 8:21 AM Warren Stephens <wsteph...@prognoshealth.com> wrote: > > // I don't want to get into the specific syntax of the test code directly, > // but a test would start execution here, supplying "lines" and "thing2" > // > mystep2 with: lines, thing2 // <---------- hide all local variables from > above except for lines and thing2 > > mymap := make(map[string]int) > for _, line := range lines { > if strings.Contains(line, thing2) { > count := strings.Count(line, thing2) > mymap[line] = count > } > } > > // and the test would end here -- because the next line is another "with" (or > return) statement > // it would be able to do Asserts and such on the variables within the scope > of this code segment > > Ian, > > An alternative approach would be to have: > > mystep2 with: lines, thing2 => mymap > > to specify all of the intermediate variables of interest for the test. > > These testable code chunks, delimited by with statements, act like hidden > funcs. The actual call could be something like test_doSomeStuff@mystep2
To me this all seems very unlike anything else in the Go language. There is nothing syntactically similar to this anywhere else. I think it is extremely unlikely that Go would adopt this idea. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWqFF5tdwYCm5eRM7kXO6v9sD2ERaig2KGruasn0G-Y4Q%40mail.gmail.com.