mirror of
https://github.com/alecthomas/chroma.git
synced 2025-07-01 00:35:06 +02:00
Switch to an Iterator interface.
This is to solve an issue where writers returned by the Formatter were often stateful, but this fact was not obvious to the API consumer, and failed in interesting ways.
This commit is contained in:
@ -20,11 +20,11 @@ func TestCompressStyle(t *testing.T) {
|
||||
|
||||
func BenchmarkHTMLFormatter(b *testing.B) {
|
||||
formatter := New()
|
||||
writer, err := formatter.Format(ioutil.Discard, styles.Fallback)
|
||||
assert.NoError(b, err)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
err = lexers.Go.Tokenise(nil, "package main\nfunc main()\n{\nprintln(`hello world`)\n}\n", writer)
|
||||
it, err := lexers.Go.Tokenise(nil, "package main\nfunc main()\n{\nprintln(`hello world`)\n}\n")
|
||||
assert.NoError(b, err)
|
||||
err = formatter.Format(ioutil.Discard, styles.Fallback, it)
|
||||
assert.NoError(b, err)
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,6 @@ func TestSplitTokensIntoLines(t *testing.T) {
|
||||
in := []*chroma.Token{
|
||||
{Value: "hello", Type: chroma.NameKeyword},
|
||||
{Value: " world\nwhat?\n", Type: chroma.NameKeyword},
|
||||
{Type: chroma.EOF},
|
||||
}
|
||||
expected := [][]*chroma.Token{
|
||||
[]*chroma.Token{
|
||||
@ -45,7 +44,6 @@ func TestSplitTokensIntoLines(t *testing.T) {
|
||||
},
|
||||
[]*chroma.Token{
|
||||
{Type: chroma.NameKeyword},
|
||||
{Type: chroma.EOF},
|
||||
},
|
||||
}
|
||||
actual := splitTokensIntoLines(in)
|
||||
|
Reference in New Issue
Block a user