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:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user