phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0

This commit is contained in:
nyash-codex
2025-11-06 15:41:52 +09:00
parent 2dc370223d
commit 77d4fd72b3
1658 changed files with 6288 additions and 2612 deletions

View File

@ -0,0 +1,67 @@
// ⭐ Phase 10: Zero-copy Detection API Test
// Test the new BufferBox zero-copy methods
static box Main {
init { console }
main() {
me.console = new ConsoleBox()
me.console.log("🧪 Testing Zero-copy Detection APIs")
// Test 1: Basic buffer creation and memory footprint
local buffer1 = new BufferBox()
local buffer2 = new BufferBox()
me.console.log("Created two BufferBox instances")
// Test memory footprint API
local footprint1 = buffer1.memory_footprint()
me.console.log("Buffer1 memory footprint: " + footprint1)
// Test 2: is_shared_with() - should return false for independent buffers
local shared_check1 = buffer1.is_shared_with(buffer2)
me.console.log("Independent buffers shared: " + shared_check1)
// Test 3: share_reference() - create shared buffer
local shared_buffer = buffer1.share_reference(buffer2)
me.console.log("Created shared reference")
// Test 4: Check if shared buffer actually shares data with buffer1
local shared_check2 = buffer1.is_shared_with(shared_buffer)
me.console.log("Shared buffer shares data with buffer1: " + shared_check2)
// Test 5: Memory footprint should be similar for shared buffers
local footprint_shared = shared_buffer.memory_footprint()
me.console.log("Shared buffer memory footprint: " + footprint_shared)
// Test 6: Write data and check sharing
me.console.log("Writing data to test sharing...")
// Create test data
local test_data = new ArrayBox()
test_data.push(72) // 'H'
test_data.push(101) // 'e'
test_data.push(108) // 'l'
test_data.push(108) // 'l'
test_data.push(111) // 'o'
buffer1.write(test_data)
me.console.log("Written test data to buffer1")
local length1 = buffer1.length()
me.console.log("Buffer1 length after write: " + length1)
// Test 7: Check if shared buffer reflects the data
local shared_length = shared_buffer.length()
me.console.log("Shared buffer length: " + shared_length)
if (length1.toString() == shared_length.toString()) {
me.console.log("✅ Zero-copy sharing working correctly!")
} else {
me.console.log("❌ Zero-copy sharing failed")
}
me.console.log("🎉 Zero-copy detection test complete")
return "Test completed"
}
}