// readParseTest reads a single test case from r.
readParseTest reads a single test case from r.
// readParseTest reads a single test case from r .
func readParseTest(r *bufio.Reader) (text, want, context string, err error) {
	line, err := r.ReadSlice('\n')
	if err != nil {
		return "", "", "", err
	}
	var b []byte
	if string(line) != "#data\n" {
		return "", "", "", fmt.Errorf(`got %q want "#data\n"`, line)
	}
	for {
		line, err = r.ReadSlice('\n')
		if err != nil {
			return "", "", "", err
		}
		if line[0] == '#' {
			break
		}
		b = append(b, line...)
	}
	text = strings.TrimRight(string(b), "\n")
	b = b[:0]
	if string(line) != "#errors\n" {
		return "", "", "", fmt.Errorf(`got %q want "#errors\n"`, line)
	}
	for {
		line, err = r.ReadSlice('\n')
		if err != nil {
			return "", "", "", err
		}
		if line[0] == '#' {
			break
		}
	}
	if string(line) == "#document-fragment\n" {
		line, err = r.ReadSlice('\n')
		if err != nil {
			return "", "", "", err
		}
		context = strings.TrimSpace(string(line))
		line, err = r.ReadSlice('\n')
		if err != nil {
			return "", "", "", err
		}
	}
	if string(line) != "#document\n" {
		return "", "", "", fmt.Errorf(`got %q want "#document\n"`, line)
	}
	for {
		line, err = r.ReadSlice('\n')
		if err != nil && err != io.EOF {
			return "", "", "", err
		}
		if len(line) == 0 || len(line) == 1 && line[0] == '\n' {
			break
		}
		b = append(b, line...)
	}
	return text, string(b), context, nil
}
func readParseTest ( r * bufio . Reader ) ( text , want , context string , err error ) { line , err := r . ReadSlice ( '\n' ) if err != nil { return " " , " " , " " , err } var b [ ] byte if string ( line ) != " \n " { return " " , " " , " " , fmt . Errorf ( `got %q want "#data\n"` , line ) } for { line , err = r . ReadSlice ( '\n' ) if err != nil { return " " , " " , " " , err } if line [ 0 ] == '#' { break } b = append ( b , line ... ) } text = strings . TrimRight ( string ( b ) , " \n " ) b = b [ : 0 ] if string ( line ) != " \n " { return " " , " " , " " , fmt . Errorf ( `got %q want "#errors\n"` , line ) } for { line , err = r . ReadSlice ( '\n' ) if err != nil { return " " , " " , " " , err } if line [ 0 ] == '#' { break } } if string ( line ) == " \n " { line , err = r . ReadSlice ( '\n' ) if err != nil { return " " , " " , " " , err } context = strings . TrimSpace ( string ( line ) ) line , err = r . ReadSlice ( '\n' ) if err != nil { return " " , " " , " " , err } } if string ( line ) != " \n " { return " " , " " , " " , fmt . Errorf ( `got %q want "#document\n"` , line ) } for { line , err = r . ReadSlice ( '\n' ) if err != nil && err != io . EOF { return " " , " " , " " , err } if len ( line ) == 0 || len ( line ) == 1 && line [ 0 ] == '\n' { break } b = append ( b , line ... ) } return text , string ( b ) , context , nil }
readParseTest reads a single test case from r.
readParseTest reads a single test case from r .
// Read the HTML. // Skip the error list. // Read the dump of what the parse tree should be.