injectPathHazard randomly injects an adversarial path component into an existing path. This implements the injectEmptyKeyComponent and injectOobArrayIndex operators from the spec.
(r *rand.Rand, path []string)
| 975 | // existing path. This implements the injectEmptyKeyComponent and |
| 976 | // injectOobArrayIndex operators from the spec. |
| 977 | func injectPathHazard(r *rand.Rand, path []string) []string { |
| 978 | switch r.Intn(3) { |
| 979 | case 0: // injectEmptyKeyComponent — append "" to the path |
| 980 | out := make([]string, len(path)+1) |
| 981 | copy(out, path) |
| 982 | out[len(path)] = "" |
| 983 | return out |
| 984 | case 1: // injectOobArrayIndex — append "[99]" to the path |
| 985 | out := make([]string, len(path)+1) |
| 986 | copy(out, path) |
| 987 | out[len(path)] = "[99]" |
| 988 | return out |
| 989 | default: // replace with a grammar-generated adversarial path |
| 990 | return genKeyPath(r) |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | // ============================================================================= |
| 995 | // Enhanced path-shape checker (catches nested D6 divergences) |
no test coverage detected