1313//
1414// The primary features of cmp are:
1515//
16- // • When the default behavior of equality does not suit the needs of the test,
17- // custom equality functions can override the equality operation.
18- // For example, an equality function may report floats as equal so long as they
19- // are within some tolerance of each other.
16+ // - When the default behavior of equality does not suit the test's needs ,
17+ // custom equality functions can override the equality operation.
18+ // For example, an equality function may report floats as equal so long as
19+ // they are within some tolerance of each other.
2020//
21- // • Types that have an Equal method may use that method to determine equality.
22- // This allows package authors to determine the equality operation for the types
23- // that they define.
21+ // - Types with an Equal method may use that method to determine equality.
22+ // This allows package authors to determine the equality operation
23+ // for the types that they define.
2424//
25- // • If no custom equality functions are used and no Equal method is defined,
26- // equality is determined by recursively comparing the primitive kinds on both
27- // values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported
28- // fields are not compared by default; they result in panics unless suppressed
29- // by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly
30- // compared using the Exporter option.
25+ // - If no custom equality functions are used and no Equal method is defined,
26+ // equality is determined by recursively comparing the primitive kinds on
27+ // both values, much like reflect.DeepEqual. Unlike reflect.DeepEqual,
28+ // unexported fields are not compared by default; they result in panics
29+ // unless suppressed by using an Ignore option (see cmpopts.IgnoreUnexported)
30+ // or explicitly compared using the Exporter option.
3131package cmp
3232
3333import (
@@ -45,25 +45,25 @@ import (
4545// Equal reports whether x and y are equal by recursively applying the
4646// following rules in the given order to x and y and all of their sub-values:
4747//
48- // • Let S be the set of all Ignore, Transformer, and Comparer options that
49- // remain after applying all path filters, value filters, and type filters.
50- // If at least one Ignore exists in S, then the comparison is ignored.
51- // If the number of Transformer and Comparer options in S is greater than one ,
52- // then Equal panics because it is ambiguous which option to use.
53- // If S contains a single Transformer, then use that to transform the current
54- // values and recursively call Equal on the output values.
55- // If S contains a single Comparer, then use that to compare the current values.
56- // Otherwise, evaluation proceeds to the next rule.
48+ // - Let S be the set of all Ignore, Transformer, and Comparer options that
49+ // remain after applying all path filters, value filters, and type filters.
50+ // If at least one Ignore exists in S, then the comparison is ignored.
51+ // If the number of Transformer and Comparer options in S is non-zero ,
52+ // then Equal panics because it is ambiguous which option to use.
53+ // If S contains a single Transformer, then use that to transform
54+ // the current values and recursively call Equal on the output values.
55+ // If S contains a single Comparer, then use that to compare the current values.
56+ // Otherwise, evaluation proceeds to the next rule.
5757//
58- // • If the values have an Equal method of the form "(T) Equal(T) bool" or
59- // "(T) Equal(I) bool" where T is assignable to I, then use the result of
60- // x.Equal(y) even if x or y is nil. Otherwise, no such method exists and
61- // evaluation proceeds to the next rule.
58+ // - If the values have an Equal method of the form "(T) Equal(T) bool" or
59+ // "(T) Equal(I) bool" where T is assignable to I, then use the result of
60+ // x.Equal(y) even if x or y is nil. Otherwise, no such method exists and
61+ // evaluation proceeds to the next rule.
6262//
63- // • Lastly, try to compare x and y based on their basic kinds.
64- // Simple kinds like booleans, integers, floats, complex numbers, strings, and
65- // channels are compared using the equivalent of the == operator in Go.
66- // Functions are only equal if they are both nil, otherwise they are unequal.
63+ // - Lastly, try to compare x and y based on their basic kinds.
64+ // Simple kinds like booleans, integers, floats, complex numbers, strings,
65+ // and channels are compared using the equivalent of the == operator in Go.
66+ // Functions are only equal if they are both nil, otherwise they are unequal.
6767//
6868// Structs are equal if recursively calling Equal on all fields report equal.
6969// If a struct contains unexported fields, Equal panics unless an Ignore option
@@ -639,7 +639,9 @@ type dynChecker struct{ curr, next int }
639639// Next increments the state and reports whether a check should be performed.
640640//
641641// Checks occur every Nth function call, where N is a triangular number:
642+ //
642643// 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 ...
644+ //
643645// See https://en.wikipedia.org/wiki/Triangular_number
644646//
645647// This sequence ensures that the cost of checks drops significantly as
0 commit comments