79 lines
1.4 KiB
Plaintext
79 lines
1.4 KiB
Plaintext
// Simple Kilo Editor Test - Step by step validation
|
|
// Test basic Box operations before full editor
|
|
|
|
local s1
|
|
local s2
|
|
local s3
|
|
local result
|
|
|
|
print("=== StringBox Methods Test ===")
|
|
|
|
// Test basic StringBox operations
|
|
s1 = "" // Create empty string instead of new StringBox()
|
|
print("Created empty StringBox")
|
|
|
|
s2 = "Hello"
|
|
print("String length test:")
|
|
result = s2.length()
|
|
print(result)
|
|
|
|
print("String substring test:")
|
|
result = s2.substring(1, 4)
|
|
print(result)
|
|
|
|
print("String concat test:")
|
|
s3 = " World"
|
|
result = s2.concat(s3)
|
|
print(result)
|
|
|
|
print("=== ArrayBox Methods Test ===")
|
|
|
|
local arr
|
|
local item
|
|
local len
|
|
|
|
arr = new ArrayBox()
|
|
print("Created empty ArrayBox")
|
|
|
|
len = arr.length()
|
|
print("Array length:")
|
|
print(len)
|
|
|
|
print("=== Basic Editor Component Test ===")
|
|
|
|
// Test a simple editor component without full complexity
|
|
box SimpleEditor {
|
|
init { text, cursor }
|
|
|
|
init_empty() {
|
|
me.text = ""
|
|
me.cursor = 0
|
|
}
|
|
|
|
append_char(ch) {
|
|
me.text = me.text.concat(ch)
|
|
me.cursor = me.cursor + 1
|
|
}
|
|
|
|
get_text() {
|
|
return me.text
|
|
}
|
|
|
|
get_cursor() {
|
|
return me.cursor
|
|
}
|
|
}
|
|
|
|
local editor
|
|
editor = new SimpleEditor()
|
|
editor.init_empty()
|
|
|
|
print("Testing simple editor:")
|
|
editor.append_char("H")
|
|
editor.append_char("i")
|
|
|
|
print("Editor text:")
|
|
print(editor.get_text())
|
|
|
|
print("Editor cursor:")
|
|
print(editor.get_cursor()) |