More documentation example testing.
This commit is contained in:
parent
3e87e010fb
commit
070a215ac3
|
|
@ -18,15 +18,44 @@ func ExampleItemType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleError() {
|
func ExampleError() {
|
||||||
error := parsekit.Error{
|
err := &parsekit.Error{
|
||||||
Message: "it broke down",
|
Message: "it broke down",
|
||||||
Line: 10,
|
Line: 10,
|
||||||
Column: 42}
|
Column: 42,
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(error.Error())
|
fmt.Println(err.Error())
|
||||||
fmt.Println(error.ErrorFull())
|
fmt.Printf("%s\n", err)
|
||||||
|
fmt.Println(err.ErrorFull())
|
||||||
// Output:
|
// Output:
|
||||||
// it broke down
|
// it broke down
|
||||||
|
// it broke down
|
||||||
|
// it broke down after line 10, column 42
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExampleError_Error() {
|
||||||
|
err := &parsekit.Error{
|
||||||
|
Message: "it broke down",
|
||||||
|
Line: 10,
|
||||||
|
Column: 42,
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
fmt.Printf("%s\n", err)
|
||||||
|
// Output:
|
||||||
|
// it broke down
|
||||||
|
// it broke down
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExampleError_ErrorFull() {
|
||||||
|
err := &parsekit.Error{
|
||||||
|
Message: "it broke down",
|
||||||
|
Line: 10,
|
||||||
|
Column: 42,
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(err.ErrorFull())
|
||||||
|
// Output:
|
||||||
// it broke down after line 10, column 42
|
// it broke down after line 10, column 42
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,7 @@ func (err *Error) Error() string {
|
||||||
// ErrorFull returns the current error message, including information about
|
// ErrorFull returns the current error message, including information about
|
||||||
// the position in the input where the error occurred.
|
// the position in the input where the error occurred.
|
||||||
func (err *Error) ErrorFull() string {
|
func (err *Error) ErrorFull() string {
|
||||||
message := err.Error()
|
return fmt.Sprintf("%s after line %d, column %d", err, err.Line, err.Column)
|
||||||
return fmt.Sprintf("%s after line %d, column %d", message, err.Line, err.Column)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmitError emits a Parser error item to the client.
|
// EmitError emits a Parser error item to the client.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue