injectMismatchedCloser swaps a closing '}' for ']' (or vice versa). The grammar generator always pairs '{' with '}' and '[' with ']'; this operator produces the cross-type mismatch class ([{...}] → [{...]}) that stresses blockEnd's open/close pairing logic.
(r *rand.Rand, data []byte)
| 909 | // operator produces the cross-type mismatch class ([{...}] → [{...]}) that |
| 910 | // stresses blockEnd's open/close pairing logic. |
| 911 | func injectMismatchedCloser(r *rand.Rand, data []byte) []byte { |
| 912 | closers := findStructuralBytes(data, '}', ']') |
| 913 | if len(closers) == 0 { |
| 914 | return data |
| 915 | } |
| 916 | idx := closers[r.Intn(len(closers))] |
| 917 | out := make([]byte, len(data)) |
| 918 | copy(out, data) |
| 919 | if out[idx] == '}' { |
| 920 | out[idx] = ']' |
| 921 | } else { |
| 922 | out[idx] = '}' |
| 923 | } |
| 924 | return out |
| 925 | } |
| 926 | |
| 927 | // ============================================================================= |
| 928 | // Adversarial key-path generator |
nothing calls this directly
no test coverage detected