import { test, expect, describe } from "bun:test" import { run } from "#index" import { toBytecode } from "#bytecode" describe("Unicode and Emoji", () => { test("emoji variable names - string format", async () => { const bytecode = toBytecode(` PUSH 5 STORE 💎 LOAD 💎 HALT `) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 5 }) }) test("emoji variable names - array format", async () => { const bytecode = toBytecode([ ["PUSH", 100], ["STORE", "💰"], ["LOAD", "💰"], ["PUSH", 50], ["ADD"], ["HALT"] ]) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 150 }) }) test("unicode variable names - Japanese", async () => { const bytecode = toBytecode(` PUSH 42 STORE 変数 LOAD 変数 HALT `) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 42 }) }) test("unicode variable names - Chinese", async () => { const bytecode = toBytecode([ ["PUSH", 888], ["STORE", "数字"], ["LOAD", "数字"], ["HALT"] ]) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 888 }) }) test("emoji in function parameters", async () => { const bytecode = toBytecode(` MAKE_FUNCTION (💎 🌟) .add STORE add JUMP .after .add: LOAD 💎 LOAD 🌟 ADD RETURN .after: LOAD add PUSH 10 PUSH 20 PUSH 2 PUSH 0 CALL HALT `) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 30 }) }) test("emoji with defaults and variadic", async () => { const bytecode = toBytecode([ ["MAKE_FUNCTION", ["🎯=100", "...🎨"], ".fn"], ["STORE", "fn"], ["JUMP", ".after"], [".fn:"], ["LOAD", "🎯"], ["RETURN"], [".after:"], ["LOAD", "fn"], ["PUSH", 0], ["PUSH", 0], ["CALL"], ["HALT"] ]) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 100 }) }) test("mixed emoji and regular names", async () => { const bytecode = toBytecode([ ["PUSH", 10], ["STORE", "💎"], ["PUSH", 20], ["STORE", "value"], ["PUSH", 30], ["STORE", "🌟"], ["LOAD", "💎"], ["LOAD", "value"], ["ADD"], ["LOAD", "🌟"], ["ADD"], ["HALT"] ]) const result = await run(bytecode) expect(result).toEqual({ type: 'number', value: 60 }) }) })