ceremonyclient/bedlam/compiler/errors_test.go
Cassandra Heart dbd95bd9e9
v2.1.0 (#439)
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete

* 2.1.0 main node rollup
2025-09-30 02:48:15 -05:00

37 lines
962 B
Go

package compiler
import (
"fmt"
"testing"
"source.quilibrium.com/quilibrium/monorepo/bedlam/compiler/utils"
)
func TestCompileError(t *testing.T) {
t.Run("test compile error message without location", func(t *testing.T) {
err := CompileError{
Stage: CompileStageParse,
SourcePos: "file:1:1",
Err: fmt.Errorf("error message"),
}
want := "Compile error [parse]: error message\nfile:1:1"
got := err.Error()
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("test compile error message with location", func(t *testing.T) {
err := CompileError{
Stage: CompileStageParse,
SourcePos: "func main(a, b int4 int4",
Location: &utils.Point{Source: "file", Line: 1, Col: 1},
Err: fmt.Errorf("error message"),
}
want := "Compile error [parse]: error message, file:1:1\nfunc main(a, b int4 int4"
got := err.Error()
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
}