Errors no longer directly depends on testcommon
This commit is contained in:
parent
334a45e06f
commit
293662e474
|
@ -1,55 +1,6 @@
|
|||
package errors
|
||||
|
||||
import "testing"
|
||||
import "strings"
|
||||
|
||||
func TestError (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:7: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^`,
|
||||
Errorf (
|
||||
Position {
|
||||
File: "example.fspl",
|
||||
Line: "lorem ipsum dolor",
|
||||
Row: 10,
|
||||
Start: 6,
|
||||
End: 11,
|
||||
},
|
||||
"some error"))
|
||||
}
|
||||
|
||||
func TestErrorTab (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:8: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^`,
|
||||
Errorf (
|
||||
Position {
|
||||
File: "example.fspl",
|
||||
Line: "\tlorem\tipsum\tdolor",
|
||||
Row: 10,
|
||||
Start: 7,
|
||||
End: 12,
|
||||
},
|
||||
"some error"))
|
||||
}
|
||||
|
||||
func TestErrorTabInBetween (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:8: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^^^^^`,
|
||||
Errorf (
|
||||
Position {
|
||||
File: "example.fspl",
|
||||
Line: "\tlorem\tipsum\tdolor",
|
||||
Row: 10,
|
||||
Start: 7,
|
||||
End: 14,
|
||||
},
|
||||
"some error"))
|
||||
}
|
||||
|
||||
func TestGetXInTabbedString (test *testing.T) {
|
||||
getXCase := func (line string, column, correct int) {
|
||||
|
@ -69,7 +20,6 @@ func TestGetXInTabbedString (test *testing.T) {
|
|||
getXCase("x\tyyyy\tzy", 7, 16)
|
||||
}
|
||||
|
||||
|
||||
func TestFormatTabs (test *testing.T) {
|
||||
fmtCase := func (line string, correct string) {
|
||||
got := formatTabs(line)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package errors
|
||||
package errorstest
|
||||
|
||||
import "testing"
|
||||
import "git.tebibyte.media/fspl/fspl/errors"
|
||||
import "git.tebibyte.media/fspl/fspl/testcommon"
|
||||
|
||||
func testString (test *testing.T, correct string, got string) {
|
||||
|
@ -11,6 +12,6 @@ func testString (test *testing.T, correct string, got string) {
|
|||
testcommon.Compare(test, correct, got)
|
||||
}
|
||||
|
||||
func testError (test *testing.T, correct string, err Error) {
|
||||
testString(test, correct, Format(err))
|
||||
func testError (test *testing.T, correct string, err errors.Error) {
|
||||
testString(test, correct, errors.Format(err))
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package errorstest
|
||||
|
||||
import "testing"
|
||||
import "git.tebibyte.media/fspl/fspl/errors"
|
||||
|
||||
func TestError (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:7: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^`,
|
||||
errors.Errorf (
|
||||
errors.Position {
|
||||
File: "example.fspl",
|
||||
Line: "lorem ipsum dolor",
|
||||
Row: 10,
|
||||
Start: 6,
|
||||
End: 11,
|
||||
},
|
||||
"some error"))
|
||||
}
|
||||
|
||||
func TestErrorTab (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:8: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^`,
|
||||
errors.Errorf (
|
||||
errors.Position {
|
||||
File: "example.fspl",
|
||||
Line: "\tlorem\tipsum\tdolor",
|
||||
Row: 10,
|
||||
Start: 7,
|
||||
End: 12,
|
||||
},
|
||||
"some error"))
|
||||
}
|
||||
|
||||
func TestErrorTabInBetween (test *testing.T) {
|
||||
testError (test,
|
||||
`example.fspl:11:8: some error
|
||||
11 | lorem ipsum dolor
|
||||
^^^^^^^^^`,
|
||||
errors.Errorf (
|
||||
errors.Position {
|
||||
File: "example.fspl",
|
||||
Line: "\tlorem\tipsum\tdolor",
|
||||
Row: 10,
|
||||
Start: 7,
|
||||
End: 14,
|
||||
},
|
||||
"some error"))
|
||||
}
|
Loading…
Reference in New Issue