0b480cfb6b
Full-featured terminal explorer for the Engram knowledge graph built natively in El. Features: - ANSI-colored TUI with box-drawing borders and salience bars - All API endpoints: stats, nodes by type/tier, search, edges, spreading activation, node detail with neighbor traversal - Text report export via fs_write - Offline/unreachable mode with helpful startup messages - Interactive mode command reference - ENGRAM_URL env var for connecting to non-default servers - Uses json_get_raw for nested JSON object traversal
104 lines
2.3 KiB
EmacsLisp
104 lines
2.3 KiB
EmacsLisp
// language_features_test.el — tests for new operators and builtins
|
|
|
|
// 1. Modulo operator
|
|
let m = 17 % 5
|
|
println(int_to_str(m))
|
|
|
|
// 2. Bitwise ops
|
|
let flags_and = 10 & 12
|
|
let flags_xor = 10 ^ 12
|
|
let flags_shl = 1 << 3
|
|
let flags_shr = 16 >> 2
|
|
println(int_to_str(flags_and))
|
|
println(int_to_str(flags_xor))
|
|
println(int_to_str(flags_shl))
|
|
println(int_to_str(flags_shr))
|
|
|
|
// 3. Math trig
|
|
let sin0 = math_sin(0.0)
|
|
let cos0 = math_cos(0.0)
|
|
let pi_val = math_pi()
|
|
println(float_to_str(sin0))
|
|
println(float_to_str(cos0))
|
|
println(float_to_str(pi_val))
|
|
|
|
// 4. String padding
|
|
let padded = str_pad_left("42", 5, "0")
|
|
println(padded)
|
|
|
|
let padded_r = str_pad_right("hi", 5, ".")
|
|
println(padded_r)
|
|
|
|
// 5. str_format
|
|
let tmpl = "Hello {name}, you are {age} years old!"
|
|
let data = {"name": "Will", "age": "30"}
|
|
let formatted = str_format(tmpl, data)
|
|
println(formatted)
|
|
|
|
// 6. format_float
|
|
let ff = format_float(3.14159, 2)
|
|
println(ff)
|
|
|
|
// 7. Time
|
|
let ts = time_now_utc()
|
|
let parts = time_to_parts(ts)
|
|
let iso_str = time_format(ts, "ISO")
|
|
println(iso_str)
|
|
|
|
// 8. Time add/diff
|
|
let ts2 = time_add(ts, 7, "day")
|
|
let diff = time_diff(ts, ts2, "day")
|
|
println(int_to_str(diff))
|
|
|
|
// 9. List range
|
|
let rng = list_range(0, 5)
|
|
println(list_join(rng, ","))
|
|
|
|
// 10. Stack push/pop
|
|
let s0 = stack_new()
|
|
let s1 = stack_push(s0, 10)
|
|
let s2 = stack_push(s1, 20)
|
|
let top = stack_peek(s2)
|
|
let s3 = stack_pop(s2)
|
|
println(int_to_str(top))
|
|
|
|
// 11. Queue enqueue/dequeue
|
|
let q0 = queue_new()
|
|
let q1 = queue_enqueue(q0, "first")
|
|
let q2 = queue_enqueue(q1, "second")
|
|
let front = queue_peek(q2)
|
|
let q3 = queue_dequeue(q2)
|
|
println(front)
|
|
|
|
// 12. Decimal round
|
|
let rounded = decimal_round(3.14159, 2)
|
|
println(float_to_str(rounded))
|
|
|
|
// 13. int_to_float / float_to_int
|
|
let fi = int_to_float(42)
|
|
let if_ = float_to_int(3.9)
|
|
println(float_to_str(fi))
|
|
println(int_to_str(if_))
|
|
|
|
// 14. is_nil / unwrap_or
|
|
let n = unwrap_or(is_nil(42), false)
|
|
println(bool_to_str(n))
|
|
|
|
// 15. list_push, list_pop, list_range
|
|
let lst = list_new()
|
|
let lst2 = list_push(lst, 100)
|
|
let lst3 = list_push(lst2, 200)
|
|
let last_elem = list_peek_last(lst3)
|
|
println(int_to_str(last_elem))
|
|
|
|
// 16. Char ops
|
|
let char_a = str_char_at("hello", 1)
|
|
let code_e = str_char_code("hello", 1)
|
|
let ch_from = str_from_char_code(65)
|
|
println(char_a)
|
|
println(int_to_str(code_e))
|
|
println(ch_from)
|
|
|
|
// Done
|
|
println("all tests complete")
|