package css_lexer import ( "strings" "testing" "github.com/evanw/esbuild/internal/logger" "github.com/evanw/esbuild/internal/test" ) func lexToken(contents string) (T, string) { log := logger.NewDeferLog(logger.DeferLogNoVerboseOrDebug, nil) result := Tokenize(log, test.SourceForTest(contents), Options{}) if len(result.Tokens) > 0 { t := result.Tokens[0] return t.Kind, t.DecodedText(contents) } return TEndOfFile, "" } func lexerError(contents string) string { log := logger.NewDeferLog(logger.DeferLogNoVerboseOrDebug, nil) Tokenize(log, test.SourceForTest(contents), Options{}) var text strings.Builder for _, msg := range log.Done() { text.WriteString(msg.String(logger.OutputOptions{}, logger.TerminalInfo{})) } return text.String() } func TestTokens(t *testing.T) { expected := []struct { contents string text string token T }{ {"", "end of file", TEndOfFile}, {"@media", "@-keyword", TAtKeyword}, {"url(x y", "bad URL token", TBadURL}, {"-->", "\"-->\"", TCDC}, {"