mirror of
https://github.com/hanzoai/esbuild.git
synced 2026-09-24 16:58:50 +00:00
37 lines
860 B
Go
37 lines
860 B
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/evanw/esbuild/internal/fs"
|
|
"github.com/evanw/esbuild/internal/logger"
|
|
)
|
|
|
|
func AssertEqual(t *testing.T, observed interface{}, expected interface{}) {
|
|
t.Helper()
|
|
if observed != expected {
|
|
t.Fatalf("%s != %s", observed, expected)
|
|
}
|
|
}
|
|
|
|
func AssertEqualWithDiff(t *testing.T, observed interface{}, expected interface{}) {
|
|
t.Helper()
|
|
if observed != expected {
|
|
stringA := fmt.Sprintf("%v", observed)
|
|
stringB := fmt.Sprintf("%v", expected)
|
|
color := !fs.CheckIfWindows()
|
|
t.Fatal("\n" + diff(stringB, stringA, color))
|
|
}
|
|
}
|
|
|
|
func SourceForTest(contents string) logger.Source {
|
|
return logger.Source{
|
|
Index: 0,
|
|
KeyPath: logger.Path{Text: "<stdin>"},
|
|
PrettyPaths: logger.PrettyPaths{Abs: "<stdin>", Rel: "<stdin>"},
|
|
Contents: contents,
|
|
IdentifierName: "stdin",
|
|
}
|
|
}
|