(isRoot bool, rng *rand.Rand)
| 105 | func (j jsonString) subdocument(_ bool, _ *rand.Rand) JSON { return j } |
| 106 | |
| 107 | func (j jsonArray) subdocument(isRoot bool, rng *rand.Rand) JSON { |
| 108 | // Root arrays contain their scalar elements. |
| 109 | if isRoot && rng.Intn(5) == 0 { |
| 110 | idx := rng.Intn(len(j)) |
| 111 | if j[idx].isScalar() { |
| 112 | return j[idx] |
| 113 | } |
| 114 | } |
| 115 | result := make(jsonArray, 0) |
| 116 | i := 0 |
| 117 | for i < len(j) { |
| 118 | if rng.Intn(2) == 0 { |
| 119 | result = append(result, j[i].(containsTester).subdocument(false /* isRoot */, rng)) |
| 120 | } |
| 121 | if rng.Intn(2) == 0 { |
| 122 | i++ |
| 123 | } |
| 124 | } |
| 125 | // Shuffle the slice. |
| 126 | for i := range result { |
| 127 | j := rng.Intn(i + 1) |
| 128 | result[i], result[j] = result[j], result[i] |
| 129 | } |
| 130 | |
| 131 | return result |
| 132 | } |
| 133 | |
| 134 | func (j jsonObject) subdocument(_ bool, rng *rand.Rand) JSON { |
| 135 | result := make(jsonObject, 0) |
nothing calls this directly
no test coverage detected