Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Upgrade project to Go 1.19 and switch to alecthomas/assert/v2
  • Loading branch information
alecthomas committed Oct 17, 2022
1 parent b338844 commit 40b7a91
Show file tree
Hide file tree
Showing 29 changed files with 127 additions and 133 deletions.
11 changes: 11 additions & 0 deletions .golangci.yml
Expand Up @@ -37,6 +37,17 @@ linters:
- wrapcheck
- stylecheck
- thelper
- nonamedreturns
- revive
- dupword
- exhaustruct
- varnamelen
- forcetypeassert
- ireturn
- maintidx
- govet
- nosnakecase
- testableexamples

linters-settings:
govet:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/golangci-lint
2 changes: 1 addition & 1 deletion cmd/chroma/go.mod
@@ -1,6 +1,6 @@
module github.com/alecthomas/chroma/v2/cmd/chroma

go 1.17
go 1.19

replace github.com/alecthomas/chroma/v2 => ../../

Expand Down
5 changes: 3 additions & 2 deletions cmd/chroma/go.sum
@@ -1,12 +1,13 @@
github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw=
github.com/alecthomas/kong v0.2.17 h1:URDISCI96MIgcIlQyoCAlhOmrSw6pZScBNkctg8r0W0=
github.com/alecthomas/kong v0.2.17/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ=
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
Expand Down
2 changes: 1 addition & 1 deletion cmd/chromad/go.mod
@@ -1,6 +1,6 @@
module github.com/alecthomas/chroma/v2/cmd/chromad

go 1.17
go 1.19

require (
github.com/alecthomas/chroma/v2 v2.0.0-00010101000000-000000000000
Expand Down
13 changes: 4 additions & 9 deletions cmd/chromad/go.sum
@@ -1,11 +1,10 @@
github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw=
github.com/alecthomas/kong v0.2.1-0.20190721020729-f7d3d9bfb5ed/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
github.com/alecthomas/kong v0.2.4 h1:Y0ZBCHAvHhTHw7FFJ2FzCAAG4pkbTgA45nc7BpMhDNk=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/kong-hcl v0.2.0 h1:l1+pkGJm2BtRJF9dCq9hw6KZWEanteY4Ar9suW3Qm0g=
github.com/alecthomas/kong-hcl v0.2.0/go.mod h1:S5D46RHGG8Ubdxk8TuXBT9wndShsA8/JYSxxiI9y01Y=
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
Expand All @@ -20,16 +19,12 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion coalesce_test.go
Expand Up @@ -3,7 +3,7 @@ package chroma
import (
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"
)

func TestCoalesce(t *testing.T) {
Expand Down
19 changes: 11 additions & 8 deletions colour_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"math"
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"
)

func TestColourRGB(t *testing.T) {
Expand Down Expand Up @@ -62,12 +62,10 @@ func hue(c Colour) float64 {
}

func TestColourClampBrightness(t *testing.T) {
const delta = 0.01 // used for brightness and hue comparisons

// Start with a colour with a brightness close to 0.5.
initial := NewColour(0, 128, 255)
br := initial.Brightness()
assert.InDelta(t, 0.5, br, delta)
assertInDelta(t, 0.5, br)

// Passing a range that includes the colour's brightness should be a no-op.
assert.Equal(t, initial.String(), initial.ClampBrightness(br-0.01, br+0.01).String())
Expand All @@ -79,10 +77,15 @@ func TestColourClampBrightness(t *testing.T) {
// Clamping to a brighter or darker range should produce the requested
// brightness while preserving the colour's hue.
brighter := initial.ClampBrightness(0.75, 1)
assert.InDelta(t, 0.75, brighter.Brightness(), delta)
assert.InDelta(t, hue(initial), hue(brighter), delta)
assertInDelta(t, 0.75, brighter.Brightness())
assertInDelta(t, hue(initial), hue(brighter))

darker := initial.ClampBrightness(0, 0.25)
assert.InDelta(t, 0.25, darker.Brightness(), delta)
assert.InDelta(t, hue(initial), hue(darker), delta)
assertInDelta(t, 0.25, darker.Brightness())
assertInDelta(t, hue(initial), hue(darker))
}

func assertInDelta(t *testing.T, expected, actual float64) {
const delta = 0.01 // used for brightness and hue comparisons
assert.True(t, actual > (expected-delta) && actual < (expected+delta))
}
2 changes: 1 addition & 1 deletion delegate_test.go
Expand Up @@ -3,7 +3,7 @@ package chroma
import (
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"
)

func makeDelegationTestLexers(t *testing.T) (lang Lexer, root Lexer) {
Expand Down
19 changes: 10 additions & 9 deletions formatters/html/html_test.go
Expand Up @@ -4,10 +4,11 @@ import (
"bytes"
"fmt"
"io/ioutil"
"regexp"
"strings"
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"

"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
Expand Down Expand Up @@ -117,7 +118,7 @@ func TestTabWidthStyle(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)

assert.Regexp(t, `<pre.*style=".*background-color:[^;]+;-moz-tab-size:4;-o-tab-size:4;tab-size:4;[^"]*".+`, buf.String())
assert.True(t, regexp.MustCompile(`<pre.*style=".*background-color:[^;]+;-moz-tab-size:4;-o-tab-size:4;tab-size:4;[^"]*".+`).MatchString(buf.String()))
}

func TestWithCustomCSS(t *testing.T) {
Expand All @@ -129,7 +130,7 @@ func TestWithCustomCSS(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)

assert.Regexp(t, `<span style="display:flex;display:inline;"><span><span style=".*">echo</span> FOO</span></span>`, buf.String())
assert.True(t, regexp.MustCompile(`<span style="display:flex;display:inline;"><span><span style=".*">echo</span> FOO</span></span>`).MatchString(buf.String()))
}

func TestWithCustomCSSStyleInheritance(t *testing.T) {
Expand All @@ -144,7 +145,7 @@ func TestWithCustomCSSStyleInheritance(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)

assert.Regexp(t, ` <span style=".*;background:blue;color:tomato;">&#34;FOO&#34;</span>`, buf.String())
assert.True(t, regexp.MustCompile(` <span style=".*;background:blue;color:tomato;">&#34;FOO&#34;</span>`).MatchString(buf.String()))
}

func TestWrapLongLines(t *testing.T) {
Expand All @@ -156,7 +157,7 @@ func TestWrapLongLines(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)

assert.Regexp(t, `<pre.*style=".*white-space:pre-wrap;word-break:break-word;`, buf.String())
assert.True(t, regexp.MustCompile(`<pre.*style=".*white-space:pre-wrap;word-break:break-word;`).MatchString(buf.String()))
}

func TestHighlightLines(t *testing.T) {
Expand Down Expand Up @@ -192,9 +193,9 @@ func TestPreWrapper(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)

assert.Regexp(t, "<body class=\"bg\">\n<pre.*class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"nb\">echo</span> FOO</span></span></code></pre>\n</body>\n</html>", buf.String())
assert.Regexp(t, `\.bg { .+ }`, buf.String())
assert.Regexp(t, `\.chroma { .+ }`, buf.String())
assert.True(t, regexp.MustCompile("<body class=\"bg\">\n<pre.*class=\"chroma\"><code><span class=\"line\"><span class=\"cl\"><span class=\"nb\">echo</span> FOO</span></span></code></pre>\n</body>\n</html>").MatchString(buf.String()))
assert.True(t, regexp.MustCompile(`\.bg { .+ }`).MatchString(buf.String()))
assert.True(t, regexp.MustCompile(`\.chroma { .+ }`).MatchString(buf.String()))
}

func TestLinkeableLineNumbers(t *testing.T) {
Expand Down Expand Up @@ -306,7 +307,7 @@ func TestWithPreWrapper(t *testing.T) {

t.Run("InlineCode, inline styles", func(t *testing.T) {
s := format(New(InlineCode(true)))
assert.Regexp(t, `<code style=".+?"><span style=".+?">echo</span> FOO</code>`, s)
assert.True(t, regexp.MustCompile(`<code style=".+?"><span style=".+?">echo</span> FOO</code>`).MatchString(s))
})

t.Run("Wrapper", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion formatters/tty_indexed_test.go
Expand Up @@ -3,8 +3,8 @@ package formatters
import (
"testing"

assert "github.com/alecthomas/assert/v2"
"github.com/alecthomas/chroma/v2"
"github.com/stretchr/testify/assert"
)

func TestClosestColour(t *testing.T) {
Expand Down
10 changes: 3 additions & 7 deletions go.mod
@@ -1,15 +1,11 @@
module github.com/alecthomas/chroma/v2

go 1.17
go 1.19

require (
github.com/alecthomas/assert/v2 v2.2.0
github.com/alecthomas/repr v0.1.0
github.com/dlclark/regexp2 v1.4.0
github.com/stretchr/testify v1.8.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
require github.com/hexops/gotextdiff v1.0.3 // indirect
19 changes: 4 additions & 15 deletions go.sum
@@ -1,19 +1,8 @@
github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw=
github.com/alecthomas/assert/v2 v2.2.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
12 changes: 6 additions & 6 deletions lexer_test.go
Expand Up @@ -3,13 +3,13 @@ package chroma
import (
"testing"

"github.com/stretchr/testify/require"
assert "github.com/alecthomas/assert/v2"
)

func TestTokenTypeClassifiers(t *testing.T) {
require.True(t, GenericDeleted.InCategory(Generic))
require.True(t, LiteralStringBacktick.InSubCategory(String))
require.Equal(t, LiteralStringBacktick.String(), "LiteralStringBacktick")
assert.True(t, GenericDeleted.InCategory(Generic))
assert.True(t, LiteralStringBacktick.InSubCategory(String))
assert.Equal(t, LiteralStringBacktick.String(), "LiteralStringBacktick")
}

func TestSimpleLexer(t *testing.T) {
Expand All @@ -30,7 +30,7 @@ func TestSimpleLexer(t *testing.T) {
[section]
a = 10
`)
require.NoError(t, err)
assert.NoError(t, err)
expected := []Token{
{Whitespace, "\n\t"},
{Comment, "; this is a comment"},
Expand All @@ -44,5 +44,5 @@ func TestSimpleLexer(t *testing.T) {
{LiteralString, "10"},
{Whitespace, "\n"},
}
require.Equal(t, expected, actual)
assert.Equal(t, expected, actual)
}
2 changes: 1 addition & 1 deletion lexers/cpp_test.go
Expand Up @@ -3,7 +3,7 @@ package lexers_test
import (
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"

"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
Expand Down
2 changes: 1 addition & 1 deletion lexers/go_test.go
Expand Up @@ -3,8 +3,8 @@ package lexers
import (
"testing"

assert "github.com/alecthomas/assert/v2"
"github.com/alecthomas/chroma/v2"
"github.com/stretchr/testify/assert"
)

func TestGoHTMLTemplateIssue126(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion lexers/lexer_benchmark_test.go
Expand Up @@ -3,7 +3,7 @@ package lexers_test
import (
"testing"

"github.com/stretchr/testify/assert"
assert "github.com/alecthomas/assert/v2"

"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
Expand Down
13 changes: 6 additions & 7 deletions lexers/lexers_test.go
Expand Up @@ -9,9 +9,8 @@ import (
"strings"
"testing"

assert "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/formatters"
Expand Down Expand Up @@ -50,11 +49,11 @@ func TestGlobs(t *testing.T) {
config := lexer.Config()
for _, glob := range config.Filenames {
_, err := filepath.Match(glob, filename)
require.NoError(t, err)
assert.NoError(t, err)
}
for _, glob := range config.AliasFilenames {
_, err := filepath.Match(glob, filename)
require.NoError(t, err)
assert.NoError(t, err)
}
}
}
Expand Down Expand Up @@ -110,7 +109,7 @@ func TestLexers(t *testing.T) {
if file.IsDir() {
dirname := filepath.Join("testdata", file.Name())
lexer := lexers.Get(file.Name())
assert.NotNil(t, lexer)
assert.NotZero(t, lexer)

subFiles, err := ioutil.ReadDir(dirname)
assert.NoError(t, err)
Expand All @@ -135,7 +134,7 @@ func TestLexers(t *testing.T) {

base := strings.Split(strings.TrimSuffix(file.Name(), filepath.Ext(file.Name())), ".")[0]
lexer := lexers.Get(base)
assert.NotNil(t, lexer, base)
assert.NotZero(t, lexer, base)

filename := filepath.Join("testdata", file.Name())
expectedFilename := strings.TrimSuffix(filename, filepath.Ext(filename)) + ".expected"
Expand Down Expand Up @@ -187,7 +186,7 @@ func TestLexersTextAnalyser(t *testing.T) {
lexerName := strings.Split(baseFilename, ".")[0]

lexer := lexers.Get(lexerName)
assert.NotNil(t, lexer, "no lexer found for name %q", lexerName)
assert.NotZero(t, lexer, "no lexer found for name %q", lexerName)

expectedFilepath := "testdata/analysis/" + baseFilename + ".expected"

Expand Down

0 comments on commit 40b7a91

Please sign in to comment.