1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-01 00:35:06 +02:00

Document and add iterator panic recovery.

This commit is contained in:
Alec Thomas
2017-09-20 22:30:25 +10:00
parent cc0e4a59ab
commit e2d6abaa64
10 changed files with 75 additions and 27 deletions

View File

@ -1,6 +1,7 @@
package html
import (
"errors"
"io/ioutil"
"testing"
@ -49,3 +50,11 @@ func TestSplitTokensIntoLines(t *testing.T) {
actual := splitTokensIntoLines(in)
assert.Equal(t, expected, actual)
}
func TestIteratorPanicRecovery(t *testing.T) {
it := func() *chroma.Token {
panic(errors.New("bad"))
}
err := New().Format(ioutil.Discard, styles.Fallback, it)
assert.Error(t, err)
}