@@ -13,26 +13,30 @@ type codeAndValue struct {
1313}
1414
1515// Code implements Matchable.
16- func (c codeAndValue ) Code () int {
16+ func (c * codeAndValue ) Code () int {
1717 return c .code
1818}
1919
2020// Value implements Matchable.
21- func (c codeAndValue ) Value () string {
21+ func (c * codeAndValue ) Value () string {
2222 return c .val
2323}
2424
2525// Bytes implements Matchable.
26- func (c codeAndValue ) Bytes () []byte {
26+ func (c * codeAndValue ) Bytes () []byte {
2727 return []byte (c .val )
2828}
2929
3030// RawValue implements Matchable.
31- func (c codeAndValue ) RawValue () []byte {
31+ func (c * codeAndValue ) RawValue () []byte {
3232 return []byte (c .val )
3333}
3434
35- var _ Matchable = codeAndValue {}
35+ var _ Matchable = & codeAndValue {}
36+
37+ func codeAndValuePtrToMatchable (c * codeAndValue ) * codeAndValue {
38+ return c
39+ }
3640
3741func TestSimple (t * testing.T ) {
3842 type testCase struct {
@@ -106,12 +110,12 @@ func TestSimple(t *testing.T) {
106110
107111 for i , tc := range testCases {
108112 for _ , m := range tc .shouldMatch {
109- if matches , err := Match (tc .pattern , codesToCodeAndValue (m )); ! matches {
113+ if matches , err := Match (tc .pattern , codesToCodeAndValue (m ), codeAndValuePtrToMatchable ); ! matches {
110114 t .Fatalf ("failed to match %v with %v. idx=%d. err=%v" , m , tc .pattern , i , err )
111115 }
112116 }
113117 for _ , m := range tc .shouldNotMatch {
114- if matches , _ := Match (tc .pattern , codesToCodeAndValue (m )); matches {
118+ if matches , _ := Match (tc .pattern , codesToCodeAndValue (m ), codeAndValuePtrToMatchable ); matches {
115119 t .Fatalf ("failed to not match %v with %v. idx=%d" , m , tc .pattern , i )
116120 }
117121 }
@@ -125,7 +129,7 @@ func TestSimple(t *testing.T) {
125129 return true
126130 }
127131 }
128- matches , _ := Match (tc .pattern , codesToCodeAndValue (notMatch ))
132+ matches , _ := Match (tc .pattern , codesToCodeAndValue (notMatch ), codeAndValuePtrToMatchable )
129133 return ! matches
130134 }, & quick.Config {}); err != nil {
131135 t .Fatal (err )
@@ -172,7 +176,7 @@ func TestCapture(t *testing.T) {
172176 _ = testCases
173177 for _ , tc := range testCases {
174178 state , assert := tc .setup ()
175- if matches , _ := Match (state , tc .parts ); ! matches {
179+ if matches , _ := Match (state , tc .parts , codeAndValuePtrToMatchable ); ! matches {
176180 t .Fatalf ("failed to match %v with %v" , tc .parts , state )
177181 }
178182 assert ()
@@ -255,7 +259,7 @@ func FuzzMatchesRegexpBehavior(f *testing.F) {
255259 return
256260 }
257261 p := PatternToMatcher (pattern ... )
258- otherMatched , _ := Match (p , bytesToCodeAndValue (corpus ))
262+ otherMatched , _ := Match (p , bytesToCodeAndValue (corpus ), codeAndValuePtrToMatchable )
259263 if otherMatched != matched {
260264 t .Log ("regexp" , string (regexpPattern ))
261265 t .Log ("corpus" , string (corpus ))
0 commit comments