func checkList(list *ast.ListCell, expect []string) []string { errors := make([]string, 0) cell := list.First() // for each expected value for i, e := range expect { // error if value expected but list end if cell == nil { unreadStr := fmt.Sprint(expect[i:]) errors = append(errors, "list terminated before cells "+unreadStr) break } // error if wrong cell contents cellStr := fmt.Sprint(cell) if cellStr != e { errors = append(errors, "expected cell value \""+e+"\", got \""+cellStr+"\"") } cell = cell.Next() } // error if all expected done but list not done if cell != nil { lenDiff := list.Value() - len(expect) errors = append(errors, "output too long by "+strconv.Itoa(lenDiff)+" cells") } return errors }