Commit 0879819
test(audience): pin Json.Serialize depth guard and cycle detection
Both guards exist because their absence yields StackOverflowException,
which the .NET runtime does not catch — the process terminates. Neither
guard had a test. Three new tests:
- nesting one level past MaxDepth throws FormatException with "nesting
exceeds" message. Sabotage: disabling GuardDepth fails the test.
- self-referential dict throws FormatException with "cycle" message.
Sabotage: disabling the visited.Add(container) check makes the test
recurse into the depth guard and the assertion on "cycle" text fails.
- shared-child diamond (same dict in two sibling keys) is not treated as
a cycle. Sabotage: removing the post-recursion visited.Remove makes
the second sibling throw "cycle".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 47f70c2 commit 0879819
1 file changed
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
206 | 250 | | |
207 | 251 | | |
0 commit comments