TestPutExpressionNestedDeep tests deeply nested expressions
(t *testing.T)
| 259 | |
| 260 | // TestPutExpressionNestedDeep tests deeply nested expressions |
| 261 | func TestPutExpressionNestedDeep(t *testing.T) { |
| 262 | // Create a moderately nested binary expression tree |
| 263 | var createNested func(depth int) Expression |
| 264 | createNested = func(depth int) Expression { |
| 265 | if depth == 0 { |
| 266 | return &Identifier{Name: "leaf"} |
| 267 | } |
| 268 | return &BinaryExpression{ |
| 269 | Left: createNested(depth - 1), |
| 270 | Right: createNested(depth - 1), |
| 271 | Operator: "+", |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | // Test with various depths |
| 276 | for _, depth := range []int{5, 10, 15} { |
| 277 | t.Run("depth_"+string(rune('0'+depth/10))+string(rune('0'+depth%10)), func(t *testing.T) { |
| 278 | expr := createNested(depth) |
| 279 | PutExpression(expr) // Should not stack overflow |
| 280 | }) |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | // TestSpanMethods tests Span() methods on various AST nodes |
| 285 | func TestSpanMethods(t *testing.T) { |
nothing calls this directly
no test coverage detected