Clean up VectorConstants test. Add legacy constructor test case.

This commit is contained in:
Petri Häkkinen 2024-12-17 09:55:50 +02:00
parent 186b4e693b
commit 69b481cb06

View file

@ -5108,39 +5108,45 @@ TEST_CASE("VectorConstants")
ScopedFastFlag luauVectorBuiltins{FFlag::LuauVectorBuiltins, true};
ScopedFastFlag luauVector2Constants{FFlag::LuauVector2Constants, true};
CHECK_EQ("\n" + compileFunction("return vector.create(1, 2)", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("return vector.create(1, 2)", 0, 2, 0), R"(
LOADK R0 K0 [1, 2, 0]
RETURN R0 1
)");
CHECK_EQ("\n" + compileFunction("return vector.create(1, 2, 3)", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("return vector.create(1, 2, 3)", 0, 2, 0), R"(
LOADK R0 K0 [1, 2, 3]
RETURN R0 1
)");
CHECK_EQ("\n" + compileFunction("print(vector.create(1, 2, 3))", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("print(vector.create(1, 2, 3))", 0, 2, 0), R"(
GETIMPORT R0 1 [print]
LOADK R1 K2 [1, 2, 3]
CALL R0 1 0
RETURN R0 0
)");
CHECK_EQ("\n" + compileFunction("print(vector.create(1, 2, 3, 4))", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("print(vector.create(1, 2, 3, 4))", 0, 2, 0), R"(
GETIMPORT R0 1 [print]
LOADK R1 K2 [1, 2, 3, 4]
CALL R0 1 0
RETURN R0 0
)");
CHECK_EQ("\n" + compileFunction("return vector.create(0, 0, 0), vector.create(-0, 0, 0)", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("return vector.create(0, 0, 0), vector.create(-0, 0, 0)", 0, 2, 0), R"(
LOADK R0 K0 [0, 0, 0]
LOADK R1 K1 [-0, 0, 0]
RETURN R0 2
)");
CHECK_EQ("\n" + compileFunction("return type(vector.create(0, 0, 0))", 0, 2, 0, /*enableVectors*/ true), R"(
CHECK_EQ("\n" + compileFunction("return type(vector.create(0, 0, 0))", 0, 2, 0), R"(
LOADK R0 K0 ['vector']
RETURN R0 1
)");
// test legacy constructor
CHECK_EQ("\n" + compileFunction("return Vector3.new(1, 2, 3)", 0, 2, 0, /*enableVectors*/ true), R"(
LOADK R0 K0 [1, 2, 3]
RETURN R0 1
)");
}