// 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 *func*s. The actual call could be something like *test_doSomeStuff@mystep2* Warren > I feel like there is something missing here. How do you write a test > that uses a with statement? > > 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/f18a9af6-240b-4f3c-a011-6d68ed69784e%40googlegroups.com.