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_fbip_allocs.lux
Normal file
17
examples/test_fbip_allocs.lux
Normal file
@@ -0,0 +1,17 @@
|
||||
// This test shows FBIP optimization by comparing allocation counts
|
||||
// With FBIP (rc=1): lists are reused in-place
|
||||
// Without FBIP (rc>1): new lists are allocated
|
||||
|
||||
fn main(): Unit = {
|
||||
Console.print("=== FBIP Allocation Test ===")
|
||||
|
||||
// Case 1: Single owner (FBIP active) - should reuse list
|
||||
let a = List.range(1, 100)
|
||||
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("Single owner chain done")
|
||||
|
||||
// The allocation count will show FBIP is working
|
||||
// if allocations are low relative to operations performed
|
||||
}
|
||||
Reference in New Issue
Block a user