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:
17
examples/test_rc_comparison.lux
Normal file
17
examples/test_rc_comparison.lux
Normal file
@@ -0,0 +1,17 @@
|
||||
fn main(): Unit = {
|
||||
Console.print("=== Allocation Comparison ===")
|
||||
|
||||
// FBIP path (rc=1): list is reused
|
||||
Console.print("Test 1: FBIP path")
|
||||
let a1 = List.range(1, 50)
|
||||
let b1 = List.map(a1, fn(x: Int): Int => x * 2)
|
||||
let c1 = List.reverse(b1)
|
||||
Console.print("FBIP done")
|
||||
|
||||
// To show non-FBIP, we need concat which doesn't have FBIP
|
||||
Console.print("Test 2: Non-FBIP path (concat)")
|
||||
let x = List.range(1, 25)
|
||||
let y = List.range(26, 50)
|
||||
let z = List.concat(x, y) // concat always allocates new
|
||||
Console.print("Concat done")
|
||||
}
|
||||
Reference in New Issue
Block a user