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

Ensure a newline exists at the end of files.

Fixes #42.
This commit is contained in:
Alec Thomas
2017-09-29 21:59:52 +10:00
parent 528bed2b60
commit 573c1d157d
13 changed files with 34 additions and 27 deletions

View File

@ -3,8 +3,7 @@ package chroma
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/alecthomas/assert"
)
func TestInclude(t *testing.T) {
@ -18,7 +17,7 @@ func TestInclude(t *testing.T) {
}
lexer := &RegexLexer{rules: actual}
err := include.Mutator.(LexerMutator).MutateLexer(lexer.rules, "root", 0)
require.NoError(t, err)
assert.NoError(t, err)
expected := CompiledRules{
"root": {
{Rule: Rule{
@ -41,18 +40,18 @@ func TestInclude(t *testing.T) {
}},
},
}
require.Equal(t, expected, actual)
assert.Equal(t, expected, actual)
}
func TestCombine(t *testing.T) {
l := MustNewLexer(nil, Rules{
l := MustNewLexer(&Config{DontEnsureNL: true}, Rules{
"root": {{`hello`, String, Combined("world", "bye", "space")}},
"world": {{`world`, Name, nil}},
"bye": {{`bye`, Name, nil}},
"space": {{`\s+`, Whitespace, nil}},
})
it, err := l.Tokenise(nil, "hello world")
require.NoError(t, err)
assert.NoError(t, err)
expected := []*Token{{String, `hello`}, {Whitespace, ` `}, {Name, `world`}}
assert.Equal(t, expected, it.Tokens())
}