test: add RC stress tests with large lists

- stress_rc.lux: Single-owner chains testing FBIP optimization
- stress_shared_rc.lux: Shared-reference chains (rc>1) forcing copy path

Both process lists of 100, 200, 500, and 1000 elements with map/filter/reverse.
Verifies no memory leaks with large data sets.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 14:46:21 -05:00
parent 771512a2ec
commit 25a3adf4fc
2 changed files with 50 additions and 0 deletions

24
examples/stress_rc.lux Normal file
View File

@@ -0,0 +1,24 @@
// Stress test for RC system with large lists
// Tests FBIP optimization with single-owner chains
fn processChain(n: Int): Int = {
// Single owner chain - FBIP should reuse lists
let nums = List.range(1, n)
let doubled = List.map(nums, fn(x: Int): Int => x * 2)
let filtered = List.filter(doubled, fn(x: Int): Bool => x > n)
let reversed = List.reverse(filtered)
List.length(reversed)
}
fn main(): Unit = {
Console.print("=== RC Stress Test ===")
// Run multiple iterations of list operations
let result1 = processChain(100)
let result2 = processChain(200)
let result3 = processChain(500)
let result4 = processChain(1000)
Console.print("Completed 4 chains")
Console.print("Sizes: 100, 200, 500, 1000")
}