51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
!! 测试新的内置库函数
|
|
|
|
!! 测试文件操作函数
|
|
show(`=== Testing File Operations ===`)
|
|
|
|
!! 写入文件
|
|
result = file_write(`test_file.txt`, `Hello, Oraset!\nThis is a test file.`)
|
|
show(`file_write result: `, result)
|
|
|
|
!! 检查文件是否存在
|
|
exists = file_exists(`test_file.txt`)
|
|
show(`file_exists result: `, exists)
|
|
|
|
!! 读取文件内容
|
|
content = file_read(`test_file.txt`)
|
|
show(`file_read result: `, content)
|
|
|
|
!! 测试时间函数
|
|
show(`\n=== Testing Time Functions ===`)
|
|
|
|
!! 获取当前时间
|
|
current_time = time_now()
|
|
show(`Current time: `, current_time)
|
|
|
|
!! 测试随机数函数
|
|
show(`\n=== Testing Random Functions ===`)
|
|
|
|
!! 生成随机整数
|
|
random_num = random_int(1, 100)
|
|
show(`Random integer (1-100): `, random_num)
|
|
|
|
!! 生成随机浮点数
|
|
random_float_num = random_float()
|
|
show(`Random float (0-1): `, random_float_num)
|
|
|
|
!! 测试系统函数
|
|
show(`\n=== Testing System Functions ===`)
|
|
|
|
!! 执行系统命令
|
|
os_name = get_env(`OS`)
|
|
if (os_name == `Windows_NT`) {
|
|
system_output = system(`dir`)
|
|
} else {
|
|
system_output = system(`ls -la`)
|
|
}
|
|
show(`System command output: `, system_output)
|
|
|
|
!! 获取环境变量
|
|
path = get_env(`PATH`)
|
|
show(`PATH environment variable: `, substring(path, 0, 100), `...`)
|