-
Notifications
You must be signed in to change notification settings - Fork 375
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
feat(examples): improve p/demo/ufmt #2553
Merged
Merged
+154
−13
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
grepsuzette
commented
Jul 9, 2024
•
edited
Loading
edited
- support for stringer, error
- support for %c verb
- allow to show value as in Go fmt.Sprintf
- allow to show verb/type mismatches as in Go fmt.Sprintf
- add some tests
grepsuzette
requested review from
ajnavarro and
zivkovicmilos
and removed request for
a team
July 9, 2024 07:38
grepsuzette
added a commit
to grepsuzette/gno
that referenced
this pull request
Jul 9, 2024
- add p/demo/tictactoe (basically @moul's model gnolang#613) - add p/demo/tictactoe1p (human VS cpu logic, extending the above) - add p/demo/ternary (to cope w/ not having C `a ? b : c` ternary operator) - add r/demo/games (start addressing gnolang#611) - add r/demo/games/tictactoe This last realm is a playable demo against a parrot which, somehow learned how to play Tic-tac-toe. This is a stateless realm which uses gnoweb as a webserver and uses css to offer a game-like experience without javascript. this depends on gnolang#2553 (improved ufmt)
thehowl
approved these changes
Jul 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits
There's a failing test, line 1722 -> Draft: Details
|
grepsuzette
force-pushed
the
improve_ufmt
branch
4 times, most recently
from
July 10, 2024 11:49
ccdead5
to
deeee75
Compare
* 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
This line // {"error: %s", []interface{}{errorToBePrinted}, "error: can I be printed?"}, gave panic: reflect: reflect.Value.SetString using value obtained using unexported field Seems to have to do with the for loop using []interface{} and what was being done in the body of the for. in gnovm/stdlibs/error, exporting s in errorString fixed the error: type errorString struct { S /* <- this */ string } But moved the test in its own function, this passes: ``` 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) } } ```
grepsuzette
force-pushed
the
improve_ufmt
branch
from
July 10, 2024 23:48
f473be3
to
b9c31a5
Compare
moul
approved these changes
Jul 11, 2024
gfanton
pushed a commit
to gfanton/gno
that referenced
this pull request
Jul 23, 2024
Co-authored-by: grepsuzette <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.