Skip to content

Commit 6f87494

Browse files
committed
Add recursiveSliceCycle case
1 parent d80d86b commit 6f87494

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/encoding/json/encode_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ type PointerCycleIndirect struct {
183183
Ptrs []interface{}
184184
}
185185

186+
type RecursiveSlice []RecursiveSlice
187+
186188
var (
187189
pointerCycleIndirect = &PointerCycleIndirect{}
188190
mapCycle = make(map[string]interface{})
189191
sliceCycle = []interface{}{nil}
190192
sliceNoCycle = []interface{}{nil, nil}
193+
recursiveSliceCycle = []RecursiveSlice{nil}
191194
)
192195

193196
func init() {
@@ -204,6 +207,7 @@ func init() {
204207
for i := startDetectingCyclesAfter; i > 0; i-- {
205208
sliceNoCycle = []interface{}{sliceNoCycle}
206209
}
210+
recursiveSliceCycle[0] = recursiveSliceCycle
207211
}
208212

209213
func TestSamePointerNoCycle(t *testing.T) {
@@ -226,6 +230,7 @@ var unsupportedValues = []interface{}{
226230
pointerCycleIndirect,
227231
mapCycle,
228232
sliceCycle,
233+
recursiveSliceCycle,
229234
}
230235

231236
func TestUnsupportedValues(t *testing.T) {

0 commit comments

Comments
 (0)