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:
43
local_tests/test_array_length_fix.hako
Normal file
43
local_tests/test_array_length_fix.hako
Normal file
@ -0,0 +1,43 @@
|
||||
// Test for ArrayBox.length() functionality
|
||||
static box ArrayLengthTest {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Testing ArrayBox.length() functionality")
|
||||
|
||||
// Test 1: Empty array
|
||||
local empty_array = new ArrayBox()
|
||||
local empty_length = empty_array.length()
|
||||
me.console.log("Empty array length: " + empty_length) // Expected: 0
|
||||
|
||||
// Test 2: Array with elements
|
||||
local test_array = new ArrayBox()
|
||||
test_array.push("first")
|
||||
test_array.push("second")
|
||||
test_array.push("third")
|
||||
|
||||
local length_after_push = test_array.length()
|
||||
me.console.log("Array length after 3 pushes: " + length_after_push) // Expected: 3
|
||||
|
||||
// Test 3: Array after pop
|
||||
local popped = test_array.pop()
|
||||
me.console.log("Popped element: " + popped)
|
||||
|
||||
local length_after_pop = test_array.length()
|
||||
me.console.log("Array length after pop: " + length_after_pop) // Expected: 2
|
||||
|
||||
// Test 4: Verify elements are still accessible
|
||||
local first_element = test_array.get(0)
|
||||
local second_element = test_array.get(1)
|
||||
me.console.log("Element at index 0: " + first_element)
|
||||
me.console.log("Element at index 1: " + second_element)
|
||||
|
||||
// Test 5: Edge case - accessing beyond length
|
||||
local beyond_length = test_array.get(5)
|
||||
me.console.log("Element beyond length: " + beyond_length) // Expected: null
|
||||
|
||||
me.console.log("✅ ArrayBox.length() tests completed")
|
||||
return "ArrayBox functionality verified"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user