Skip to content

Commit a8d6e30

Browse files
committed
fix some code block intentions
1 parent 15dcc61 commit a8d6e30

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

assert/assert.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,17 @@ const (
159159
// be called at the beginning of every test. There is two way of doing it:
160160
//
161161
// for _, tt := range tests {
162-
// t.Run(tt.name, func(t *testing.T) { // Shorter way, litle magic
163-
// defer assert.PushTester(t)() // <- IMPORTANT! NOTE! (t)()
164-
// ...
165-
// assert.That(something, "test won't work")
166-
// })
167-
// t.Run(tt.name, func(t *testing.T) { // Longer, explicit way, 2 lines
168-
// assert.PushTester(t) // <- IMPORTANT!
169-
// defer assert.PopTester()
170-
// ...
171-
// assert.That(something, "test won't work")
172-
// })
162+
// t.Run(tt.name, func(t *testing.T) { // Shorter way, litle magic
163+
// defer assert.PushTester(t)() // <- IMPORTANT! NOTE! (t)()
164+
// ...
165+
// assert.That(something, "test won't work")
166+
// })
167+
// t.Run(tt.name, func(t *testing.T) { // Longer, explicit way, 2 lines
168+
// assert.PushTester(t) // <- IMPORTANT!
169+
// defer assert.PopTester()
170+
// ...
171+
// assert.That(something, "test won't work")
172+
// })
173173
// }
174174
//
175175
// Because PushTester returns [PopTester] it allows us to merge these two calls
@@ -184,8 +184,8 @@ const (
184184
// defer assert.PushTester(t)() // does the cleanup
185185
// ...
186186
// go func() {
187-
// assert.PushTester(t) // left cleanup out! Leave it for the test, see ^
188-
// ...
187+
// assert.PushTester(t) // left cleanup out! Leave it for the test, see ^
188+
// ...
189189
//
190190
// Note that the second argument, if given, changes the default asserter for
191191
// whole package. The argument is mainly for temporary development use and isn't
@@ -209,12 +209,12 @@ func PushTester(t testing.TB, a ...defInd) function {
209209
// You have two ways to call [PopTester]. With defer right after [PushTester]:
210210
//
211211
// for _, tt := range tests {
212-
// t.Run(tt.name, func(t *testing.T) {
213-
// assert.PushTester(t) // <- important!
214-
// defer assert.PopTester() // <- for good girls and not so bad boys
215-
// ...
216-
// assert.That(something, "test won't work")
217-
// })
212+
// t.Run(tt.name, func(t *testing.T) {
213+
// assert.PushTester(t) // <- important!
214+
// defer assert.PopTester() // <- for good girls and not so bad boys
215+
// ...
216+
// assert.That(something, "test won't work")
217+
// })
218218
// }
219219
//
220220
// If you want, you can combine [PushTester] and PopTester to one-liner:
@@ -853,7 +853,7 @@ func current() asserter {
853853
// and set asserter only one in TestMain, or in init.
854854
//
855855
// func TestMain(m *testing.M) {
856-
// SetDefault(assert.TestFull)
856+
// SetDefault(assert.TestFull)
857857
func SetDefault(i defInd) (old defInd) {
858858
// pkg lvl lock to allow only one pkg client call this at one of the time
859859
// together with the indexing, i.e we don't need to switch asserter

assert/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ assertion line is written more from a runtime detection point of view, it catche
2222
all assert violations in the unit tests as well:
2323
2424
func (c Chain) Invite(...) {
25-
assert.That(c.isLeaf(invitersKey), "only leaf can invite")
25+
assert.That(c.isLeaf(invitersKey), "only leaf can invite")
2626
2727
If some assertion violation occurs in the deep call stack, they are still
2828
reported as a test failure. See the above code blocks. If assertion failure

err2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ var Stdnull = &nullDev{}
9191
// a panic handler. See the second handler below:
9292
//
9393
// defer err2.Handle(&err,
94-
// err2.Err( func(error) { os.Remove(dst) }), // err2.Err() keeps it short
95-
// // below handler catches panics, but you can re-throw if needed
96-
// func(p any) {}
94+
// err2.Err( func(error) { os.Remove(dst) }), // err2.Err() keeps it short
95+
// // below handler catches panics, but you can re-throw if needed
96+
// func(p any) {}
9797
// )
9898
func Handle(err *error, a ...any) {
9999
// This and others are similar but we need to call `recover` here because

handlers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// You can use it like this:
1515
//
1616
// func main() {
17-
// defer err2.Catch(err2.Stderr)
17+
// defer err2.Catch(err2.Stderr)
1818
func Stderr(err error) error {
1919
if err == nil {
2020
return nil
@@ -30,7 +30,7 @@ func Stderr(err error) error {
3030
// You can use it like this:
3131
//
3232
// func main() {
33-
// defer err2.Catch(err2.Stdout)
33+
// defer err2.Catch(err2.Stdout)
3434
func Stdout(err error) error {
3535
if err == nil {
3636
return nil
@@ -57,7 +57,7 @@ func Reset(error) error { return nil }
5757
// and don't want to use [SetLogTracer] and keep it to write to your logs.
5858
//
5959
// defer err2.Catch(err2.Err(func(err error) {
60-
// fmt.Println("ERROR:", err)
60+
// fmt.Println("ERROR:", err)
6161
// }))
6262
//
6363
// Note that since Err helper we have other helpers like [Stdout] that allows
@@ -89,7 +89,7 @@ func Log(err error) error {
8989
// You can use it like this:
9090
//
9191
// func myFunction() {
92-
// defer err2.Handle(err2.Noop, err2.StderrNoReset)
92+
// defer err2.Handle(err2.Noop, err2.StderrNoReset)
9393
func StderrNoReset(err error) error {
9494
if err == nil {
9595
return nil
@@ -104,7 +104,7 @@ func StderrNoReset(err error) error {
104104
// You can use it like this:
105105
//
106106
// func main() {
107-
// defer err2.Catch(err2.StdoutNoReset)
107+
// defer err2.Catch(err2.StdoutNoReset)
108108
func StdoutNoReset(err error) error {
109109
if err == nil {
110110
return nil

0 commit comments

Comments
 (0)