Skip to content

Commit

Permalink
Treat offset Z and +0000 as identical
Browse files Browse the repository at this point in the history
For Z the Zoneinfo name is set to UTC, but for +0000 it just sets the
offset (but not the Zoneinfo name). reflect.DeepEqual() would consider
these different.
  • Loading branch information
arp242 committed Oct 10, 2023
1 parent 3796541 commit ccc1f0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func (r Runner) Run() (Tests, error) {
if err != nil {
return Tests{}, fmt.Errorf("tomltest.Runner.Run: %w", err)
}
if r.Parallel == 0 {
r.Parallel = 1
}

var (
tests = Tests{
Expand All @@ -168,7 +171,9 @@ func (r Runner) Run() (Tests, error) {
invalid := strings.Contains(p, "invalid/")
if r.hasSkip(p) {
tests.Skipped++
mu.Lock()
tests.Tests = append(tests.Tests, Test{Path: p, Skipped: true, Encoder: r.Encoder})
mu.Unlock()
continue
}

Expand Down
9 changes: 9 additions & 0 deletions toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"
"reflect"
"strings"
"time"
)

// CompareTOML compares the given arguments.
Expand Down Expand Up @@ -129,6 +130,14 @@ func deepEqual(want, have any) bool {
return true
}

// Time.Equal deals with some edge-cases such as offset +0000 and Z being
// identical.
if haveT, ok := have.(time.Time); ok {
if wantT, ok := want.(time.Time); ok {
return wantT.Equal(haveT)
}
}

return reflect.DeepEqual(want, have)
}

Expand Down

0 comments on commit ccc1f0b

Please sign in to comment.