From d4dce498f718884448a991166e2852f2cb1c9c75 Mon Sep 17 00:00:00 2001 From: Kampfkarren Date: Thu, 28 Jul 2022 17:51:51 -0700 Subject: [PATCH] Test compile --- tests/Compiler.test.cpp | 50 +++++++++++++---------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/tests/Compiler.test.cpp b/tests/Compiler.test.cpp index 0fc0c8cb..ac0e7f1e 100644 --- a/tests/Compiler.test.cpp +++ b/tests/Compiler.test.cpp @@ -1241,42 +1241,22 @@ TEST_CASE("InterpStringWithNoExpressions") CHECK_EQ(compileFunction0(R"(return "hello")"), compileFunction0("return `hello`")); } -/** - * INTERP CODE REVIEW: This test fails, but its not clear to me why. - * - * One reason is that LOP_MOVE is added indiscriminately with interpolated strings, whereas - * standard namecalls only add it where necessary. - * I am not sure how to fix that, but at least understand why it happens. - * - * The second reason, however, is that the registers are completely different for both. - * Since the conformance tests pass, this might just be a difference without a distinction, - * like if "format" is being registered before the other strings, for instance. - * - * (""):format() codegen: - * LOADK R0 K0 - * LOADK R2 K1 - * NAMECALL R0 R0 K2 - * CALL R0 2 1 - * RETURN R0 0 - * - * Interpolated string codegen: - * LOADK R1 K0 - * LOADK R3 K1 - * NAMECALL R1 R1 K2 - * CALL R1 2 1 - * MOVE R0 R1 - * RETURN R0 0 - */ +TEST_CASE("InterpStringZeroCost") +{ + ScopedFastFlag sff{"LuauInterpolatedStringBaseSupport", true}; -// TEST_CASE("InterpStringZeroCost") -// { -// ScopedFastFlag sff{"LuauInterpolatedStringBaseSupport", true}; - -// CHECK_EQ( -// "\n" + compileFunction0(R"(local _ = ("hello, %*!"):format("world"))"), -// "\n" + compileFunction0(R"(local _ = `hello, {"world"}!`)") -// ); -// } + CHECK_EQ( + "\n" + compileFunction0(R"(local _ = `hello, {"world"}!`)"), + R"( +LOADK R1 K0 +LOADK R3 K1 +NAMECALL R1 R1 K2 +CALL R1 2 1 +MOVE R0 R1 +RETURN R0 0 +)" + ); +} TEST_CASE("InterpStringRegisterCleanup") {