Skip to content

Commit 5584cfa

Browse files
committed
more documentation
1 parent 4a7bc51 commit 5584cfa

File tree

6 files changed

+33
-15
lines changed

6 files changed

+33
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
### Version history
44

5+
##### 0.9.5 **mistake in build number: 5 < 41**
6+
- `flag` package support to set `err2` and `assert` package configuration
7+
- `err2.Catch` default mode is to log error
8+
- cleanup and refactoring, new tests and benchmarks
9+
510
##### 0.9.41
611
- Issue #18: **bug fixed**: noerr-handler had to be the last one of the err2
712
handlers

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ Please see the full version history from [CHANGELOG](./CHANGELOG.md).
527527
528528
### Latest Release
529529
530-
##### 0.9.5
530+
##### 0.9.51
531531
- `flag` package support to set `err2` and `assert` package configuration
532532
- `err2.Catch` default mode is to log error
533533
- cleanup and refactoring, new tests and benchmarks

assert/assert.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
type defInd = uint32
1818

1919
const (
20-
// Plain converts asserts just plain error messages without extra
20+
// Plain converts asserts just plain K&D error messages without extra
2121
// information.
2222
Plain defInd = 0 + iota
2323

@@ -68,8 +68,12 @@ const (
6868
// output properly and allow traverse of locations of the error trace.
6969
TestFull
7070

71-
// Debug asserter transforms assertion violations to panics which is the
72-
// pattern that e.g. Go's standard library uses:
71+
// Debug asserter transforms assertion violations to panic calls where
72+
// panic object's type is string, i.e., err2 package treats it as a normal
73+
// panic, not an error.
74+
//
75+
// The pattern that e.g. Go's standard
76+
// library uses:
7377
//
7478
// if p == nil {
7579
// panic("pkg: ptr cannot be nil")

assert/doc.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,23 @@ The assert package supports Go's flags. All you need to do is to call flag.Parse
5858
And the following flags are supported (="default-value"):
5959
6060
-asserter="Prod"
61-
A name of the asserter Plain, Prod, Dev, Debug (see constants)
61+
A name of the asserter Plain, Prod, Dev, Debug
62+
See more information from constants: Plain, Production, Development, Debug
6263
6364
And assert package's configuration flags are inserted.
6465
65-
Note. assert.That's performance is equal to the if-statement. Most of the
66-
generics-based versions are almost as fast. If your algorithm is
67-
performance-critical please run `make bench` in the err2 repo and decide case by
68-
case. Also you can make an issue or even PR if you would like to have something
69-
similar like glog.V() function.
66+
# Performance
7067
71-
Note. Format string functions need to be own instances because of Go's vet and
72-
test tool integration.
68+
assert.That's performance is equal to the if-statement thanks for inlining. And
69+
the most of the generics-based versions are about the equally fast.
70+
71+
If your algorithm is performance-critical please run `make bench` in the err2
72+
repo and decide case by case. Also you can make an issue or even PR if you would
73+
like to have something similar like glog.V() function.
74+
75+
# Technical Notes
76+
77+
Format string functions need to be own instances because of Go's vet and test
78+
tool integration.
7379
*/
7480
package assert

err2_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ func doWork(ePtr *error, r any) {
912912
}
913913
}
914914

915+
// Next benchmark is only for internal test for trying to reproduce Go compilers
916+
// missing optimization behavior.
917+
915918
func BenchmarkRecursionWithTryAnd_HeavyPtrPtr_Defer(b *testing.B) {
916919
var recursion func(a int) (r int, err error)
917920
recursion = func(a int) (r int, err error) {

internal/test/test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import (
55
"testing"
66
)
77

8-
// require fails the test if the condition is false.
8+
// Require fails the test if the condition is false.
99
func Require(tb testing.TB, condition bool, v ...interface{}) {
1010
tb.Helper()
1111
if !condition {
1212
tb.Fatal(v...)
1313
}
1414
}
1515

16-
// require fails the test if the condition is false.
16+
// Requiref fails the test if the condition is false.
1717
func Requiref(tb testing.TB, condition bool, format string, v ...interface{}) {
1818
tb.Helper()
1919
if !condition {
2020
tb.Fatalf(format, v...)
2121
}
2222
}
2323

24-
// requireEqual fails the test if the values aren't equal
24+
// RequireEqual fails the test if the values aren't equal
2525
func RequireEqual[T comparable](tb testing.TB, val, want T, a ...any) {
2626
tb.Helper()
2727
if want != val {

0 commit comments

Comments
 (0)