MCPcopy
hub / github.com/golang/net / TestHTML5LibTests

Function TestHTML5LibTests

html/token_test.go:1106–1172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1104}
1105
1106func TestHTML5LibTests(t *testing.T) {
1107 skipTests := map[string]bool{
1108 // We emit a comment token here, instead of no token. This is a specification
1109 // divergence that we may want to fix.
1110 "test1.test/Empty end tag": true,
1111 "test2.test/Empty end tag with following characters": true,
1112 "test2.test/Empty end tag with following tag": true,
1113 "test2.test/Empty end tag with following comment": true,
1114 "test2.test/Empty end tag with following end tag": true,
1115 "test3.test/</>": true,
1116 "test4.test/CR EOF after doctype name": true,
1117 "test4.test/Doctype public case-sensitivity (1)": true,
1118 "test4.test/Doctype public case-sensitivity (2)": true,
1119 "test4.test/Doctype system case-sensitivity (1)": true,
1120 "test4.test/Doctype system case-sensitivity (2)": true,
1121 }
1122
1123 var tests struct {
1124 Tests []h5libTest
1125 }
1126 testFiles, err := filepath.Glob("testdata/html5lib-tests/tokenizer/*.test")
1127 if err != nil {
1128 t.Fatal(err)
1129 }
1130 for _, testFile := range testFiles {
1131 data, err := os.ReadFile(testFile)
1132 if err != nil {
1133 t.Fatal(err)
1134 }
1135 if err := json.Unmarshal(data, &tests); err != nil {
1136 t.Fatal(err)
1137 }
1138
1139 base := filepath.Base(testFile)
1140
1141 for _, tc := range tests.Tests {
1142 name := fmt.Sprintf("%s/%s", base, tc.Description)
1143 t.Run(name, func(t *testing.T) {
1144 if skipTests[name] {
1145 t.Skip("skipping, known failure")
1146 }
1147 if len(tc.InitialStates) > 0 {
1148 t.Skip("Initial states not supported yet")
1149 }
1150 if strings.Contains(tc.Input, "<!DOCTYPE") {
1151 t.Skip("Skipping DOCTYPE")
1152 }
1153 z := NewTokenizer(strings.NewReader(tc.Input))
1154 var tokens []Token
1155 for {
1156 if z.Next() == ErrorToken {
1157 if z.Err() == io.EOF {
1158 break
1159 }
1160 t.Fatalf("Error: %v", z.Err())
1161 }
1162 tokens = append(tokens, z.Token())
1163 }

Callers

nothing calls this directly

Calls 8

NextMethod · 0.95
ErrMethod · 0.95
TokenMethod · 0.95
NewTokenizerFunction · 0.85
sortTokenAttributesFunction · 0.85
SkipMethod · 0.80
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…