From dd64edd58fe25ec74ae5958128cf3f74b0692f3b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 28 Jan 2026 18:43:14 +0800 Subject: Fixed compiler issues and added 800+ test cases. --- spec/outputs/test/advanced_macro_spec.lua | 92 +++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 spec/outputs/test/advanced_macro_spec.lua (limited to 'spec/outputs/test/advanced_macro_spec.lua') diff --git a/spec/outputs/test/advanced_macro_spec.lua b/spec/outputs/test/advanced_macro_spec.lua new file mode 100644 index 0000000..0a46978 --- /dev/null +++ b/spec/outputs/test/advanced_macro_spec.lua @@ -0,0 +1,92 @@ +return describe("advanced macro", function() + it("should evaluate macro at compile time", function() + local area = 6.2831853071796 * 5 + return assert.is_true(area > 0) + end) + it("should support macro with arguments", function() + local result = (5 + 10) + return assert.same(result, 15) + end) + it("should handle string returning macro", function() + local result = 'hello world' + return assert.same(result, "hello world") + end) + it("should work with conditional compilation", function() + debugMode = true + assert.is_true(debugMode) + return assert.is_true(debugMode) + end) + it("should support macro generating conditional code", function() + debugMode = true + local x = 10 + return assert.same(x, 10) + end) + it("should work with lua code insertion", function() + local macro_test_var = 42 + do +local macro_test_var = 99 + end + return assert.same(macro_test_var, 42) + end) + it("should support multi-line raw lua", function() + local multiline_var = "test" +multiline_var = "test work" + local multiline_var1 = "test1" + assert.same(multiline_var, "test work") + return assert.same(multiline_var1, "test1") + end) + it("should export macro from module", function() + local result = (5 * 2) + return assert.same(result, 10) + end) + it("should work with builtin FILE macro", function() + local result = "./spec/inputs/test/advanced_macro_spec.yue" + return assert.is_true(type(result) == "string") + end) + it("should work with builtin LINE macro", function() + local result = 82 + return assert.is_true(type(result) == "number") + end) + it("should support argument validation", function() + local result = 123 + return assert.same(result, 123) + end) + it("should handle string argument validation", function() + local result = "hello" + return assert.same(result, "hello") + end) + it("should work with is_ast check", function() + local result = (10 + 20) + return assert.same(result, 30) + end) + it("should support macro generating macro", function() + local result = "Red" + return assert.same(result, "Red") + end) + it("should handle complex macro logic", function() + local my_print + my_print = function(...) + return ... + end + local a, b, c = my_print("hello", "world", 123) + assert.same(a, "hello") + assert.same(b, "world") + return assert.same(c, 123) + end) + it("should work with table manipulation", function() + local result = { + "1", + "2", + "3" + } + return assert.same(result, { + "1", + "2", + "3" + }) + end) + return it("should support string concatenation in macro", function() + local result = ("hello" .. "world") + return assert.same(result, "helloworld") + end) +end) -- cgit v1.2.3-55-g6feb