test: add FBIP and RC verification test cases

Add test cases demonstrating FBIP (Functional But In-Place) optimization:
- test_fbip_clean.lux: Basic FBIP chain (map, filter, reverse)
- test_fbip_allocs.lux: Single-owner allocation test with range/map/filter/reverse
- test_no_fbip.lux: Demonstrates shared reference forcing rc>1 path
- test_rc_comparison.lux: Comparison of FBIP vs non-FBIP allocations

All tests verify no memory leaks with the RC system.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 14:44:53 -05:00
parent 4d5a975b79
commit 771512a2ec
4 changed files with 63 additions and 0 deletions

20
examples/test_no_fbip.lux Normal file
View File

@@ -0,0 +1,20 @@
// Test WITHOUT FBIP by forcing rc>1 (shared reference)
fn useList(l: List<Int>): Int = {
List.length(l)
}
fn main(): Unit = {
Console.print("=== Without FBIP (forced rc>1) ===")
let a = List.range(1, 100)
// Create alias to bump rc, preventing FBIP
let alias = a
let len1 = useList(alias)
// Now 'a' has rc>1 so map must allocate new list
let b = List.map(a, fn(x: Int): Int => x * 2)
let c = List.filter(b, fn(x: Int): Bool => x > 50)
let d = List.reverse(c)
Console.print("Shared reference chain done")
}