Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failing test about error. rewrite Sprintf to iterate over runes, rather then doing C-for #1

Open
wants to merge 6 commits into
base: improve_ufmt
Choose a base branch
from

Conversation

grepsuzette
Copy link
Owner

No description provided.

* support for stringer, error
* support for %c verb
* allow to show <nil> value as in Go fmt.Sprintf
* allow to show verb/type mismatches as in Go fmt.Sprintf
* add tests
…rather then doing C-for

There was a weird bug...

// {"error: %s", []interface{}{errorToBePrinted}, "error: can I be printed?"},
// ^ BUG panic: reflect: reflect.Value.SetString using value obtained using unexported field

Basically think it had to do with the for loop using []interface{} and
what was being done in the body of the for. The only way was to export

type errorString struct { S /* <- this */ string }

in gnovm/stdlibs/error, or to move the test about error in their own
function; this works:

```
func TestPrintErrors(t *testing.T) {
	got := Sprintf("error: %s", errors.New("can I be printed?"))
	expectedOutput := "error: can I be printed?"
	if got != expectedOutput {
		t.Errorf("got %q, want %q.", got, expectedOutput)
	}
}
```
* support for stringer, error
* support for %c verb
* allow to show <nil> value as in Go fmt.Sprintf
* allow to show verb/type mismatches as in Go fmt.Sprintf
* add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant