src/reader tests: Have parse() return a unique_ptr
The reason being that some tests called parse() twice, which will silently destruct the first parser. Once the `Module` owns the AST nodes, the second call will end up deleting all the AST nodes. Tests would then perform use-after-free for the AST nodes belonging to the first parser / module. There's no reason why the unique_ptr can't be returned, which is cleaner overall. Bug: tint:335 Change-Id: I7ff2e9777a7ebeb76702f806294fe4c2c49bd7c9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33241 Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
40e3ccda33
commit
627732c408
|
@ -131,9 +131,9 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -158,9 +158,9 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -187,9 +187,9 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -216,9 +216,9 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -247,9 +247,9 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -278,9 +278,9 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -311,9 +311,9 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -344,9 +344,9 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -379,9 +379,9 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -406,9 +406,9 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -460,11 +460,11 @@ TEST_P(SpvBinaryArithTest, EmitExpression) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
std::ostringstream ss;
|
||||
ss << R"(VariableConst{
|
||||
|
@ -690,11 +690,11 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -725,11 +725,11 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -836,11 +836,11 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -871,11 +871,11 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -926,9 +926,9 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -955,9 +955,9 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -984,9 +984,9 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -1013,9 +1013,9 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -1042,9 +1042,9 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -1071,9 +1071,9 @@ TEST_F(SpvBinaryArithTestBasic, Dot) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_3
|
||||
|
@ -1102,9 +1102,9 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_3
|
||||
|
|
|
@ -149,11 +149,11 @@ TEST_P(SpvBinaryBitTest, EmitExpression) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
std::ostringstream ss;
|
||||
ss << R"(VariableConst{
|
||||
|
@ -396,9 +396,9 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -423,9 +423,9 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -452,9 +452,9 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -481,9 +481,9 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -508,9 +508,9 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -539,9 +539,9 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -572,9 +572,9 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -604,9 +604,9 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
|
|
@ -30,7 +30,7 @@ using ::testing::Eq;
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
|
||||
|
@ -68,7 +68,7 @@ TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -88,7 +88,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) {
|
|||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
{
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -109,7 +109,7 @@ Return{})"))
|
|||
}
|
||||
|
||||
{
|
||||
FunctionEmitter fe(p, *spirv_function(50));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Return{
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ Return{})"))
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -144,7 +144,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) {
|
|||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
{
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
Variable{
|
||||
|
@ -179,7 +179,7 @@ Return{})"))
|
|||
<< ToString(fe.ast_body());
|
||||
}
|
||||
{
|
||||
FunctionEmitter fe(p, *spirv_function(50));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Return{
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ Return{})"))
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_CallWithParams) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,9 +82,9 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -138,9 +138,9 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -179,9 +179,9 @@ TEST_F(SpvParserTest_Composite_Construct, Array) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -210,9 +210,9 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -245,9 +245,9 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -276,9 +276,9 @@ TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("CompositeExtract %1 index value 900 is out of "
|
||||
"bounds for vector of 2 elements"));
|
||||
|
@ -296,9 +296,9 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -327,9 +327,9 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(p->error(), Eq("CompositeExtract %2 index value 3 is out of "
|
||||
"bounds for matrix of 3 elements"));
|
||||
|
@ -347,9 +347,9 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -381,9 +381,9 @@ TEST_F(SpvParserTest_CompositeExtract, Array) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -413,9 +413,9 @@ TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(p->error(), Eq("can't do OpCompositeExtract on a runtime array"));
|
||||
}
|
||||
|
@ -432,9 +432,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -474,9 +474,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -518,9 +518,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("CompositeExtract %2 index value 40 is out of "
|
||||
"bounds for structure %25 having 3 members"));
|
||||
|
@ -540,9 +540,9 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -579,9 +579,9 @@ TEST_F(SpvParserTest_CopyObject, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -617,9 +617,9 @@ TEST_F(SpvParserTest_CopyObject, Pointer) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -657,9 +657,9 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -699,9 +699,9 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -758,9 +758,9 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_10
|
||||
|
@ -789,9 +789,9 @@ TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("invalid vectorshuffle ID %10: index too large: 9"));
|
||||
|
|
|
@ -78,9 +78,9 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -104,9 +104,9 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -134,9 +134,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
|
||||
|
@ -150,9 +150,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_BadArg) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
|
||||
|
@ -166,9 +166,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_BadArg) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
|
||||
|
@ -182,9 +182,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_BadArg) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("unhandled expression for ID 2\n%2 = OpTypeVoid"));
|
||||
|
@ -198,9 +198,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("operand for conversion to floating point must be "
|
||||
|
@ -215,9 +215,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(
|
||||
p->error(),
|
||||
|
@ -234,9 +234,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -261,9 +261,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -290,9 +290,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -317,9 +317,9 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -345,9 +345,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("operand for conversion to floating point must be "
|
||||
"integral scalar or vector, but got: __bool"));
|
||||
|
@ -361,9 +361,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("operand for conversion to floating point must be integral "
|
||||
|
@ -379,9 +379,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -408,9 +408,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -435,9 +435,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -464,9 +464,9 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -490,9 +490,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("operand for conversion to signed integer must be floating "
|
||||
|
@ -507,9 +507,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("operand for conversion to signed integer must be floating "
|
||||
|
@ -525,9 +525,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -552,9 +552,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -581,9 +581,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -608,9 +608,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -636,9 +636,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("operand for conversion to unsigned integer must be floating "
|
||||
|
@ -653,9 +653,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_BadArgType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("operand for conversion to unsigned integer must be floating "
|
||||
|
@ -671,9 +671,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -700,9 +700,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -727,9 +727,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
@ -756,9 +756,9 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{
|
||||
x_1
|
||||
|
|
|
@ -50,14 +50,14 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_VoidFunctionWithoutParams) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionDeclaration());
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
Function x_100 -> __void
|
||||
|
@ -67,7 +67,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_VoidFunctionWithoutParams) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_NonVoidResultType) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%fn_ret_float = OpTypeFunction %float
|
||||
%100 = OpFunction %float None %fn_ret_float
|
||||
%entry = OpLabel
|
||||
|
@ -75,7 +75,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_NonVoidResultType) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionDeclaration());
|
||||
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
|
@ -86,7 +86,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_NonVoidResultType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%100 = OpFunction %void None %fn_mixed_params
|
||||
|
@ -98,7 +98,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionDeclaration());
|
||||
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
|
@ -125,7 +125,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_GenerateParamNames) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%100 = OpFunction %void None %fn_mixed_params
|
||||
|
@ -137,7 +137,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_GenerateParamNames) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionDeclaration());
|
||||
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr(R"(
|
||||
|
|
|
@ -96,9 +96,9 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -127,9 +127,9 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -162,9 +162,9 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -194,9 +194,9 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -234,9 +234,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -265,9 +265,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -300,9 +300,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -332,9 +332,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -372,9 +372,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -406,9 +406,9 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
|
|
@ -202,9 +202,9 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -229,9 +229,9 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -282,11 +282,11 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
std::ostringstream ss;
|
||||
ss << R"(VariableConst{
|
||||
|
@ -697,9 +697,9 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -728,9 +728,9 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -767,9 +767,9 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -798,9 +798,9 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -837,9 +837,9 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -868,9 +868,9 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -907,9 +907,9 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -938,9 +938,9 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -977,9 +977,9 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -1008,9 +1008,9 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -1047,9 +1047,9 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -1078,9 +1078,9 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -1117,9 +1117,9 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1148,9 +1148,9 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1179,9 +1179,9 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1210,9 +1210,9 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1249,9 +1249,9 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1294,9 +1294,9 @@ TEST_F(SpvLogicalTest, Any) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1327,9 +1327,9 @@ TEST_F(SpvLogicalTest, All) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1360,9 +1360,9 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1389,9 +1389,9 @@ TEST_F(SpvLogicalTest, IsNan_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1422,9 +1422,9 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -1451,9 +1451,9 @@ TEST_F(SpvLogicalTest, IsInf_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
|
|
@ -30,7 +30,7 @@ using ::testing::Eq;
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeBool
|
||||
|
@ -48,7 +48,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier[not set]{x_1}
|
||||
|
@ -65,7 +65,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreUintConst) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -80,7 +80,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) {
|
|||
OpReturn
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier[not set]{x_1}
|
||||
|
@ -93,7 +93,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreIntConst) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 1
|
||||
|
@ -108,7 +108,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) {
|
|||
OpReturn
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier[not set]{x_1}
|
||||
|
@ -121,7 +121,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeFloat 32
|
||||
|
@ -136,7 +136,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) {
|
|||
OpReturn
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier[not set]{x_1}
|
||||
|
@ -149,7 +149,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeBool
|
||||
|
@ -165,7 +165,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
VariableConst{
|
||||
|
@ -179,7 +179,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_LoadScalar) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -194,7 +194,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -219,7 +219,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -235,7 +235,7 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -259,7 +259,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -272,7 +272,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
|||
OpReturn
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
Identifier[not set]{x_1}
|
||||
|
@ -300,7 +300,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_NoOperands) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_AccessChain_BaseIsNotPointer) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%10 = OpTypeInt 32 0
|
||||
|
@ -336,10 +336,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -369,10 +369,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("Access chain %2 index %42 value 42 is out of "
|
||||
"bounds for vector of 4 elements"));
|
||||
|
@ -399,10 +399,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
ArrayAccessor[not set]{
|
||||
|
@ -436,10 +436,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
ArrayAccessor[not set]{
|
||||
|
@ -479,10 +479,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
ArrayAccessor[not set]{
|
||||
|
@ -521,10 +521,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -569,10 +569,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -615,10 +615,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("Access chain %2 index %10 is a non-constant "
|
||||
"index into a structure %55"));
|
||||
|
@ -646,10 +646,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_StructConstOutOfBounds) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(), Eq("Access chain %2 index value 99 is out of bounds "
|
||||
"for structure %55 having 2 members"));
|
||||
|
@ -679,10 +679,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
ArrayAccessor[not set]{
|
||||
|
@ -719,10 +719,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -754,10 +754,10 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_InvalidPointeeType) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_FALSE(fe.EmitBody());
|
||||
EXPECT_THAT(p->error(),
|
||||
HasSubstr("Access chain with unknown or invalid pointee type "
|
||||
|
@ -794,7 +794,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_TypesAndVarDeclarations) {
|
|||
// of the structure type, arrays of the structure, pointers to them, and
|
||||
// OpVariable of these.
|
||||
const auto assembly = OldStorageBufferPreamble();
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -828,9 +828,9 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
MemberAccessor[not set]{
|
||||
|
@ -867,9 +867,9 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||
ArrayAccessor[not set]{
|
||||
|
@ -900,9 +900,9 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -955,9 +955,9 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
Variable{
|
||||
|
|
|
@ -63,9 +63,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -123,9 +123,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -183,9 +183,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -224,9 +224,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -256,9 +256,9 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
VariableConst{
|
||||
|
@ -286,10 +286,10 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Return{}
|
||||
)")) << ToString(fe.ast_body());
|
||||
|
|
|
@ -78,7 +78,7 @@ std::string Preamble() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%1 = OpVariable %ptr_uint Function
|
||||
|
@ -88,7 +88,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -116,7 +116,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) {
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + Preamble() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%a = OpVariable %ptr_uint Function
|
||||
|
@ -126,7 +126,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -154,7 +154,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) {
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + Preamble() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%a = OpVariable %ptr_uint Function
|
||||
|
@ -164,7 +164,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -192,7 +192,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) {
|
||||
auto* p =
|
||||
auto p =
|
||||
parser(test::Assemble(Names({"a", "b", "c", "d", "e"}) + Preamble() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
|
@ -205,7 +205,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -262,7 +262,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) {
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c", "d"}) + Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c", "d"}) + Preamble() + R"(
|
||||
%null_bool = OpConstantNull %bool
|
||||
%null_int = OpConstantNull %int
|
||||
%null_uint = OpConstantNull %uint
|
||||
|
@ -278,7 +278,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -325,7 +325,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%const = OpConstantComposite %v2float %float_1p5 %two
|
||||
|
@ -337,7 +337,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -358,7 +358,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %m3v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%three = OpConstant %float 3.0
|
||||
|
@ -375,7 +375,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -409,7 +409,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
%const = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -421,7 +421,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -442,7 +442,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
|
||||
auto* p = parser(test::Assemble(
|
||||
auto p = parser(test::Assemble(
|
||||
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
|
@ -455,7 +455,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -476,7 +476,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
%const = OpConstantNull %arr2uint
|
||||
|
@ -488,7 +488,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -509,7 +509,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
|
||||
auto* p = parser(test::Assemble(
|
||||
auto p = parser(test::Assemble(
|
||||
std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
|
@ -522,7 +522,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -543,7 +543,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %strct
|
||||
%two = OpConstant %uint 2
|
||||
%arrconst = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -556,7 +556,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -582,7 +582,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
||||
auto* p = parser(test::Assemble(Preamble() + R"(
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%ptr = OpTypePointer Function %strct
|
||||
%two = OpConstant %uint 2
|
||||
%arrconst = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -595,7 +595,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitFunctionVariables());
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{
|
||||
|
@ -637,9 +637,9 @@ TEST_F(SpvParserTest,
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -682,9 +682,9 @@ TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -752,9 +752,9 @@ TEST_F(SpvParserTest,
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -849,9 +849,9 @@ TEST_F(
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Assignment{
|
||||
|
@ -963,9 +963,9 @@ TEST_F(
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
// We don't hoist x_1 into its own mutable variable. It is emitted as
|
||||
|
@ -1048,9 +1048,9 @@ TEST_F(SpvParserTest,
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(If{
|
||||
|
@ -1133,9 +1133,9 @@ TEST_F(
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(If{
|
||||
|
@ -1212,9 +1212,9 @@ TEST_F(SpvParserTest,
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
// We don't hoist x_1 into its own mutable variable. It is emitted as
|
||||
|
@ -1286,9 +1286,9 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{
|
||||
|
@ -1428,9 +1428,9 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{
|
||||
|
@ -1583,10 +1583,10 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< assembly << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -1752,9 +1752,9 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -1872,9 +1872,9 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) {
|
|||
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
@ -1978,9 +1978,9 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) {
|
|||
OpFunctionEnd
|
||||
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
|
||||
EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_Empty) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto* result = p->ConvertMemberDecoration(1, 1, {});
|
||||
EXPECT_EQ(result, nullptr);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto* result = p->ConvertMemberDecoration(12, 13, {SpvDecorationOffset});
|
||||
EXPECT_EQ(result, nullptr);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto* result =
|
||||
p->ConvertMemberDecoration(12, 13, {SpvDecorationOffset, 3, 4});
|
||||
|
@ -59,7 +59,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_Offset) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto* result = p->ConvertMemberDecoration(1, 1, {SpvDecorationOffset, 8});
|
||||
ASSERT_NE(result, nullptr);
|
||||
|
@ -71,7 +71,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Offset) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_UnhandledDecoration) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto* result = p->ConvertMemberDecoration(12, 13, {12345678});
|
||||
EXPECT_EQ(result, nullptr);
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
p->Fail() << "boing";
|
||||
auto* type = p->ConvertType(10);
|
||||
EXPECT_EQ(type, nullptr);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) {
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* type = p->ConvertType(10);
|
||||
EXPECT_EQ(type, nullptr);
|
||||
EXPECT_THAT(
|
||||
|
@ -54,7 +54,7 @@ TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_NotAnId) {
|
||||
auto* p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(SpvParserTest, ConvertType_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_IdExistsButIsNotAType) {
|
||||
auto* p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
|
@ -74,7 +74,7 @@ TEST_F(SpvParserTest, ConvertType_IdExistsButIsNotAType) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_UnhandledType) {
|
||||
// Pipes are an OpenCL type. Tint doesn't support them.
|
||||
auto* p = parser(test::Assemble("%70 = OpTypePipe WriteOnly"));
|
||||
auto p = parser(test::Assemble("%70 = OpTypePipe WriteOnly"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(70);
|
||||
|
@ -84,7 +84,7 @@ TEST_F(SpvParserTest, ConvertType_UnhandledType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Void) {
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
|
@ -93,7 +93,7 @@ TEST_F(SpvParserTest, ConvertType_Void) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Bool) {
|
||||
auto* p = parser(test::Assemble("%100 = OpTypeBool"));
|
||||
auto p = parser(test::Assemble("%100 = OpTypeBool"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(100);
|
||||
|
@ -102,7 +102,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_I32) {
|
||||
auto* p = parser(test::Assemble("%2 = OpTypeInt 32 1"));
|
||||
auto p = parser(test::Assemble("%2 = OpTypeInt 32 1"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(2);
|
||||
|
@ -111,7 +111,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_U32) {
|
||||
auto* p = parser(test::Assemble("%3 = OpTypeInt 32 0"));
|
||||
auto p = parser(test::Assemble("%3 = OpTypeInt 32 0"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
|
@ -120,7 +120,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_F32) {
|
||||
auto* p = parser(test::Assemble("%4 = OpTypeFloat 32"));
|
||||
auto p = parser(test::Assemble("%4 = OpTypeFloat 32"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(4);
|
||||
|
@ -129,7 +129,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_BadIntWidth) {
|
||||
auto* p = parser(test::Assemble("%5 = OpTypeInt 17 1"));
|
||||
auto p = parser(test::Assemble("%5 = OpTypeInt 17 1"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(5);
|
||||
|
@ -138,7 +138,7 @@ TEST_F(SpvParserTest, ConvertType_BadIntWidth) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_BadFloatWidth) {
|
||||
auto* p = parser(test::Assemble("%6 = OpTypeFloat 19"));
|
||||
auto p = parser(test::Assemble("%6 = OpTypeFloat 19"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(6);
|
||||
|
@ -147,7 +147,7 @@ TEST_F(SpvParserTest, ConvertType_BadFloatWidth) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%5 = OpTypePipe ReadOnly
|
||||
%20 = OpTypeVector %5 2
|
||||
)"));
|
||||
|
@ -159,7 +159,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%20 = OpTypeVector %float 2
|
||||
%30 = OpTypeVector %float 3
|
||||
|
@ -186,7 +186,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%int = OpTypeInt 32 1
|
||||
%20 = OpTypeVector %int 2
|
||||
%30 = OpTypeVector %int 3
|
||||
|
@ -213,7 +213,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%20 = OpTypeVector %uint 2
|
||||
%30 = OpTypeVector %uint 3
|
||||
|
@ -240,7 +240,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%5 = OpTypePipe ReadOnly
|
||||
%10 = OpTypeVector %5 2
|
||||
%20 = OpTypeMatrix %10 2
|
||||
|
@ -254,7 +254,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
||||
// Matrices are only defined over floats.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%v2 = OpTypeVector %float 2
|
||||
%v3 = OpTypeVector %float 3
|
||||
|
@ -331,7 +331,7 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
|
@ -353,7 +353,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RuntimeArray_InvalidDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeRuntimeArray %uint
|
||||
|
@ -367,7 +367,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 64
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeRuntimeArray %uint
|
||||
|
@ -384,7 +384,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_ZeroIsError) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 0
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeRuntimeArray %uint
|
||||
|
@ -398,7 +398,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_ZeroIsError) {
|
|||
|
||||
TEST_F(SpvParserTest,
|
||||
ConvertType_RuntimeArray_ArrayStride_SpecifiedTwiceIsError) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 64
|
||||
OpDecorate %10 ArrayStride 64
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -412,7 +412,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Array) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpConstant %uint 42
|
||||
%10 = OpTypeArray %uint %uint_42
|
||||
|
@ -435,7 +435,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %uint_42 SpecId 12
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpSpecConstant %uint 42
|
||||
|
@ -450,7 +450,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpConstant %uint 42
|
||||
%sum = OpSpecConstantOp %uint IAdd %uint_42 %uint_42
|
||||
|
@ -469,7 +469,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) {
|
|||
// optimizer representation doesn't handle it and asserts out instead.
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint64 = OpTypeInt 64 0
|
||||
%uint64_big = OpConstant %uint64 5000000000
|
||||
%10 = OpTypeArray %uint64 %uint64_big
|
||||
|
@ -484,7 +484,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Array_InvalidDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_5 = OpConstant %uint 5
|
||||
|
@ -499,7 +499,7 @@ TEST_F(SpvParserTest, ConvertType_Array_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_5 = OpConstant %uint 5
|
||||
|
@ -518,7 +518,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayStride_ZeroIsError) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 0
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_5 = OpConstant %uint 5
|
||||
|
@ -533,7 +533,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_ZeroIsError) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayStride_SpecifiedTwiceIsError) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 ArrayStride 4
|
||||
OpDecorate %10 ArrayStride 4
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -549,7 +549,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_SpecifiedTwiceIsError) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %uint %float
|
||||
|
@ -570,7 +570,7 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeStruct %uint
|
||||
|
@ -591,7 +591,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %10 0 Offset 0
|
||||
OpMemberDecorate %10 1 Offset 8
|
||||
OpMemberDecorate %10 2 Offset 16
|
||||
|
@ -623,7 +623,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) {
|
||||
// Disallow pointer-to-function
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%42 = OpTypeFunction %void
|
||||
%3 = OpTypePointer Input %42
|
||||
|
@ -638,7 +638,7 @@ TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) {
|
|||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidStorageClass) {
|
||||
// Disallow invalid storage class
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%3 = OpTypePointer !999 %1 ; Special syntax to inject 999 as the storage class
|
||||
)"));
|
||||
|
@ -647,7 +647,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Input %float
|
||||
)"));
|
||||
|
@ -663,7 +663,7 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Output %float
|
||||
)"));
|
||||
|
@ -679,7 +679,7 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Uniform %float
|
||||
)"));
|
||||
|
@ -695,7 +695,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Workgroup %float
|
||||
)"));
|
||||
|
@ -711,7 +711,7 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer UniformConstant %float
|
||||
)"));
|
||||
|
@ -727,7 +727,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer StorageBuffer %float
|
||||
)"));
|
||||
|
@ -743,7 +743,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Image %float
|
||||
)"));
|
||||
|
@ -759,7 +759,7 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Private %float
|
||||
)"));
|
||||
|
@ -775,7 +775,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Function %float
|
||||
)"));
|
||||
|
@ -792,7 +792,7 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
|
||||
// FYI: The reader suports pointer-to-pointer even while WebGPU does not.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%42 = OpTypePointer Output %float
|
||||
%3 = OpTypePointer Input %42
|
||||
|
@ -818,7 +818,7 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
|
||||
// We fake the type suport for samplers, images, and sampled images.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%1 = OpTypeSampler
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
@ -830,7 +830,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
|
||||
// We fake the type suport for samplers, images, and sampled images.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%1 = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
)"));
|
||||
|
@ -842,7 +842,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%im = OpTypeImage %float 2D 0 0 0 1 Unknown
|
||||
%1 = OpTypeSampledImage %im
|
||||
|
|
|
@ -50,7 +50,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_NoFunctions) {
|
||||
auto* p = parser(test::Assemble(CommonTypes()));
|
||||
auto p = parser(test::Assemble(CommonTypes()));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -58,7 +58,7 @@ TEST_F(SpvParserTest, EmitFunctions_NoFunctions) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
||||
auto* p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
%main = OpFunction %void None %voidfn
|
||||
OpFunctionEnd
|
||||
)"));
|
||||
|
@ -76,7 +76,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_Vertex) {
|
|||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
||||
auto* p = parser(test::Assemble(input));
|
||||
auto p = parser(test::Assemble(input));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -95,7 +95,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_Fragment) {
|
|||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
||||
auto* p = parser(test::Assemble(input));
|
||||
auto p = parser(test::Assemble(input));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -114,7 +114,7 @@ TEST_F(SpvParserTest, EmitFunctions_Function_EntryPoint_GLCompute) {
|
|||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
||||
auto* p = parser(test::Assemble(input));
|
||||
auto p = parser(test::Assemble(input));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -135,7 +135,7 @@ OpEntryPoint Fragment %main "frag_main"
|
|||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
||||
auto* p = parser(test::Assemble(input));
|
||||
auto p = parser(test::Assemble(input));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->error().empty()) << p->error();
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -152,7 +152,7 @@ OpFunctionEnd)";
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) {
|
||||
auto* p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
%main = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
OpReturn
|
||||
|
@ -168,7 +168,7 @@ TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
||||
auto* p = parser(test::Assemble(
|
||||
auto p = parser(test::Assemble(
|
||||
Names({"root", "branch", "leaf", "leaf_result", "branch_result"}) +
|
||||
CommonTypes() + R"(
|
||||
%uintfn = OpTypeFunction %uint
|
||||
|
@ -250,7 +250,7 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
||||
auto* p = parser(test::Assemble(Names({"ret_float"}) + CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"ret_float"}) + CommonTypes() + R"(
|
||||
%fn_ret_float = OpTypeFunction %float
|
||||
|
||||
%ret_float = OpFunction %float None %fn_ret_float
|
||||
|
@ -275,8 +275,8 @@ TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
||||
auto* p = parser(test::Assemble(Names({"mixed_params", "a", "b", "c"}) +
|
||||
CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"mixed_params", "a", "b", "c"}) +
|
||||
CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%mixed_params = OpFunction %void None %fn_mixed_params
|
||||
|
@ -315,7 +315,7 @@ TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_GenerateParamNames) {
|
||||
auto* p = parser(test::Assemble(Names({"mixed_params"}) + CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(Names({"mixed_params"}) + CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%mixed_params = OpFunction %void None %fn_mixed_params
|
||||
|
|
|
@ -27,7 +27,7 @@ using ::testing::Eq;
|
|||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_NotAnId) {
|
||||
auto* p = parser(test::Assemble(""));
|
||||
auto p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(42);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -35,7 +35,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_NoDecorations) {
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -43,7 +43,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_NoDecorations) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_OneDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
|
@ -56,7 +56,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_OneDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_MultiDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %5 RelaxedPrecision
|
||||
OpDecorate %5 Location 7 ; Invalid case made up for test
|
||||
%float = OpTypeFloat 32
|
||||
|
@ -71,7 +71,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_MultiDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_NotAnId) {
|
||||
auto* p = parser(test::Assemble(""));
|
||||
auto p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsForMember(42, 9);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -79,7 +79,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_NotAStruct) {
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -87,7 +87,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_NotAStruct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_MemberWithoutDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeStruct %uint
|
||||
)"));
|
||||
|
@ -99,7 +99,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_MemberWithoutDecoration) {
|
|||
|
||||
// TODO(dneto): Enable when ArrayStride is handled
|
||||
TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_OneDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %10 1 ArrayStride 12
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_2 = OpConstant %uint 2
|
||||
|
@ -117,7 +117,7 @@ TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_OneDecoration) {
|
|||
// crbug.com/tint/30 for ArrayStride
|
||||
// crbug.com/tint/31 for matrix layout
|
||||
TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_MultiDecoration) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %50 1 RelaxedPrecision
|
||||
OpMemberDecorate %50 2 ArrayStride 16
|
||||
OpMemberDecorate %50 2 MatrixStride 8
|
||||
|
|
|
@ -195,7 +195,7 @@ TEST_F(SpvParserTest,
|
|||
%10 = OpConstantNull %ptr_sampler
|
||||
%20 = OpConstantNull %ptr_f_texture_1d
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(10, false);
|
||||
const auto* image = p->GetMemoryObjectDeclarationForHandle(20, true);
|
||||
|
@ -210,7 +210,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_Variable_Direct) {
|
|||
%10 = OpVariable %ptr_sampler UniformConstant
|
||||
%20 = OpVariable %ptr_f_texture_1d UniformConstant
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(10, false);
|
||||
|
@ -247,7 +247,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -282,7 +282,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -319,7 +319,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -354,7 +354,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -382,7 +382,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_Variable_CopyObject) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -410,7 +410,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_Variable_Load) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -443,7 +443,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(100, false);
|
||||
|
@ -474,7 +474,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_Variable_Image) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
||||
|
@ -493,7 +493,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_FuncParam_Direct) {
|
|||
%entry = OpLabel
|
||||
OpReturn
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(10, false);
|
||||
|
@ -530,7 +530,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -565,7 +565,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -602,7 +602,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -637,7 +637,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -666,7 +666,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -694,7 +694,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_FuncParam_Load) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(110, false);
|
||||
|
@ -728,7 +728,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto* sampler = p->GetMemoryObjectDeclarationForHandle(100, false);
|
||||
|
@ -760,7 +760,7 @@ TEST_F(SpvParserTest, GetMemoryObjectDeclarationForHandle_FuncParam_Image) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
||||
|
@ -804,7 +804,7 @@ TEST_P(SpvParserTest_RegisterHandleUsage_SampledImage, Variable) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->RegisterHandleUsage());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -844,7 +844,7 @@ TEST_P(SpvParserTest_RegisterHandleUsage_SampledImage, FunctionParam) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule()) << p->error() << assembly << std::endl;
|
||||
EXPECT_TRUE(p->RegisterHandleUsage()) << p->error() << assembly << std::endl;
|
||||
EXPECT_TRUE(p->error().empty()) << p->error() << assembly << std::endl;
|
||||
|
@ -953,7 +953,7 @@ TEST_P(SpvParserTest_RegisterHandleUsage_RawImage, Variable) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->RegisterHandleUsage());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -990,7 +990,7 @@ TEST_P(SpvParserTest_RegisterHandleUsage_RawImage, FunctionParam) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildInternalModule());
|
||||
EXPECT_TRUE(p->RegisterHandleUsage());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
|
|
@ -32,7 +32,7 @@ using ::testing::Not;
|
|||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
TEST_F(SpvParserTest, Import_NoImport) {
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -40,7 +40,7 @@ TEST_F(SpvParserTest, Import_NoImport) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, Import_ImportGlslStd450) {
|
||||
auto* p = parser(test::Assemble(R"(%1 = OpExtInstImport "GLSL.std.450")"));
|
||||
auto p = parser(test::Assemble(R"(%1 = OpExtInstImport "GLSL.std.450")"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
EXPECT_THAT(p->glsl_std_450_imports(), ElementsAre(1));
|
||||
|
|
|
@ -64,7 +64,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_NoVar) {
|
||||
auto* p = parser(test::Assemble(""));
|
||||
auto p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -72,7 +72,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_NoVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass_NotAWebGPUStorageClass) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer CrossWorkgroup %float
|
||||
%52 = OpVariable %ptr CrossWorkgroup
|
||||
|
@ -86,7 +86,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass_NotAWebGPUStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass_Function) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Function %float
|
||||
%52 = OpVariable %ptr Function
|
||||
|
@ -102,7 +102,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass_Function) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BadPointerType) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%fn_ty = OpTypeFunction %float
|
||||
%3 = OpTypePointer Private %fn_ty
|
||||
|
@ -118,7 +118,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BadPointerType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_NonPointerType) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%5 = OpTypeFunction %float
|
||||
%3 = OpTypePointer Private %5
|
||||
|
@ -132,7 +132,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_NonPointerType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_AnonWorkgroupVar) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Workgroup %float
|
||||
%52 = OpVariable %ptr Workgroup
|
||||
|
@ -150,7 +150,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_AnonWorkgroupVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_NamedWorkgroupVar) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %52 "the_counter"
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Workgroup %float
|
||||
|
@ -169,7 +169,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_NamedWorkgroupVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_PrivateVar) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %52 "my_own_private_idaho"
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Private %float
|
||||
|
@ -188,7 +188,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_PrivateVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BuiltinVertexIndex) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %52 BuiltIn VertexIndex
|
||||
%uint = OpTypeInt 32 0
|
||||
%ptr = OpTypePointer Input %uint
|
||||
|
@ -236,7 +236,7 @@ std::string PerVertexPreamble() {
|
|||
TEST_F(SpvParserTest, ModuleScopeVar_BuiltinPosition_MapsToModuleScopeVec4Var) {
|
||||
// In Vulkan SPIR-V, Position is the first member of gl_PerVertex
|
||||
const std::string assembly = PerVertexPreamble();
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << assembly;
|
||||
EXPECT_TRUE(p->error().empty()) << p->error();
|
||||
|
@ -272,7 +272,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule()) << assembly;
|
||||
EXPECT_THAT(p->error(), Eq("storing to the whole per-vertex structure is not "
|
||||
"supported: OpStore %1 %9"))
|
||||
|
@ -288,7 +288,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule()) << assembly;
|
||||
EXPECT_THAT(p->error(), Eq("operations producing a per-vertex structure are "
|
||||
"not supported: %1000 = OpUndef %10"))
|
||||
|
@ -304,7 +304,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(), Eq("operations producing a per-vertex structure are "
|
||||
"not supported: %1000 = OpUndef %11"))
|
||||
|
@ -323,7 +323,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinPosition_StorePosition) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -354,7 +354,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -385,7 +385,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -415,7 +415,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinPointSize_NotSupported) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(), Eq("accessing per-vertex member 1 is not supported. "
|
||||
"Only Position is supported"));
|
||||
|
@ -435,7 +435,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinClipDistance_NotSupported) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(), Eq("accessing per-vertex member 2 is not supported. "
|
||||
"Only Position is supported"));
|
||||
|
@ -455,7 +455,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinCullDistance_NotSupported) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(), Eq("accessing per-vertex member 3 is not supported. "
|
||||
"Only Position is supported"));
|
||||
|
@ -474,7 +474,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinPerVertex_MemberIndex_NotConstant) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("first index of access chain into per-vertex structure is not "
|
||||
|
@ -495,7 +495,7 @@ TEST_F(SpvParserTest,
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
EXPECT_FALSE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->error(),
|
||||
Eq("first index of access chain into per-vertex structure is not "
|
||||
|
@ -503,7 +503,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarInitializers) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%1 = OpVariable %ptr_bool Private %true
|
||||
%2 = OpVariable %ptr_bool Private %false
|
||||
%3 = OpVariable %ptr_int Private %int_m1
|
||||
|
@ -556,7 +556,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarInitializers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarNullInitializers) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%null_bool = OpConstantNull %bool
|
||||
%null_int = OpConstantNull %int
|
||||
%null_uint = OpConstantNull %uint
|
||||
|
@ -605,7 +605,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarNullInitializers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarUndefInitializers) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%undef_bool = OpUndef %bool
|
||||
%undef_int = OpUndef %int
|
||||
%undef_uint = OpUndef %uint
|
||||
|
@ -654,7 +654,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarUndefInitializers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%const = OpConstantComposite %v2float %float_1p5 %two
|
||||
|
@ -678,7 +678,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorBoolNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2bool
|
||||
%const = OpConstantNull %v2bool
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -701,7 +701,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorBoolNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorBoolUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2bool
|
||||
%const = OpUndef %v2bool
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -724,7 +724,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorBoolUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorUintNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2uint
|
||||
%const = OpConstantNull %v2uint
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -747,7 +747,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorUintNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorUintUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2uint
|
||||
%const = OpUndef %v2uint
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -770,7 +770,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorUintUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorIntNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2int
|
||||
%const = OpConstantNull %v2int
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -793,7 +793,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorIntNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorIntUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2int
|
||||
%const = OpUndef %v2int
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -816,7 +816,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorIntUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorFloatNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2float
|
||||
%const = OpConstantNull %v2float
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -839,7 +839,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorFloatNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorFloatUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2float
|
||||
%const = OpUndef %v2float
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -862,7 +862,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorFloatUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_MatrixInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %m3v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%three = OpConstant %float 3.0
|
||||
|
@ -904,7 +904,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_MatrixNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %m3v2float
|
||||
%const = OpConstantNull %m3v2float
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -940,7 +940,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_MatrixUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %m3v2float
|
||||
%const = OpUndef %m3v2float
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -976,7 +976,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ArrayInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
%const = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -1000,7 +1000,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ArrayInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ArrayNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %arr2uint
|
||||
%const = OpConstantNull %arr2uint
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -1023,7 +1023,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ArrayNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ArrayUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %arr2uint
|
||||
%const = OpUndef %arr2uint
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -1046,7 +1046,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ArrayUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %strct
|
||||
%two = OpConstant %uint 2
|
||||
%arrconst = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -1077,7 +1077,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StructNullInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %strct
|
||||
%const = OpConstantNull %strct
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -1106,7 +1106,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructNullInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StructUndefInitializer) {
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %strct
|
||||
%const = OpUndef %strct
|
||||
%200 = OpVariable %ptr Private %const
|
||||
|
@ -1135,7 +1135,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructUndefInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_LocationDecoration_Valid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Location 3
|
||||
)" + CommonTypes() + R"(
|
||||
|
@ -1186,7 +1186,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_DescriptorSetDecoration_Valid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar DescriptorSet 3
|
||||
OpDecorate %strct Block
|
||||
|
@ -1240,7 +1240,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BindingDecoration_Valid) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Binding 3
|
||||
OpDecorate %strct Block
|
||||
|
@ -1295,7 +1295,7 @@ TEST_F(SpvParserTest,
|
|||
|
||||
TEST_F(SpvParserTest,
|
||||
ModuleScopeVar_StructMember_NonReadableDecoration_Dropped) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %strct Block
|
||||
OpMemberDecorate %strct 0 NonReadable
|
||||
|
@ -1322,7 +1322,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 ColMajor
|
||||
|
@ -1351,7 +1351,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 MatrixStride 8
|
||||
|
@ -1380,7 +1380,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_RowMajorDecoration_IsError) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 RowMajor
|
||||
|
@ -1401,7 +1401,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_RowMajorDecoration_IsError) {
|
|||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_AllMembers) {
|
||||
// Variable should have access(read)
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 NonWritable
|
||||
|
@ -1431,7 +1431,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_AllMembers) {
|
|||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers) {
|
||||
// Variable should have access(read_write)
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 NonWritable
|
||||
|
@ -1462,7 +1462,7 @@ TEST_F(
|
|||
SpvParserTest,
|
||||
ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers_DuplicatedOnSameMember) { // NOLINT
|
||||
// Variable should have access(read_write)
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %s Block
|
||||
OpMemberDecorate %s 0 NonWritable
|
||||
|
@ -1491,7 +1491,7 @@ TEST_F(
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_True) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
OpDecorate %c SpecId 12
|
||||
%bool = OpTypeBool
|
||||
|
@ -1516,7 +1516,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_True) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_False) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
OpDecorate %c SpecId 12
|
||||
%bool = OpTypeBool
|
||||
|
@ -1541,7 +1541,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_False) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_U32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
OpDecorate %c SpecId 12
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -1566,7 +1566,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_U32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_I32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
OpDecorate %c SpecId 12
|
||||
%int = OpTypeInt 32 1
|
||||
|
@ -1591,7 +1591,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_I32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_F32) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
OpDecorate %c SpecId 12
|
||||
%float = OpTypeFloat 32
|
||||
|
@ -1618,7 +1618,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_DeclareConst_F32) {
|
|||
TEST_F(SpvParserTest,
|
||||
ModuleScopeVar_ScalarSpecConstant_DeclareConst_F32_WithoutSpecId) {
|
||||
// When we don't have a spec ID, declare an undecorated module-scope constant.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
%float = OpTypeFloat 32
|
||||
%c = OpSpecConstant %float 2.5
|
||||
|
@ -1639,7 +1639,7 @@ TEST_F(SpvParserTest,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_UsedInFunction) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %c "myconst"
|
||||
%float = OpTypeFloat 32
|
||||
%c = OpSpecConstant %float 2.5
|
||||
|
@ -1651,7 +1651,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_UsedInFunction) {
|
|||
OpFunctionEnd
|
||||
)"));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||
FunctionEmitter fe(p, *spirv_function(100));
|
||||
FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100));
|
||||
EXPECT_TRUE(fe.EmitBody()) << p->error();
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace {
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%s = OpTypeStruct %uint %uint
|
||||
)"));
|
||||
|
@ -44,7 +44,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %s "mystruct"
|
||||
%uint = OpTypeInt 32 0
|
||||
%s = OpTypeStruct %uint %uint
|
||||
|
@ -54,7 +54,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_Dup_EmitBoth) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%s = OpTypeStruct %uint %uint
|
||||
%s2 = OpTypeStruct %uint %uint
|
||||
|
@ -75,7 +75,7 @@ TEST_F(SpvParserTest, NamedTypes_Dup_EmitBoth) {
|
|||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonRTArrayWithDecoration) {
|
||||
// Runtime arrays are always in SSBO, and those are always laid out.
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %arr ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
%arr = OpTypeRuntimeArray %uint
|
||||
|
@ -86,7 +86,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArrayWithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %arr ArrayStride 8
|
||||
OpDecorate %arr2 ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -100,7 +100,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %arr "myrtarr"
|
||||
OpDecorate %arr ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -112,7 +112,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %arr "myarr"
|
||||
OpDecorate %arr ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
|
@ -126,7 +126,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpDecorate %arr ArrayStride 8
|
||||
OpDecorate %arr2 ArrayStride 8
|
||||
%uint = OpTypeInt 32 0
|
||||
|
|
|
@ -30,14 +30,14 @@ using ::testing::HasSubstr;
|
|||
|
||||
TEST_F(SpvParserTest, Impl_Uint32VecEmpty) {
|
||||
std::vector<uint32_t> data;
|
||||
auto* p = parser(data);
|
||||
auto p = parser(data);
|
||||
EXPECT_FALSE(p->Parse());
|
||||
// TODO(dneto): What message?
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, Impl_InvalidModuleFails) {
|
||||
auto invalid_spv = test::Assemble("%ty = OpTypeInt 3 0");
|
||||
auto* p = parser(invalid_spv);
|
||||
auto p = parser(invalid_spv);
|
||||
EXPECT_FALSE(p->Parse());
|
||||
EXPECT_THAT(
|
||||
p->error(),
|
||||
|
@ -58,7 +58,7 @@ TEST_F(SpvParserTest, Impl_GenericVulkanShader_SimpleMemoryModel) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ TEST_F(SpvParserTest, Impl_GenericVulkanShader_GLSL450MemoryModel) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ TEST_F(SpvParserTest, Impl_GenericVulkanShader_VulkanMemoryModel) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ TEST_F(SpvParserTest, Impl_OpenCLKernel_Fails) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_FALSE(p->Parse());
|
||||
EXPECT_THAT(p->error(), HasSubstr("Capability Kernel is not allowed"));
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ TEST_F(SpvParserTest, Impl_Source_NoOpLine) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
// Use instruction counting.
|
||||
|
@ -167,7 +167,7 @@ TEST_F(SpvParserTest, Impl_Source_WithOpLine_WithOpNoLine) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
// Use the information from the OpLine that is still in scope.
|
||||
|
@ -197,7 +197,7 @@ TEST_F(SpvParserTest, Impl_Source_InvalidId) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)");
|
||||
auto* p = parser(spv);
|
||||
auto p = parser(spv);
|
||||
EXPECT_TRUE(p->Parse());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
auto s99 = p->GetSourceForResultIdForTest(99);
|
||||
|
|
|
@ -36,31 +36,24 @@ class SpvParserTestBase : public T {
|
|||
SpvParserTestBase() = default;
|
||||
~SpvParserTestBase() override = default;
|
||||
|
||||
/// Sets up the test helper
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
/// Tears down the test helper
|
||||
void TearDown() override { impl_ = nullptr; }
|
||||
|
||||
/// Retrieves the parser from the helper
|
||||
/// @param input the SPIR-V binary to parse
|
||||
/// @returns a parser for the given binary
|
||||
ParserImpl* parser(const std::vector<uint32_t>& input) {
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, input);
|
||||
return impl_.get();
|
||||
std::unique_ptr<ParserImpl> parser(const std::vector<uint32_t>& input) {
|
||||
return std::make_unique<ParserImpl>(&ctx_, input);
|
||||
}
|
||||
|
||||
/// Gets the internal representation of the function with the given ID.
|
||||
/// Assumes ParserImpl::BuildInternalRepresentation has been run and
|
||||
/// succeeded.
|
||||
/// @param parser the parser
|
||||
/// @param id the SPIR-V ID of the function
|
||||
/// @returns the internal representation of the function
|
||||
spvtools::opt::Function* spirv_function(uint32_t id) {
|
||||
return impl_->ir_context()->GetFunction(id);
|
||||
spvtools::opt::Function* spirv_function(ParserImpl* parser, uint32_t id) {
|
||||
return parser->ir_context()->GetFunction(id);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<ParserImpl> impl_;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, UserName_RespectOpName) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %1 "the_void_type"
|
||||
%1 = OpTypeVoid
|
||||
)"));
|
||||
|
@ -37,7 +37,7 @@ TEST_F(SpvParserTest, UserName_RespectOpName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_IgnoreEmptyName) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %1 ""
|
||||
%1 = OpTypeVoid
|
||||
)"));
|
||||
|
@ -46,7 +46,7 @@ TEST_F(SpvParserTest, UserName_IgnoreEmptyName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_DistinguishDuplicateSuggestion) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpName %1 "vanilla"
|
||||
OpName %2 "vanilla"
|
||||
%1 = OpTypeVoid
|
||||
|
@ -58,7 +58,7 @@ TEST_F(SpvParserTest, UserName_DistinguishDuplicateSuggestion) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_RespectOpMemberName) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberName %3 0 "strawberry"
|
||||
OpMemberName %3 1 "vanilla"
|
||||
OpMemberName %3 2 "chocolate"
|
||||
|
@ -72,7 +72,7 @@ TEST_F(SpvParserTest, UserName_RespectOpMemberName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_IgnoreEmptyMemberName) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberName %3 0 ""
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeStruct %2
|
||||
|
@ -82,7 +82,7 @@ TEST_F(SpvParserTest, UserName_IgnoreEmptyMemberName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_SynthesizeMemberNames) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeStruct %2 %2 %2
|
||||
)"));
|
||||
|
@ -93,7 +93,7 @@ TEST_F(SpvParserTest, UserName_SynthesizeMemberNames) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_MemberNamesMixUserAndSynthesized) {
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
auto p = parser(test::Assemble(R"(
|
||||
OpMemberName %3 1 "vanilla"
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeStruct %2 %2 %2
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) {
|
||||
auto* p = parser("a + true");
|
||||
auto p = parser("a + true");
|
||||
auto e = p->additive_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) {
|
||||
auto* p = parser("a - true");
|
||||
auto p = parser("a - true");
|
||||
auto e = p->additive_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} + true");
|
||||
auto p = parser("if (a) {} + true");
|
||||
auto e = p->additive_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ParserImplTest, AdditiveExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_InvalidRHS) {
|
||||
auto* p = parser("true + if (a) {}");
|
||||
auto p = parser("true + if (a) {}");
|
||||
auto e = p->additive_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, AdditiveExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->additive_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_Parses) {
|
||||
auto* p = parser("a & true");
|
||||
auto p = parser("a & true");
|
||||
auto e = p->and_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, AndExpression_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} & true");
|
||||
auto p = parser("if (a) {} & true");
|
||||
auto e = p->and_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, AndExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_InvalidRHS) {
|
||||
auto* p = parser("true & if (a) {}");
|
||||
auto p = parser("true & if (a) {}");
|
||||
auto e = p->and_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, AndExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->and_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_Parses) {
|
||||
auto* p = parser("a");
|
||||
auto p = parser("a");
|
||||
auto e = p->expect_argument_expression_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, ArgumentExpressionList_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_ParsesMultiple) {
|
||||
auto* p = parser("a, -33, 1+2");
|
||||
auto p = parser("a, -33, 1+2");
|
||||
auto e = p->expect_argument_expression_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, ArgumentExpressionList_ParsesMultiple) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_HandlesMissingExpression) {
|
||||
auto* p = parser("a, ");
|
||||
auto p = parser("a, ");
|
||||
auto e = p->expect_argument_expression_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -57,7 +57,7 @@ TEST_F(ParserImplTest, ArgumentExpressionList_HandlesMissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_HandlesInvalidExpression) {
|
||||
auto* p = parser("if(a) {}");
|
||||
auto p = parser("if(a) {}");
|
||||
auto e = p->expect_argument_expression_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) {
|
||||
auto* p = parser("a = 123");
|
||||
auto p = parser("a = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
||||
auto* p = parser("a.b.c[2].d = 123");
|
||||
auto p = parser("a.b.c[2].d = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -108,7 +108,7 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
||||
auto* p = parser("a.b.c[2].d 123");
|
||||
auto p = parser("a.b.c[2].d 123");
|
||||
auto e = p->assignment_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_InvalidLHS) {
|
||||
auto* p = parser("if (true) {} = 123");
|
||||
auto p = parser("if (true) {} = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, AssignmentStmt_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_InvalidRHS) {
|
||||
auto* p = parser("a.b.c[2].d = if (true) {}");
|
||||
auto p = parser("a.b.c[2].d = if (true) {}");
|
||||
auto e = p->assignment_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt) {
|
||||
auto* p = parser(R"({
|
||||
auto p = parser(R"({
|
||||
discard;
|
||||
return 1 + b / 2;
|
||||
})");
|
||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, BodyStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_Empty) {
|
||||
auto* p = parser("{}");
|
||||
auto p = parser("{}");
|
||||
auto e = p->expect_body_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, BodyStmt_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_InvalidStmt) {
|
||||
auto* p = parser("{fn main() -> void {}}");
|
||||
auto p = parser("{fn main() -> void {}}");
|
||||
auto e = p->expect_body_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, BodyStmt_InvalidStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_MissingRightParen) {
|
||||
auto* p = parser("{return;");
|
||||
auto p = parser("{return;");
|
||||
auto e = p->expect_body_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt) {
|
||||
auto* p = parser("break");
|
||||
auto p = parser("break");
|
||||
auto e = p->break_stmt();
|
||||
EXPECT_FALSE(e.errored);
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call) {
|
||||
auto* p = parser("a();");
|
||||
auto p = parser("a();");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, Statement_Call) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_WithParams) {
|
||||
auto* p = parser("a(1, b, 2 + 3 / b);");
|
||||
auto p = parser("a(1, b, 2 + 3 / b);");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, Statement_Call_WithParams) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) {
|
||||
auto* p = parser("a(");
|
||||
auto p = parser("a(");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_Missing_Semi) {
|
||||
auto* p = parser("a()");
|
||||
auto p = parser("a()");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, Statement_Call_Missing_Semi) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_Bad_ArgList) {
|
||||
auto* p = parser("a(b c);");
|
||||
auto p = parser("a(b c);");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Empty) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
auto e = p->case_body();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, CaseBody_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Statements) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
var a: i32;
|
||||
a = 2;)");
|
||||
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, CaseBody_Statements) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_InvalidStatement) {
|
||||
auto* p = parser("a =");
|
||||
auto p = parser("a =");
|
||||
auto e = p->case_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ParserImplTest, CaseBody_InvalidStatement) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Fallthrough) {
|
||||
auto* p = parser("fallthrough;");
|
||||
auto p = parser("fallthrough;");
|
||||
auto e = p->case_body();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, CaseBody_Fallthrough) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Fallthrough_MissingSemicolon) {
|
||||
auto* p = parser("fallthrough");
|
||||
auto p = parser("fallthrough");
|
||||
auto e = p->case_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
||||
auto* p = parser("vec2<f32>(1., 2.)");
|
||||
auto p = parser("vec2<f32>(1., 2.)");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingRightParen) {
|
||||
auto* p = parser("vec2<f32>(1., 2.");
|
||||
auto p = parser("vec2<f32>(1., 2.");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingLeftParen) {
|
||||
auto* p = parser("vec2<f32> 1., 2.)");
|
||||
auto p = parser("vec2<f32> 1., 2.)");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_HangingComma) {
|
||||
auto* p = parser("vec2<f32>(1.,)");
|
||||
auto p = parser("vec2<f32>(1.,)");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_HangingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingComma) {
|
||||
auto* p = parser("vec2<f32>(1. 2.");
|
||||
auto p = parser("vec2<f32>(1. 2.");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_MissingExpr) {
|
||||
auto* p = parser("vec2<f32>()");
|
||||
auto p = parser("vec2<f32>()");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -100,7 +100,7 @@ TEST_F(ParserImplTest, ConstExpr_MissingExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_InvalidExpr) {
|
||||
auto* p = parser("vec2<f32>(1., if(a) {})");
|
||||
auto p = parser("vec2<f32>(1., if(a) {})");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -109,7 +109,7 @@ TEST_F(ParserImplTest, ConstExpr_InvalidExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_ConstLiteral) {
|
||||
auto* p = parser("true");
|
||||
auto p = parser("true");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -122,7 +122,7 @@ TEST_F(ParserImplTest, ConstExpr_ConstLiteral) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_ConstLiteral_Invalid) {
|
||||
auto* p = parser("invalid");
|
||||
auto p = parser("invalid");
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ParserImplTest, ConstExpr_Recursion) {
|
|||
for (size_t i = 0; i < 200; i++) {
|
||||
out << ")";
|
||||
}
|
||||
auto* p = parser(out.str());
|
||||
auto p = parser(out.str());
|
||||
auto e = p->expect_const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Int) {
|
||||
auto* p = parser("-234");
|
||||
auto p = parser("-234");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_TRUE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, ConstLiteral_Int) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
||||
auto* p = parser("234u");
|
||||
auto p = parser("234u");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_TRUE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Float) {
|
||||
auto* p = parser("234.e12");
|
||||
auto p = parser("234.e12");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_TRUE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, ConstLiteral_Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_InvalidFloat) {
|
||||
auto* p = parser("1.2e+256");
|
||||
auto p = parser("1.2e+256");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_FALSE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, ConstLiteral_InvalidFloat) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_True) {
|
||||
auto* p = parser("true");
|
||||
auto p = parser("true");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_TRUE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, ConstLiteral_True) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_False) {
|
||||
auto* p = parser("false");
|
||||
auto p = parser("false");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_TRUE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
@ -89,7 +89,7 @@ TEST_F(ParserImplTest, ConstLiteral_False) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_NoMatch) {
|
||||
auto* p = parser("another-token");
|
||||
auto p = parser("another-token");
|
||||
auto c = p->const_literal();
|
||||
EXPECT_FALSE(c.matched);
|
||||
EXPECT_FALSE(c.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt) {
|
||||
auto* p = parser("continue");
|
||||
auto p = parser("continue");
|
||||
auto e = p->continue_stmt();
|
||||
EXPECT_FALSE(e.errored);
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ContinuingStmt) {
|
||||
auto* p = parser("continuing { discard; }");
|
||||
auto p = parser("continuing { discard; }");
|
||||
auto e = p->continuing_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, ContinuingStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinuingStmt_InvalidBody) {
|
||||
auto* p = parser("continuing { discard }");
|
||||
auto p = parser("continuing { discard }");
|
||||
auto e = p->continuing_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, DepthTextureType_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->depth_texture_type();
|
||||
EXPECT_FALSE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, DepthTextureType_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, DepthTextureType_2d) {
|
||||
auto* p = parser("texture_depth_2d");
|
||||
auto p = parser("texture_depth_2d");
|
||||
auto t = p->depth_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
||||
auto* p = parser("texture_depth_2d_array");
|
||||
auto p = parser("texture_depth_2d_array");
|
||||
auto t = p->depth_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
||||
auto* p = parser("texture_depth_cube");
|
||||
auto p = parser("texture_depth_cube");
|
||||
auto t = p->depth_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
||||
auto* p = parser("texture_depth_cube_array");
|
||||
auto p = parser("texture_depth_cube_array");
|
||||
auto t = p->depth_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt) {
|
||||
auto* p = parser("else { a = b; c = d; }");
|
||||
auto p = parser("else { a = b; c = d; }");
|
||||
auto e = p->else_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, ElseStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt_InvalidBody) {
|
||||
auto* p = parser("else { fn main() -> void {}}");
|
||||
auto p = parser("else { fn main() -> void {}}");
|
||||
auto e = p->else_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, ElseStmt_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt_MissingBody) {
|
||||
auto* p = parser("else");
|
||||
auto p = parser("else");
|
||||
auto e = p->else_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt) {
|
||||
auto* p = parser("elseif (a == 4) { a = b; c = d; }");
|
||||
auto p = parser("elseif (a == 4) { a = b; c = d; }");
|
||||
auto e = p->elseif_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, ElseIfStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_Multiple) {
|
||||
auto* p = parser("elseif (a == 4) { a = b; c = d; } elseif(c) { d = 2; }");
|
||||
auto p = parser("elseif (a == 4) { a = b; c = d; } elseif(c) { d = 2; }");
|
||||
auto e = p->elseif_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -56,7 +56,7 @@ TEST_F(ParserImplTest, ElseIfStmt_Multiple) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_InvalidBody) {
|
||||
auto* p = parser("elseif (true) { fn main() -> void {}}");
|
||||
auto p = parser("elseif (true) { fn main() -> void {}}");
|
||||
auto e = p->elseif_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -65,7 +65,7 @@ TEST_F(ParserImplTest, ElseIfStmt_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_MissingBody) {
|
||||
auto* p = parser("elseif (true)");
|
||||
auto p = parser("elseif (true)");
|
||||
auto e = p->elseif_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) {
|
||||
auto* p = parser("a == true");
|
||||
auto p = parser("a == true");
|
||||
auto e = p->equality_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) {
|
||||
auto* p = parser("a != true");
|
||||
auto p = parser("a != true");
|
||||
auto e = p->equality_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} == true");
|
||||
auto p = parser("if (a) {} == true");
|
||||
auto e = p->equality_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ParserImplTest, EqualityExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_InvalidRHS) {
|
||||
auto* p = parser("true == if (a) {}");
|
||||
auto p = parser("true == if (a) {}");
|
||||
auto e = p->equality_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, EqualityExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->equality_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -27,7 +27,7 @@ class ParserImplErrorTest : public ParserImplTest {};
|
|||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto* p = parser(source); \
|
||||
auto p = parser(source); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, diag::Formatter().format(p->diagnostics())); \
|
||||
|
|
|
@ -27,7 +27,7 @@ class ParserImplErrorResyncTest : public ParserImplTest {};
|
|||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto* p = parser(source); \
|
||||
auto p = parser(source); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, diag::Formatter().format(p->diagnostics())); \
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) {
|
||||
auto* p = parser("a ^ true");
|
||||
auto p = parser("a ^ true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} ^ true");
|
||||
auto p = parser("if (a) {} ^ true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidRHS) {
|
||||
auto* p = parser("true ^ if (a) {}");
|
||||
auto p = parser("true ^ if (a) {}");
|
||||
auto e = p->exclusive_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -26,13 +26,13 @@ namespace {
|
|||
class ForStmtTest : public ParserImplTest {
|
||||
public:
|
||||
void TestForLoop(std::string loop_str, std::string for_str) {
|
||||
auto* p_loop = parser(loop_str);
|
||||
auto p_loop = parser(loop_str);
|
||||
auto e_loop = p_loop->expect_statements();
|
||||
EXPECT_FALSE(e_loop.errored);
|
||||
EXPECT_FALSE(p_loop->has_error()) << p_loop->error();
|
||||
ASSERT_NE(e_loop.value, nullptr);
|
||||
|
||||
auto* p_for = parser(for_str);
|
||||
auto p_for = parser(for_str);
|
||||
auto e_for = p_for->expect_statements();
|
||||
EXPECT_FALSE(e_for.errored);
|
||||
EXPECT_FALSE(p_for->has_error()) << p_for->error();
|
||||
|
@ -158,7 +158,7 @@ TEST_F(ForStmtTest, All) {
|
|||
class ForStmtErrorTest : public ParserImplTest {
|
||||
public:
|
||||
void TestForWithError(std::string for_str, std::string error_str) {
|
||||
auto* p_for = parser(for_str);
|
||||
auto p_for = parser(for_str);
|
||||
auto e_for = p_for->for_stmt();
|
||||
|
||||
EXPECT_FALSE(e_for.matched);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl) {
|
||||
auto* p = parser("fn main(a : i32, b : f32) -> void { return; }");
|
||||
auto p = parser("fn main(a : i32, b : f32) -> void { return; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
||||
auto* p = parser("[[workgroup_size(2, 3, 4)]] fn main() -> void { return; }");
|
||||
auto p = parser("[[workgroup_size(2, 3, 4)]] fn main() -> void { return; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -89,7 +89,7 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList_MultipleEntries) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
[[workgroup_size(2, 3, 4), workgroup_size(5, 6, 7)]]
|
||||
fn main() -> void { return; })");
|
||||
auto decos = p->decoration_list();
|
||||
|
@ -133,7 +133,7 @@ fn main() -> void { return; })");
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_DecorationList_MultipleLists) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
[[workgroup_size(2, 3, 4)]]
|
||||
[[workgroup_size(5, 6, 7)]]
|
||||
fn main() -> void { return; })");
|
||||
|
@ -178,7 +178,7 @@ fn main() -> void { return; })");
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_InvalidHeader) {
|
||||
auto* p = parser("fn main() -> { }");
|
||||
auto p = parser("fn main() -> { }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -192,7 +192,7 @@ TEST_F(ParserImplTest, FunctionDecl_InvalidHeader) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_InvalidBody) {
|
||||
auto* p = parser("fn main() -> void { return }");
|
||||
auto p = parser("fn main() -> void { return }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -206,7 +206,7 @@ TEST_F(ParserImplTest, FunctionDecl_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_MissingLeftBrace) {
|
||||
auto* p = parser("fn main() -> void return; }");
|
||||
auto p = parser("fn main() -> void return; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_Parses) {
|
||||
auto* p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)]]");
|
||||
auto p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_Empty) {
|
||||
auto* p = parser("[[]]");
|
||||
auto p = parser("[[]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_Invalid) {
|
||||
auto* p = parser("[[invalid]]");
|
||||
auto p = parser("[[invalid]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_ExtraComma) {
|
||||
auto* p = parser("[[workgroup_size(2), ]]");
|
||||
auto p = parser("[[workgroup_size(2), ]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_ExtraComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_MissingComma) {
|
||||
auto* p = parser("[[workgroup_size(2) workgroup_size(2)]]");
|
||||
auto p = parser("[[workgroup_size(2) workgroup_size(2)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_MissingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_BadDecoration) {
|
||||
auto* p = parser("[[workgroup_size()]]");
|
||||
auto p = parser("[[workgroup_size()]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_BadDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecorationList_MissingRightAttr) {
|
||||
auto* p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)");
|
||||
auto p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup) {
|
||||
auto* p = parser("workgroup_size(4)");
|
||||
auto p = parser("workgroup_size(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_2Param) {
|
||||
auto* p = parser("workgroup_size(4, 5)");
|
||||
auto p = parser("workgroup_size(4, 5)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_2Param) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_3Param) {
|
||||
auto* p = parser("workgroup_size(4, 5, 6)");
|
||||
auto p = parser("workgroup_size(4, 5, 6)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -84,7 +84,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_3Param) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_TooManyValues) {
|
||||
auto* p = parser("workgroup_size(1, 2, 3, 4)");
|
||||
auto p = parser("workgroup_size(1, 2, 3, 4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_TooManyValues) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_X_Value) {
|
||||
auto* p = parser("workgroup_size(-2, 5, 6)");
|
||||
auto p = parser("workgroup_size(-2, 5, 6)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -105,7 +105,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_X_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Y_Value) {
|
||||
auto* p = parser("workgroup_size(4, 0, 6)");
|
||||
auto p = parser("workgroup_size(4, 0, 6)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -116,7 +116,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Y_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Z_Value) {
|
||||
auto* p = parser("workgroup_size(4, 5, -3)");
|
||||
auto p = parser("workgroup_size(4, 5, -3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Z_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingLeftParam) {
|
||||
auto* p = parser("workgroup_size 4, 5, 6)");
|
||||
auto p = parser("workgroup_size 4, 5, 6)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -137,7 +137,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingLeftParam) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingRightParam) {
|
||||
auto* p = parser("workgroup_size(4, 5, 6");
|
||||
auto p = parser("workgroup_size(4, 5, 6");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -147,7 +147,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingRightParam) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingValues) {
|
||||
auto* p = parser("workgroup_size()");
|
||||
auto p = parser("workgroup_size()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingValues) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Value) {
|
||||
auto* p = parser("workgroup_size(, 2, 3)");
|
||||
auto p = parser("workgroup_size(, 2, 3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -171,7 +171,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Comma) {
|
||||
auto* p = parser("workgroup_size(1 2, 3)");
|
||||
auto p = parser("workgroup_size(1 2, 3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -181,7 +181,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Comma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Value) {
|
||||
auto* p = parser("workgroup_size(1, , 3)");
|
||||
auto p = parser("workgroup_size(1, , 3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -193,7 +193,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Comma) {
|
||||
auto* p = parser("workgroup_size(1, 2 3)");
|
||||
auto p = parser("workgroup_size(1, 2 3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -203,7 +203,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Comma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Value) {
|
||||
auto* p = parser("workgroup_size(1, 2, )");
|
||||
auto p = parser("workgroup_size(1, 2, )");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -215,7 +215,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Invalid) {
|
||||
auto* p = parser("workgroup_size(nan)");
|
||||
auto p = parser("workgroup_size(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -227,7 +227,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Invalid) {
|
||||
auto* p = parser("workgroup_size(2, nan)");
|
||||
auto p = parser("workgroup_size(2, nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -239,7 +239,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Invalid) {
|
||||
auto* p = parser("workgroup_size(2, 3, nan)");
|
||||
auto p = parser("workgroup_size(2, 3, nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -251,7 +251,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Stage) {
|
||||
auto* p = parser("stage(compute)");
|
||||
auto p = parser("stage(compute)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -264,7 +264,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingValue) {
|
||||
auto* p = parser("stage()");
|
||||
auto p = parser("stage()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -274,7 +274,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingInvalid) {
|
||||
auto* p = parser("stage(nan)");
|
||||
auto p = parser("stage(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -284,7 +284,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingLeftParen) {
|
||||
auto* p = parser("stage compute)");
|
||||
auto p = parser("stage compute)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -294,7 +294,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingRightParen) {
|
||||
auto* p = parser("stage(compute");
|
||||
auto p = parser("stage(compute");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader) {
|
||||
auto* p = parser("fn main(a : i32, b: f32) -> void");
|
||||
auto p = parser("fn main(a : i32, b: f32) -> void");
|
||||
auto f = p->function_header();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(f.matched);
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, FunctionHeader) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
||||
auto* p = parser("fn () -> void");
|
||||
auto p = parser("fn () -> void");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidIdent) {
|
||||
auto* p = parser("fn 133main() -> i32");
|
||||
auto p = parser("fn 133main() -> i32");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingParenLeft) {
|
||||
auto* p = parser("fn main) -> i32");
|
||||
auto p = parser("fn main) -> i32");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingParenLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidParamList) {
|
||||
auto* p = parser("fn main(a :i32,) -> i32");
|
||||
auto p = parser("fn main(a :i32,) -> i32");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidParamList) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingParenRight) {
|
||||
auto* p = parser("fn main( -> i32");
|
||||
auto p = parser("fn main( -> i32");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -89,7 +89,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingParenRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingArrow) {
|
||||
auto* p = parser("fn main() i32");
|
||||
auto p = parser("fn main() i32");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -99,7 +99,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingArrow) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidReturnType) {
|
||||
auto* p = parser("fn main() -> invalid");
|
||||
auto p = parser("fn main() -> invalid");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
@ -109,7 +109,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidReturnType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingReturnType) {
|
||||
auto* p = parser("fn main() ->");
|
||||
auto p = parser("fn main() ->");
|
||||
auto f = p->function_header();
|
||||
EXPECT_FALSE(f.matched);
|
||||
EXPECT_TRUE(f.errored);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
||||
auto* v = tm()->Get(std::make_unique<ast::type::VoidType>());
|
||||
|
||||
auto* p = parser("void");
|
||||
auto p = parser("void");
|
||||
auto e = p->function_type_decl();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
|||
auto* f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
|
||||
auto* p = parser("vec2<f32>");
|
||||
auto p = parser("vec2<f32>");
|
||||
auto e = p->function_type_decl();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_InvalidType) {
|
||||
auto* p = parser("vec2<invalid>");
|
||||
auto p = parser("vec2<invalid>");
|
||||
auto e = p->function_type_decl();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl) {
|
||||
auto* p = parser("const a : f32 = 1.");
|
||||
auto p = parser("const a : f32 = 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
||||
auto* p = parser("const a: f32 1.");
|
||||
auto p = parser("const a: f32 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -56,7 +56,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_InvalidVariable) {
|
||||
auto* p = parser("const a: invalid = 1.");
|
||||
auto p = parser("const a: invalid = 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -66,7 +66,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_InvalidVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_InvalidExpression) {
|
||||
auto* p = parser("const a: f32 = if (a) {}");
|
||||
auto p = parser("const a: f32 = if (a) {}");
|
||||
auto e = p->global_constant_decl();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -76,7 +76,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingExpression) {
|
||||
auto* p = parser("const a: f32 =");
|
||||
auto p = parser("const a: f32 =");
|
||||
auto e = p->global_constant_decl();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -24,13 +24,13 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Semicolon) {
|
||||
auto* p = parser(";");
|
||||
auto p = parser(";");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable) {
|
||||
auto* p = parser("var<out> a : vec2<i32> = vec2<i32>(1, 2);");
|
||||
auto p = parser("var<out> a : vec2<i32> = vec2<i32>(1, 2);");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -42,21 +42,21 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_Invalid) {
|
||||
auto* p = parser("var<out> a : vec2<invalid>;");
|
||||
auto p = parser("var<out> a : vec2<invalid>;");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:19: unknown constructed type 'invalid'");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_MissingSemicolon) {
|
||||
auto* p = parser("var<out> a : vec2<i32>");
|
||||
auto p = parser("var<out> a : vec2<i32>");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:23: expected ';' for variable declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant) {
|
||||
auto* p = parser("const a : i32 = 2;");
|
||||
auto p = parser("const a : i32 = 2;");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -68,21 +68,21 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalConstant) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant_Invalid) {
|
||||
auto* p = parser("const a : vec2<i32>;");
|
||||
auto p = parser("const a : vec2<i32>;");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:20: expected '=' for constant declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant_MissingSemicolon) {
|
||||
auto* p = parser("const a : vec2<i32> = vec2<i32>(1, 2)");
|
||||
auto p = parser("const a : vec2<i32> = vec2<i32>(1, 2)");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:38: expected ';' for constant declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
||||
auto* p = parser("type A = i32;");
|
||||
auto p = parser("type A = i32;");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -93,7 +93,7 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
|
||||
auto* p = parser(R"(struct A {
|
||||
auto p = parser(R"(struct A {
|
||||
a : f32;
|
||||
};
|
||||
type B = A;)");
|
||||
|
@ -114,21 +114,21 @@ type B = A;)");
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_Invalid) {
|
||||
auto* p = parser("type A = invalid;");
|
||||
auto p = parser("type A = invalid;");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:10: unknown constructed type 'invalid'");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) {
|
||||
auto* p = parser("type A = i32");
|
||||
auto p = parser("type A = i32");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:13: expected ';' for type alias");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function) {
|
||||
auto* p = parser("fn main() -> void { return; }");
|
||||
auto p = parser("fn main() -> void { return; }");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, GlobalDecl_Function) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) {
|
||||
auto* p = parser("[[workgroup_size(2)]] fn main() -> void { return; }");
|
||||
auto p = parser("[[workgroup_size(2)]] fn main() -> void { return; }");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -148,14 +148,14 @@ TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function_Invalid) {
|
||||
auto* p = parser("fn main() -> { return; }");
|
||||
auto p = parser("fn main() -> { return; }");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:14: unable to determine function return type");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
||||
auto* p = parser("struct A { b: i32; c: f32;};");
|
||||
auto p = parser("struct A { b: i32; c: f32;};");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -172,7 +172,7 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
||||
auto* p =
|
||||
auto p =
|
||||
parser("struct A { [[offset(0)]] data: [[stride(4)]] array<f32>; };");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -197,7 +197,7 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
|
||||
auto* p = parser("[[block]] struct A { [[offset(0)]] data: f32; };");
|
||||
auto p = parser("[[block]] struct A { [[offset(0)]] data: f32; };");
|
||||
p->expect_global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -215,14 +215,14 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Struct_Invalid) {
|
||||
auto* p = parser("[[block]] A {};");
|
||||
auto p = parser("[[block]] A {};");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:11: expected declaration after decorations");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_StructMissing_Semi) {
|
||||
auto* p = parser("[[block]] struct A {}");
|
||||
auto p = parser("[[block]] struct A {}");
|
||||
p->expect_global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:22: expected ';' for struct declaration");
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
||||
auto* p = parser("var<out> a : f32");
|
||||
auto p = parser("var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
||||
auto* p = parser("var<out> a : f32 = 1.");
|
||||
auto p = parser("var<out> a : f32 = 1.");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -75,7 +75,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||
auto* p = parser("[[binding(2), set(1)]] var<out> a : f32");
|
||||
auto p = parser("[[binding(2), set(1)]] var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -108,7 +108,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
||||
auto* p = parser("[[binding(2)]] [[set(1)]] var<out> a : f32");
|
||||
auto p = parser("[[binding(2)]] [[set(1)]] var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -142,7 +142,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
||||
auto* p = parser("[[binding()]] var<out> a : f32");
|
||||
auto p = parser("[[binding()]] var<out> a : f32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -158,7 +158,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidConstExpr) {
|
||||
auto* p = parser("var<out> a : f32 = if (a) {}");
|
||||
auto p = parser("var<out> a : f32 = if (a) {}");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -171,7 +171,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_InvalidConstExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidVariableDecl) {
|
||||
auto* p = parser("var<invalid> a : f32;");
|
||||
auto p = parser("var<invalid> a : f32;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt) {
|
||||
auto* p = parser("if (a == 4) { a = b; c = d; }");
|
||||
auto p = parser("if (a == 4) { a = b; c = d; }");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -39,8 +39,7 @@ TEST_F(ParserImplTest, IfStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_WithElse) {
|
||||
auto* p =
|
||||
parser("if (a == 4) { a = b; c = d; } elseif(c) { d = 2; } else {}");
|
||||
auto p = parser("if (a == 4) { a = b; c = d; } elseif(c) { d = 2; } else {}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -62,7 +61,7 @@ TEST_F(ParserImplTest, IfStmt_WithElse) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidCondition) {
|
||||
auto* p = parser("if (a = 3) {}");
|
||||
auto p = parser("if (a = 3) {}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -72,7 +71,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidCondition) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_MissingCondition) {
|
||||
auto* p = parser("if {}");
|
||||
auto p = parser("if {}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -82,7 +81,7 @@ TEST_F(ParserImplTest, IfStmt_MissingCondition) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidBody) {
|
||||
auto* p = parser("if (a) { fn main() -> void {}}");
|
||||
auto p = parser("if (a) { fn main() -> void {}}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -92,7 +91,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_MissingBody) {
|
||||
auto* p = parser("if (a)");
|
||||
auto p = parser("if (a)");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -102,7 +101,7 @@ TEST_F(ParserImplTest, IfStmt_MissingBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidElseif) {
|
||||
auto* p = parser("if (a) {} elseif (a) { fn main() -> a{}}");
|
||||
auto p = parser("if (a) {} elseif (a) { fn main() -> a{}}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -112,7 +111,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidElseif) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidElse) {
|
||||
auto* p = parser("if (a) {} else { fn main() -> a{}}");
|
||||
auto p = parser("if (a) {} else { fn main() -> a{}}");
|
||||
auto e = p->if_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ImageStorageType_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
||||
auto* p = parser("r8unorm");
|
||||
auto p = parser("r8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Unorm);
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
||||
auto* p = parser("r8snorm");
|
||||
auto p = parser("r8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Snorm);
|
||||
|
@ -47,7 +47,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
||||
auto* p = parser("r8uint");
|
||||
auto p = parser("r8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Uint);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
||||
auto* p = parser("r8sint");
|
||||
auto p = parser("r8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Sint);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
||||
auto* p = parser("r16uint");
|
||||
auto p = parser("r16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Uint);
|
||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
||||
auto* p = parser("r16sint");
|
||||
auto p = parser("r16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Sint);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
||||
auto* p = parser("r16float");
|
||||
auto p = parser("r16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Float);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
||||
auto* p = parser("rg8unorm");
|
||||
auto p = parser("rg8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Unorm);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
||||
auto* p = parser("rg8snorm");
|
||||
auto p = parser("rg8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Snorm);
|
||||
|
@ -103,7 +103,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
||||
auto* p = parser("rg8uint");
|
||||
auto p = parser("rg8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Uint);
|
||||
|
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
||||
auto* p = parser("rg8sint");
|
||||
auto p = parser("rg8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Sint);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
||||
auto* p = parser("r32uint");
|
||||
auto p = parser("r32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Uint);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
||||
auto* p = parser("r32sint");
|
||||
auto p = parser("r32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Sint);
|
||||
|
@ -135,7 +135,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
||||
auto* p = parser("r32float");
|
||||
auto p = parser("r32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Float);
|
||||
|
@ -143,7 +143,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
||||
auto* p = parser("rg16uint");
|
||||
auto p = parser("rg16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Uint);
|
||||
|
@ -151,7 +151,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
||||
auto* p = parser("rg16sint");
|
||||
auto p = parser("rg16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Sint);
|
||||
|
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
||||
auto* p = parser("rg16float");
|
||||
auto p = parser("rg16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Float);
|
||||
|
@ -167,7 +167,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
||||
auto* p = parser("rgba8unorm");
|
||||
auto p = parser("rgba8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Unorm);
|
||||
|
@ -175,7 +175,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
||||
auto* p = parser("rgba8unorm_srgb");
|
||||
auto p = parser("rgba8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8UnormSrgb);
|
||||
|
@ -183,7 +183,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
||||
auto* p = parser("rgba8snorm");
|
||||
auto p = parser("rgba8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Snorm);
|
||||
|
@ -191,7 +191,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
||||
auto* p = parser("rgba8uint");
|
||||
auto p = parser("rgba8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Uint);
|
||||
|
@ -199,7 +199,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
||||
auto* p = parser("rgba8sint");
|
||||
auto p = parser("rgba8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Sint);
|
||||
|
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
||||
auto* p = parser("bgra8unorm");
|
||||
auto p = parser("bgra8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8Unorm);
|
||||
|
@ -215,7 +215,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
||||
auto* p = parser("bgra8unorm_srgb");
|
||||
auto p = parser("bgra8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8UnormSrgb);
|
||||
|
@ -223,7 +223,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
||||
auto* p = parser("rgb10a2unorm");
|
||||
auto p = parser("rgb10a2unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgb10A2Unorm);
|
||||
|
@ -231,7 +231,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
||||
auto* p = parser("rg11b10float");
|
||||
auto p = parser("rg11b10float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg11B10Float);
|
||||
|
@ -239,7 +239,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
||||
auto* p = parser("rg32uint");
|
||||
auto p = parser("rg32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Uint);
|
||||
|
@ -247,7 +247,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
||||
auto* p = parser("rg32sint");
|
||||
auto p = parser("rg32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Sint);
|
||||
|
@ -255,7 +255,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
||||
auto* p = parser("rg32float");
|
||||
auto p = parser("rg32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Float);
|
||||
|
@ -263,7 +263,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
||||
auto* p = parser("rgba16uint");
|
||||
auto p = parser("rgba16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Uint);
|
||||
|
@ -271,7 +271,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
||||
auto* p = parser("rgba16sint");
|
||||
auto p = parser("rgba16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Sint);
|
||||
|
@ -279,7 +279,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
||||
auto* p = parser("rgba16float");
|
||||
auto p = parser("rgba16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Float);
|
||||
|
@ -287,7 +287,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
||||
auto* p = parser("rgba32uint");
|
||||
auto p = parser("rgba32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Uint);
|
||||
|
@ -295,7 +295,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
||||
auto* p = parser("rgba32sint");
|
||||
auto p = parser("rgba32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Sint);
|
||||
|
@ -303,7 +303,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
|
||||
auto* p = parser("rgba32float");
|
||||
auto p = parser("rgba32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Float);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_Parses) {
|
||||
auto* p = parser("a | true");
|
||||
auto p = parser("a | true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, InclusiveOrExpression_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} | true");
|
||||
auto p = parser("if (a) {} | true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, InclusiveOrExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidRHS) {
|
||||
auto* p = parser("true | if (a) {}");
|
||||
auto p = parser("true | if (a) {}");
|
||||
auto e = p->inclusive_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, InclusiveOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_Parses) {
|
||||
auto* p = parser("a && true");
|
||||
auto p = parser("a && true");
|
||||
auto e = p->logical_and_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, LogicalAndExpression_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} && true");
|
||||
auto p = parser("if (a) {} && true");
|
||||
auto e = p->logical_and_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, LogicalAndExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_InvalidRHS) {
|
||||
auto* p = parser("true && if (a) {}");
|
||||
auto p = parser("true && if (a) {}");
|
||||
auto e = p->logical_and_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, LogicalAndExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->logical_and_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_Parses) {
|
||||
auto* p = parser("a || true");
|
||||
auto p = parser("a || true");
|
||||
auto e = p->logical_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, LogicalOrExpression_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} || true");
|
||||
auto p = parser("if (a) {} || true");
|
||||
auto e = p->logical_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, LogicalOrExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_InvalidRHS) {
|
||||
auto* p = parser("true || if (a) {}");
|
||||
auto p = parser("true || if (a) {}");
|
||||
auto e = p->logical_or_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, LogicalOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->logical_or_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_BodyNoContinuing) {
|
||||
auto* p = parser("loop { discard; }");
|
||||
auto p = parser("loop { discard; }");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -36,7 +36,7 @@ TEST_F(ParserImplTest, LoopStmt_BodyNoContinuing) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_BodyWithContinuing) {
|
||||
auto* p = parser("loop { discard; continuing { discard; }}");
|
||||
auto p = parser("loop { discard; continuing { discard; }}");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, LoopStmt_BodyWithContinuing) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_NoBodyNoContinuing) {
|
||||
auto* p = parser("loop { }");
|
||||
auto p = parser("loop { }");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, LoopStmt_NoBodyNoContinuing) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_NoBodyWithContinuing) {
|
||||
auto* p = parser("loop { continuing { discard; }}");
|
||||
auto p = parser("loop { continuing { discard; }}");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -74,7 +74,7 @@ TEST_F(ParserImplTest, LoopStmt_NoBodyWithContinuing) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_MissingBracketLeft) {
|
||||
auto* p = parser("loop discard; }");
|
||||
auto p = parser("loop discard; }");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -84,7 +84,7 @@ TEST_F(ParserImplTest, LoopStmt_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_MissingBracketRight) {
|
||||
auto* p = parser("loop { discard; ");
|
||||
auto p = parser("loop { discard; ");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, LoopStmt_MissingBracketRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_InvalidStatements) {
|
||||
auto* p = parser("loop { discard }");
|
||||
auto p = parser("loop { discard }");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ParserImplTest, LoopStmt_InvalidStatements) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_InvalidContinuing) {
|
||||
auto* p = parser("loop { continuing { discard }}");
|
||||
auto p = parser("loop { continuing { discard }}");
|
||||
auto e = p->loop_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) {
|
||||
auto* p = parser("a * true");
|
||||
auto p = parser("a * true");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) {
|
||||
auto* p = parser("a / true");
|
||||
auto p = parser("a / true");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) {
|
||||
auto* p = parser("a % true");
|
||||
auto p = parser("a % true");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} * true");
|
||||
auto p = parser("if (a) {} * true");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_InvalidRHS) {
|
||||
auto* p = parser("true * if (a) {}");
|
||||
auto p = parser("true * if (a) {}");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -114,7 +114,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->multiplicative_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace {
|
|||
TEST_F(ParserImplTest, ParamList_Single) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser("a : i32");
|
||||
auto p = parser("a : i32");
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -52,7 +52,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
auto* f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
|
||||
auto* p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_Empty) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ParamList_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_HangingComma) {
|
||||
auto* p = parser("a : i32,");
|
||||
auto p = parser("a : i32,");
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt) {
|
||||
auto* p = parser("(a + b)");
|
||||
auto p = parser("(a + b)");
|
||||
auto e = p->expect_paren_rhs_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(e.errored);
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ParenRhsStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) {
|
||||
auto* p = parser("true)");
|
||||
auto p = parser("true)");
|
||||
auto e = p->expect_paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) {
|
||||
auto* p = parser("(true");
|
||||
auto p = parser("(true");
|
||||
auto e = p->expect_paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) {
|
||||
auto* p = parser("(if (a() {})");
|
||||
auto p = parser("(if (a() {})");
|
||||
auto e = p->expect_paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingExpression) {
|
||||
auto* p = parser("()");
|
||||
auto p = parser("()");
|
||||
auto e = p->expect_paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(e.errored);
|
||||
|
|
|
@ -34,7 +34,7 @@ class PipelineStageTest : public ParserImplTestWithParam<PipelineStageData> {};
|
|||
|
||||
TEST_P(PipelineStageTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
|
||||
auto stage = p->expect_pipeline_stage();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -57,7 +57,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
PipelineStageData{"compute", ast::PipelineStage::kCompute}));
|
||||
|
||||
TEST_F(ParserImplTest, PipelineStage_NoMatch) {
|
||||
auto* p = parser("not-a-stage");
|
||||
auto p = parser("not-a-stage");
|
||||
auto stage = p->expect_pipeline_stage();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(stage.errored);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) {
|
||||
auto* p = parser("a[1]");
|
||||
auto p = parser("a[1]");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_ExpressionIndex) {
|
||||
auto* p = parser("a[1 + b / 4]");
|
||||
auto p = parser("a[1 + b / 4]");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ExpressionIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_MissingIndex) {
|
||||
auto* p = parser("a[]");
|
||||
auto p = parser("a[]");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_MissingIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_MissingRightBrace) {
|
||||
auto* p = parser("a[1");
|
||||
auto p = parser("a[1");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -89,7 +89,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_MissingRightBrace) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_InvalidIndex) {
|
||||
auto* p = parser("a[if(a() {})]");
|
||||
auto p = parser("a[if(a() {})]");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -99,7 +99,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_InvalidIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_Empty) {
|
||||
auto* p = parser("a()");
|
||||
auto p = parser("a()");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -117,7 +117,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_WithArgs) {
|
||||
auto* p = parser("test(1, b, 2 + 3 / b)");
|
||||
auto p = parser("test(1, b, 2 + 3 / b)");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_WithArgs) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_InvalidArg) {
|
||||
auto* p = parser("a(if(a) {})");
|
||||
auto p = parser("a(if(a) {})");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_InvalidArg) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_HangingComma) {
|
||||
auto* p = parser("a(b, )");
|
||||
auto p = parser("a(b, )");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -158,7 +158,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_HangingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) {
|
||||
auto* p = parser("a(");
|
||||
auto p = parser("a(");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -168,7 +168,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
||||
auto* p = parser("a.b");
|
||||
auto p = parser("a.b");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -185,7 +185,7 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
||||
auto* p = parser("a.if");
|
||||
auto p = parser("a.if");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -195,7 +195,7 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor_MissingIdent) {
|
||||
auto* p = parser("a.");
|
||||
auto p = parser("a.");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -205,7 +205,7 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccessor_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_NonMatch_returnLHS) {
|
||||
auto* p = parser("a b");
|
||||
auto p = parser("a b");
|
||||
auto e = p->postfix_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Ident) {
|
||||
auto* p = parser("a");
|
||||
auto p = parser("a");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
||||
auto* p = parser("vec4<i32>(1, 2, 3, 4))");
|
||||
auto p = parser("vec4<i32>(1, 2, 3, 4))");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_ZeroConstructor) {
|
||||
auto* p = parser("vec4<i32>()");
|
||||
auto p = parser("vec4<i32>()");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -97,7 +97,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_ZeroConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidTypeDecl) {
|
||||
auto* p = parser("vec4<if>(2., 3., 4., 5.)");
|
||||
auto p = parser("vec4<if>(2., 3., 4., 5.)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -107,7 +107,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidTypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingLeftParen) {
|
||||
auto* p = parser("vec4<f32> 2., 3., 4., 5.)");
|
||||
auto p = parser("vec4<f32> 2., 3., 4., 5.)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -117,7 +117,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
||||
auto* p = parser("vec4<f32>(2., 3., 4., 5.");
|
||||
auto p = parser("vec4<f32>(2., 3., 4., 5.");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
||||
auto* p = parser("i32(if(a) {})");
|
||||
auto p = parser("i32(if(a) {})");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -137,7 +137,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ConstLiteral_True) {
|
||||
auto* p = parser("true");
|
||||
auto p = parser("true");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -151,7 +151,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ConstLiteral_True) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr) {
|
||||
auto* p = parser("(a == b)");
|
||||
auto p = parser("(a == b)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -161,7 +161,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingRightParen) {
|
||||
auto* p = parser("(a == b");
|
||||
auto p = parser("(a == b");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -171,7 +171,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingExpr) {
|
||||
auto* p = parser("()");
|
||||
auto p = parser("()");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -181,7 +181,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_InvalidExpr) {
|
||||
auto* p = parser("(if (a) {})");
|
||||
auto p = parser("(if (a) {})");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -193,7 +193,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_InvalidExpr) {
|
|||
TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
||||
auto* f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
|
||||
auto* p = parser("f32(1)");
|
||||
auto p = parser("f32(1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -213,7 +213,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
|||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
|
||||
auto* f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
|
||||
auto* p = parser("bitcast<f32>(1)");
|
||||
auto p = parser("bitcast<f32>(1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -229,7 +229,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingGreaterThan) {
|
||||
auto* p = parser("bitcast<f32(1)");
|
||||
auto p = parser("bitcast<f32(1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -239,7 +239,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingType) {
|
||||
auto* p = parser("bitcast<>(1)");
|
||||
auto p = parser("bitcast<>(1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -249,7 +249,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_InvalidType) {
|
||||
auto* p = parser("bitcast<invalid>(1)");
|
||||
auto p = parser("bitcast<invalid>(1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -259,7 +259,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_InvalidType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingLeftParen) {
|
||||
auto* p = parser("bitcast<f32>1)");
|
||||
auto p = parser("bitcast<f32>1)");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -269,7 +269,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingRightParen) {
|
||||
auto* p = parser("bitcast<f32>(1");
|
||||
auto p = parser("bitcast<f32>(1");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -279,7 +279,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingExpression) {
|
||||
auto* p = parser("bitcast<f32>()");
|
||||
auto p = parser("bitcast<f32>()");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -289,7 +289,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_bitcast_InvalidExpression) {
|
||||
auto* p = parser("bitcast<f32>(if (a) {})");
|
||||
auto p = parser("bitcast<f32>(if (a) {})");
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) {
|
||||
auto* p = parser("a < true");
|
||||
auto p = parser("a < true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) {
|
||||
auto* p = parser("a > true");
|
||||
auto p = parser("a > true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) {
|
||||
auto* p = parser("a <= true");
|
||||
auto p = parser("a <= true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) {
|
||||
auto* p = parser("a >= true");
|
||||
auto p = parser("a >= true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} < true");
|
||||
auto p = parser("if (a) {} < true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
|
||||
auto* p = parser("true < if (a) {}");
|
||||
auto p = parser("true < if (a) {}");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
|
@ -135,7 +135,7 @@ TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->relational_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_FALSE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, SampledTextureType_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_1d_Old) {
|
||||
auto* p = parser("texture_sampled_1d");
|
||||
auto p = parser("texture_sampled_1d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_1dArray_Old) {
|
||||
auto* p = parser("texture_sampled_1d_array");
|
||||
auto p = parser("texture_sampled_1d_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, SampledTextureType_1dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_2d_Old) {
|
||||
auto* p = parser("texture_sampled_2d");
|
||||
auto p = parser("texture_sampled_2d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -58,7 +58,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_2dArray_Old) {
|
||||
auto* p = parser("texture_sampled_2d_array");
|
||||
auto p = parser("texture_sampled_2d_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_3d_Old) {
|
||||
auto* p = parser("texture_sampled_3d");
|
||||
auto p = parser("texture_sampled_3d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -76,7 +76,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_Cube_Old) {
|
||||
auto* p = parser("texture_sampled_cube");
|
||||
auto p = parser("texture_sampled_cube");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_kCubeArray_Old) {
|
||||
auto* p = parser("texture_sampled_cube_array");
|
||||
auto p = parser("texture_sampled_cube_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_1d) {
|
||||
auto* p = parser("texture_1d");
|
||||
auto p = parser("texture_1d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -103,7 +103,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_1dArray) {
|
||||
auto* p = parser("texture_1d_array");
|
||||
auto p = parser("texture_1d_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -112,7 +112,7 @@ TEST_F(ParserImplTest, SampledTextureType_1dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_2d) {
|
||||
auto* p = parser("texture_2d");
|
||||
auto p = parser("texture_2d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -121,7 +121,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
||||
auto* p = parser("texture_2d_array");
|
||||
auto p = parser("texture_2d_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -130,7 +130,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_3d) {
|
||||
auto* p = parser("texture_3d");
|
||||
auto p = parser("texture_3d");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
||||
auto* p = parser("texture_cube");
|
||||
auto p = parser("texture_cube");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
|
||||
auto* p = parser("texture_cube_array");
|
||||
auto p = parser("texture_cube_array");
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, SamplerType_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->sampler_type();
|
||||
EXPECT_FALSE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, SamplerType_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SamplerType_Sampler) {
|
||||
auto* p = parser("sampler");
|
||||
auto p = parser("sampler");
|
||||
auto t = p->sampler_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
|
||||
auto* p = parser("sampler_comparison");
|
||||
auto p = parser("sampler_comparison");
|
||||
auto t = p->sampler_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftLeft) {
|
||||
auto* p = parser("a << true");
|
||||
auto p = parser("a << true");
|
||||
auto e = p->shift_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) {
|
||||
auto* p = parser("a >> true");
|
||||
auto p = parser("a >> true");
|
||||
auto e = p->shift_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ShiftExpression_InvalidLHS) {
|
||||
auto* p = parser("if (a) {} << true");
|
||||
auto p = parser("if (a) {} << true");
|
||||
auto e = p->shift_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ParserImplTest, ShiftExpression_InvalidLHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ShiftExpression_InvalidRHS) {
|
||||
auto* p = parser("true << if (a) {}");
|
||||
auto p = parser("true << if (a) {}");
|
||||
auto e = p->shift_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, ShiftExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ShiftExpression_NoOr_ReturnsLHS) {
|
||||
auto* p = parser("a true");
|
||||
auto p = parser("a true");
|
||||
auto e = p->shift_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, Statement) {
|
||||
auto* p = parser("return;");
|
||||
auto p = parser("return;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -33,13 +33,13 @@ TEST_F(ParserImplTest, Statement) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Semicolon) {
|
||||
auto* p = parser(";");
|
||||
auto p = parser(";");
|
||||
p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Return_NoValue) {
|
||||
auto* p = parser("return;");
|
||||
auto p = parser("return;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -50,7 +50,7 @@ TEST_F(ParserImplTest, Statement_Return_NoValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Return_Value) {
|
||||
auto* p = parser("return a + b * (.1 - .2);");
|
||||
auto p = parser("return a + b * (.1 - .2);");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, Statement_Return_Value) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Return_MissingSemi) {
|
||||
auto* p = parser("return");
|
||||
auto p = parser("return");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, Statement_Return_MissingSemi) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Return_Invalid) {
|
||||
auto* p = parser("return if(a) {};");
|
||||
auto p = parser("return if(a) {};");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ParserImplTest, Statement_Return_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_If) {
|
||||
auto* p = parser("if (a) {}");
|
||||
auto p = parser("if (a) {}");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -92,7 +92,7 @@ TEST_F(ParserImplTest, Statement_If) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_If_Invalid) {
|
||||
auto* p = parser("if (a) { fn main() -> {}}");
|
||||
auto p = parser("if (a) { fn main() -> {}}");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -102,7 +102,7 @@ TEST_F(ParserImplTest, Statement_If_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Variable) {
|
||||
auto* p = parser("var a : i32 = 1;");
|
||||
auto p = parser("var a : i32 = 1;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, Statement_Variable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Variable_Invalid) {
|
||||
auto* p = parser("var a : i32 =;");
|
||||
auto p = parser("var a : i32 =;");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -121,7 +121,7 @@ TEST_F(ParserImplTest, Statement_Variable_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Variable_MissingSemicolon) {
|
||||
auto* p = parser("var a : i32");
|
||||
auto p = parser("var a : i32");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -131,7 +131,7 @@ TEST_F(ParserImplTest, Statement_Variable_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Switch) {
|
||||
auto* p = parser("switch (a) {}");
|
||||
auto p = parser("switch (a) {}");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -140,7 +140,7 @@ TEST_F(ParserImplTest, Statement_Switch) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Switch_Invalid) {
|
||||
auto* p = parser("switch (a) { case: {}}");
|
||||
auto p = parser("switch (a) { case: {}}");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -150,7 +150,7 @@ TEST_F(ParserImplTest, Statement_Switch_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Loop) {
|
||||
auto* p = parser("loop {}");
|
||||
auto p = parser("loop {}");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -159,7 +159,7 @@ TEST_F(ParserImplTest, Statement_Loop) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Loop_Invalid) {
|
||||
auto* p = parser("loop discard; }");
|
||||
auto p = parser("loop discard; }");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -169,7 +169,7 @@ TEST_F(ParserImplTest, Statement_Loop_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Assignment) {
|
||||
auto* p = parser("a = b;");
|
||||
auto p = parser("a = b;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -178,7 +178,7 @@ TEST_F(ParserImplTest, Statement_Assignment) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Assignment_Invalid) {
|
||||
auto* p = parser("a = if(b) {};");
|
||||
auto p = parser("a = if(b) {};");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -188,7 +188,7 @@ TEST_F(ParserImplTest, Statement_Assignment_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Assignment_MissingSemicolon) {
|
||||
auto* p = parser("a = b");
|
||||
auto p = parser("a = b");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -198,7 +198,7 @@ TEST_F(ParserImplTest, Statement_Assignment_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Break) {
|
||||
auto* p = parser("break;");
|
||||
auto p = parser("break;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, Statement_Break) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Break_MissingSemicolon) {
|
||||
auto* p = parser("break");
|
||||
auto p = parser("break");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -217,7 +217,7 @@ TEST_F(ParserImplTest, Statement_Break_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Continue) {
|
||||
auto* p = parser("continue;");
|
||||
auto p = parser("continue;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -226,7 +226,7 @@ TEST_F(ParserImplTest, Statement_Continue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Continue_MissingSemicolon) {
|
||||
auto* p = parser("continue");
|
||||
auto p = parser("continue");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -236,7 +236,7 @@ TEST_F(ParserImplTest, Statement_Continue_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Discard) {
|
||||
auto* p = parser("discard;");
|
||||
auto p = parser("discard;");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
@ -246,7 +246,7 @@ TEST_F(ParserImplTest, Statement_Discard) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Discard_MissingSemicolon) {
|
||||
auto* p = parser("discard");
|
||||
auto p = parser("discard");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
|
@ -256,7 +256,7 @@ TEST_F(ParserImplTest, Statement_Discard_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Body) {
|
||||
auto* p = parser("{ var i: i32; }");
|
||||
auto p = parser("{ var i: i32; }");
|
||||
auto e = p->statement();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -266,7 +266,7 @@ TEST_F(ParserImplTest, Statement_Body) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Body_Invalid) {
|
||||
auto* p = parser("{ fn main() -> {}}");
|
||||
auto p = parser("{ fn main() -> {}}");
|
||||
auto e = p->statement();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, Statements) {
|
||||
auto* p = parser("discard; return;");
|
||||
auto p = parser("discard; return;");
|
||||
auto e = p->expect_statements();
|
||||
EXPECT_FALSE(e.errored);
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -33,7 +33,7 @@ TEST_F(ParserImplTest, Statements) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statements_Empty) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
auto e = p->expect_statements();
|
||||
EXPECT_FALSE(e.errored);
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
|
|
|
@ -35,7 +35,7 @@ class StorageClassTest : public ParserImplTestWithParam<StorageClassData> {};
|
|||
|
||||
TEST_P(StorageClassTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
|
||||
auto sc = p->expect_storage_class("test");
|
||||
EXPECT_FALSE(sc.errored);
|
||||
|
@ -61,7 +61,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
StorageClassData{"function", ast::StorageClass::kFunction}));
|
||||
|
||||
TEST_F(ParserImplTest, StorageClass_NoMatch) {
|
||||
auto* p = parser("not-a-storage-class");
|
||||
auto p = parser("not-a-storage-class");
|
||||
auto sc = p->expect_storage_class("test");
|
||||
EXPECT_EQ(sc.errored, true);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Invalid) {
|
||||
auto* p = parser("abc");
|
||||
auto p = parser("abc");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_FALSE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, StorageTextureType_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Readonly1d_Old) {
|
||||
auto* p = parser("texture_ro_1d");
|
||||
auto p = parser("texture_ro_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Readonly1dArray_Old) {
|
||||
auto* p = parser("texture_ro_1d_array");
|
||||
auto p = parser("texture_ro_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly1dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Readonly2d_Old) {
|
||||
auto* p = parser("texture_ro_2d");
|
||||
auto p = parser("texture_ro_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Readonly2dArray_Old) {
|
||||
auto* p = parser("texture_ro_2d_array");
|
||||
auto p = parser("texture_ro_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly2dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Readonly3d_Old) {
|
||||
auto* p = parser("texture_ro_3d");
|
||||
auto p = parser("texture_ro_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ParserImplTest, StorageTextureType_Readonly3d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Writeonly1d_Old) {
|
||||
auto* p = parser("texture_wo_1d");
|
||||
auto p = parser("texture_wo_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Writeonly1dArray_Old) {
|
||||
auto* p = parser("texture_wo_1d_array");
|
||||
auto p = parser("texture_wo_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -101,7 +101,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly1dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Writeonly2d_Old) {
|
||||
auto* p = parser("texture_wo_2d");
|
||||
auto p = parser("texture_wo_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -111,7 +111,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Writeonly2dArray_Old) {
|
||||
auto* p = parser("texture_wo_2d_array");
|
||||
auto p = parser("texture_wo_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -121,7 +121,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly2dArray_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_Writeonly3d_Old) {
|
||||
auto* p = parser("texture_wo_3d");
|
||||
auto p = parser("texture_wo_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -131,7 +131,7 @@ TEST_F(ParserImplTest, StorageTextureType_Writeonly3d_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_ro_1d) {
|
||||
auto* p = parser("texture_storage_ro_1d");
|
||||
auto p = parser("texture_storage_ro_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -141,7 +141,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_1d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_ro_1dArray) {
|
||||
auto* p = parser("texture_storage_ro_1d_array");
|
||||
auto p = parser("texture_storage_ro_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -151,7 +151,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_1dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_ro_2d) {
|
||||
auto* p = parser("texture_storage_ro_2d");
|
||||
auto p = parser("texture_storage_ro_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -161,7 +161,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_2d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_ro_2dArray) {
|
||||
auto* p = parser("texture_storage_ro_2d_array");
|
||||
auto p = parser("texture_storage_ro_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -171,7 +171,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_ro_3d) {
|
||||
auto* p = parser("texture_storage_ro_3d");
|
||||
auto p = parser("texture_storage_ro_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -181,7 +181,7 @@ TEST_F(ParserImplTest, StorageTextureType_ro_3d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_wo_1d) {
|
||||
auto* p = parser("texture_storage_wo_1d");
|
||||
auto p = parser("texture_storage_wo_1d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -191,7 +191,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_1d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_wo_1dArray) {
|
||||
auto* p = parser("texture_storage_wo_1d_array");
|
||||
auto p = parser("texture_storage_wo_1d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -201,7 +201,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_1dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_wo_2d) {
|
||||
auto* p = parser("texture_storage_wo_2d");
|
||||
auto p = parser("texture_storage_wo_2d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -211,7 +211,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_2d) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_wo_2dArray) {
|
||||
auto* p = parser("texture_storage_wo_2d_array");
|
||||
auto p = parser("texture_storage_wo_2d_array");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -221,7 +221,7 @@ TEST_F(ParserImplTest, StorageTextureType_wo_2dArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StorageTextureType_wo_3d) {
|
||||
auto* p = parser("texture_storage_wo_3d");
|
||||
auto p = parser("texture_storage_wo_3d");
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace {
|
|||
TEST_F(ParserImplTest, StructBodyDecl_Parses) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser("{a : i32;}");
|
||||
auto p = parser("{a : i32;}");
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_FALSE(m.errored);
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_ParsesEmpty) {
|
||||
auto* p = parser("{}");
|
||||
auto p = parser("{}");
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_FALSE(m.errored);
|
||||
|
@ -47,7 +47,7 @@ TEST_F(ParserImplTest, StructBodyDecl_ParsesEmpty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_InvalidMember) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
{
|
||||
[[offset(nan)]] a : i32;
|
||||
})");
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, StructBodyDecl_InvalidMember) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_MissingClosingBracket) {
|
||||
auto* p = parser("{a : i32;");
|
||||
auto p = parser("{a : i32;");
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(m.errored);
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, StructBodyDecl_MissingClosingBracket) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructBodyDecl_InvalidToken) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
{
|
||||
a : i32;
|
||||
1.23
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_Parses) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
struct S {
|
||||
a : i32;
|
||||
[[offset(4)]] b : f32;
|
||||
|
@ -45,7 +45,7 @@ struct S {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_ParsesWithDecoration) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
[[block]] struct B {
|
||||
a : f32;
|
||||
b : f32;
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
[[block]]
|
||||
[[block]] struct S {
|
||||
a : f32;
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_EmptyMembers) {
|
||||
auto* p = parser("struct S {}");
|
||||
auto p = parser("struct S {}");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -110,7 +110,7 @@ TEST_F(ParserImplTest, StructDecl_EmptyMembers) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_MissingIdent) {
|
||||
auto* p = parser("struct {}");
|
||||
auto p = parser("struct {}");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -126,7 +126,7 @@ TEST_F(ParserImplTest, StructDecl_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) {
|
||||
auto* p = parser("struct S }");
|
||||
auto p = parser("struct S }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -142,7 +142,7 @@ TEST_F(ParserImplTest, StructDecl_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_InvalidStructBody) {
|
||||
auto* p = parser("struct S { a : B; }");
|
||||
auto p = parser("struct S { a : B; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -158,7 +158,7 @@ TEST_F(ParserImplTest, StructDecl_InvalidStructBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_InvalidStructDecorationDecl) {
|
||||
auto* p = parser("[[block struct S { a : i32; }");
|
||||
auto p = parser("[[block struct S { a : i32; }");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -173,7 +173,7 @@ TEST_F(ParserImplTest, StructDecl_InvalidStructDecorationDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecl_MissingStruct) {
|
||||
auto* p = parser("[[block]] S {}");
|
||||
auto p = parser("[[block]] S {}");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, StructDecorationDecl_Parses) {
|
||||
auto* p = parser("[[block]]");
|
||||
auto p = parser("[[block]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -33,7 +33,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) {
|
||||
auto* p = parser("[[block");
|
||||
auto p = parser("[[block");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructDecorationDecl_InvalidDecoration) {
|
||||
auto* p = parser("[[invalid]]");
|
||||
auto p = parser("[[invalid]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
|
|
@ -36,7 +36,7 @@ class StructDecorationTest
|
|||
|
||||
TEST_P(StructDecorationTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
|
||||
auto deco = p->decoration();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -52,7 +52,7 @@ INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
|||
testing::Values(StructDecorationData{"block", true}));
|
||||
|
||||
TEST_F(ParserImplTest, StructDecoration_NoMatch) {
|
||||
auto* p = parser("not-a-stage");
|
||||
auto p = parser("not-a-stage");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyStr) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -32,7 +32,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyStr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyBlock) {
|
||||
auto* p = parser("[[]]");
|
||||
auto p = parser("[[]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -42,7 +42,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyBlock) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_Single) {
|
||||
auto* p = parser("[[offset(4)]]");
|
||||
auto p = parser("[[offset(4)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_Single) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_InvalidDecoration) {
|
||||
auto* p = parser("[[offset(nan)]]");
|
||||
auto p = parser("[[offset(nan)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecorationDecl_MissingClose) {
|
||||
auto* p = parser("[[offset(4)");
|
||||
auto p = parser("[[offset(4)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecoration_Offset) {
|
||||
auto* p = parser("offset(4)");
|
||||
auto p = parser("offset(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingLeftParen) {
|
||||
auto* p = parser("offset 4)");
|
||||
auto p = parser("offset 4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingRightParen) {
|
||||
auto* p = parser("offset(4");
|
||||
auto p = parser("offset(4");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingValue) {
|
||||
auto* p = parser("offset()");
|
||||
auto p = parser("offset()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -70,7 +70,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingInvalid) {
|
||||
auto* p = parser("offset(nan)");
|
||||
auto p = parser("offset(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace {
|
|||
TEST_F(ParserImplTest, StructMember_Parses) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser("a : i32;");
|
||||
auto p = parser("a : i32;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, StructMember_Parses) {
|
|||
TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser("[[offset(2)]] a : i32;");
|
||||
auto p = parser("[[offset(2)]] a : i32;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
|||
TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser(R"([[offset(2)]]
|
||||
auto p = parser(R"([[offset(2)]]
|
||||
[[offset(4)]] a : i32;)");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_InvalidDecoration) {
|
||||
auto* p = parser("[[offset(nan)]] a : i32;");
|
||||
auto p = parser("[[offset(nan)]] a : i32;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, StructMember_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_InvalidVariable) {
|
||||
auto* p = parser("[[offset(4)]] a : B;");
|
||||
auto p = parser("[[offset(4)]] a : B;");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_TRUE(decos.matched);
|
||||
|
@ -132,7 +132,7 @@ TEST_F(ParserImplTest, StructMember_InvalidVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, StructMember_MissingSemicolon) {
|
||||
auto* p = parser("a : i32");
|
||||
auto p = parser("a : i32");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_FALSE(decos.errored);
|
||||
EXPECT_FALSE(decos.matched);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case) {
|
||||
auto* p = parser("case 1: { a = 4; }");
|
||||
auto p = parser("case 1: { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -36,7 +36,7 @@ TEST_F(ParserImplTest, SwitchBody_Case) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_InvalidConstLiteral) {
|
||||
auto* p = parser("case a == 4: { a = 4; }");
|
||||
auto p = parser("case a == 4: { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_InvalidConstLiteral) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_InvalidSelector_bool) {
|
||||
auto* p = parser("case true: { a = 4; }");
|
||||
auto p = parser("case true: { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -56,7 +56,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_InvalidSelector_bool) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_MissingConstLiteral) {
|
||||
auto* p = parser("case: { a = 4; }");
|
||||
auto p = parser("case: { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -66,7 +66,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_MissingConstLiteral) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_MissingColon) {
|
||||
auto* p = parser("case 1 { a = 4; }");
|
||||
auto p = parser("case 1 { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -76,7 +76,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_MissingColon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_MissingBracketLeft) {
|
||||
auto* p = parser("case 1: a = 4; }");
|
||||
auto p = parser("case 1: a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -86,7 +86,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_MissingBracketRight) {
|
||||
auto* p = parser("case 1: { a = 4; ");
|
||||
auto p = parser("case 1: { a = 4; ");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -96,7 +96,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_MissingBracketRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Case_InvalidCaseBody) {
|
||||
auto* p = parser("case 1: { fn main() -> void {} }");
|
||||
auto p = parser("case 1: { fn main() -> void {} }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -106,7 +106,7 @@ TEST_F(ParserImplTest, SwitchBody_Case_InvalidCaseBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Default) {
|
||||
auto* p = parser("default: { a = 4; }");
|
||||
auto p = parser("default: { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, SwitchBody_Default) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Default_MissingColon) {
|
||||
auto* p = parser("default { a = 4; }");
|
||||
auto p = parser("default { a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -129,7 +129,7 @@ TEST_F(ParserImplTest, SwitchBody_Default_MissingColon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Default_MissingBracketLeft) {
|
||||
auto* p = parser("default: a = 4; }");
|
||||
auto p = parser("default: a = 4; }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ParserImplTest, SwitchBody_Default_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Default_MissingBracketRight) {
|
||||
auto* p = parser("default: { a = 4; ");
|
||||
auto p = parser("default: { a = 4; ");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -149,7 +149,7 @@ TEST_F(ParserImplTest, SwitchBody_Default_MissingBracketRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchBody_Default_InvalidCaseBody) {
|
||||
auto* p = parser("default: { fn main() -> void {} }");
|
||||
auto p = parser("default: { fn main() -> void {} }");
|
||||
auto e = p->switch_body();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_WithoutDefault) {
|
||||
auto* p = parser(R"(switch(a) {
|
||||
auto p = parser(R"(switch(a) {
|
||||
case 1: {}
|
||||
case 2: {}
|
||||
})");
|
||||
|
@ -40,7 +40,7 @@ TEST_F(ParserImplTest, SwitchStmt_WithoutDefault) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_Empty) {
|
||||
auto* p = parser("switch(a) { }");
|
||||
auto p = parser("switch(a) { }");
|
||||
auto e = p->switch_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, SwitchStmt_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_DefaultInMiddle) {
|
||||
auto* p = parser(R"(switch(a) {
|
||||
auto p = parser(R"(switch(a) {
|
||||
case 1: {}
|
||||
default: {}
|
||||
case 2: {}
|
||||
|
@ -70,7 +70,7 @@ TEST_F(ParserImplTest, SwitchStmt_DefaultInMiddle) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_InvalidExpression) {
|
||||
auto* p = parser("switch(a=b) {}");
|
||||
auto p = parser("switch(a=b) {}");
|
||||
auto e = p->switch_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -80,7 +80,7 @@ TEST_F(ParserImplTest, SwitchStmt_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_MissingExpression) {
|
||||
auto* p = parser("switch {}");
|
||||
auto p = parser("switch {}");
|
||||
auto e = p->switch_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -90,7 +90,7 @@ TEST_F(ParserImplTest, SwitchStmt_MissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_MissingBracketLeft) {
|
||||
auto* p = parser("switch(a) }");
|
||||
auto p = parser("switch(a) }");
|
||||
auto e = p->switch_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -100,7 +100,7 @@ TEST_F(ParserImplTest, SwitchStmt_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_MissingBracketRight) {
|
||||
auto* p = parser("switch(a) {");
|
||||
auto p = parser("switch(a) {");
|
||||
auto e = p->switch_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -110,7 +110,7 @@ TEST_F(ParserImplTest, SwitchStmt_MissingBracketRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, SwitchStmt_InvalidBody) {
|
||||
auto* p = parser(R"(switch(a) {
|
||||
auto p = parser(R"(switch(a) {
|
||||
case: {}
|
||||
})");
|
||||
auto e = p->switch_stmt();
|
||||
|
|
|
@ -24,12 +24,12 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, Empty) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
ASSERT_TRUE(p->Parse()) << p->error();
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Parses) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
[[location(0)]] var<out> gl_FragColor : vec4<f32>;
|
||||
|
||||
[[stage(vertex)]]
|
||||
|
@ -45,7 +45,7 @@ fn main() -> void {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, HandlesError) {
|
||||
auto* p = parser(R"(
|
||||
auto p = parser(R"(
|
||||
fn main() -> { # missing return type
|
||||
return;
|
||||
})");
|
||||
|
@ -56,7 +56,7 @@ fn main() -> { # missing return type
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GetRegisteredType) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
ast::type::I32Type i32;
|
||||
p->register_constructed("my_alias", &i32);
|
||||
|
||||
|
@ -66,7 +66,7 @@ TEST_F(ParserImplTest, GetRegisteredType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GetUnregisteredType) {
|
||||
auto* p = parser("");
|
||||
auto p = parser("");
|
||||
auto* alias = p->get_constructed("my_alias");
|
||||
ASSERT_EQ(alias, nullptr);
|
||||
}
|
||||
|
|
|
@ -21,15 +21,6 @@ ParserImplTest::ParserImplTest() = default;
|
|||
|
||||
ParserImplTest::~ParserImplTest() = default;
|
||||
|
||||
void ParserImplTest::SetUp() {
|
||||
ctx_.Reset();
|
||||
}
|
||||
|
||||
void ParserImplTest::TearDown() {
|
||||
impl_ = nullptr;
|
||||
files_.clear();
|
||||
}
|
||||
|
||||
} // namespace wgsl
|
||||
} // namespace reader
|
||||
} // namespace tint
|
||||
|
|
|
@ -35,20 +35,14 @@ class ParserImplTest : public testing::Test {
|
|||
ParserImplTest();
|
||||
~ParserImplTest() override;
|
||||
|
||||
/// Sets up the test helper
|
||||
void SetUp() override;
|
||||
|
||||
/// Tears down the test helper
|
||||
void TearDown() override;
|
||||
|
||||
/// Retrieves the parser from the helper
|
||||
/// @param str the string to parse
|
||||
/// @returns the parser implementation
|
||||
ParserImpl* parser(const std::string& str) {
|
||||
std::unique_ptr<ParserImpl> parser(const std::string& str) {
|
||||
auto file = std::make_unique<Source::File>("test.wgsl", str);
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
auto impl = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
files_.emplace_back(std::move(file));
|
||||
return impl_.get();
|
||||
return impl;
|
||||
}
|
||||
|
||||
/// @returns the type manager
|
||||
|
@ -56,7 +50,6 @@ class ParserImplTest : public testing::Test {
|
|||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
std::unique_ptr<ParserImpl> impl_;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
|
@ -68,23 +61,14 @@ class ParserImplTestWithParam : public testing::TestWithParam<T> {
|
|||
ParserImplTestWithParam() = default;
|
||||
~ParserImplTestWithParam() override = default;
|
||||
|
||||
/// Sets up the test helper
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
/// Tears down the test helper
|
||||
void TearDown() override {
|
||||
impl_ = nullptr;
|
||||
files_.clear();
|
||||
}
|
||||
|
||||
/// Retrieves the parser from the helper
|
||||
/// @param str the string to parse
|
||||
/// @returns the parser implementation
|
||||
ParserImpl* parser(const std::string& str) {
|
||||
std::unique_ptr<ParserImpl> parser(const std::string& str) {
|
||||
auto file = std::make_unique<Source::File>("test.wgsl", str);
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
auto impl = std::make_unique<ParserImpl>(&ctx_, file.get());
|
||||
files_.emplace_back(std::move(file));
|
||||
return impl_.get();
|
||||
return impl;
|
||||
}
|
||||
|
||||
/// @returns the type manager
|
||||
|
@ -92,7 +76,7 @@ class ParserImplTestWithParam : public testing::TestWithParam<T> {
|
|||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Source::File>> files_;
|
||||
std::unique_ptr<ParserImpl> impl_;
|
||||
std::unique_ptr<ParserImpl> impl;
|
||||
Context ctx_;
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -34,7 +34,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
|
||||
auto* p = parser("sampler");
|
||||
auto p = parser("sampler");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||
auto* p = parser("sampler_comparison");
|
||||
auto p = parser("sampler_comparison");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -56,7 +56,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||
auto* p = parser("texture_depth_2d");
|
||||
auto p = parser("texture_depth_2d");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
||||
auto* p = parser("texture_sampled_1d<f32>");
|
||||
auto p = parser("texture_sampled_1d<f32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
||||
auto* p = parser("texture_sampled_2d<i32>");
|
||||
auto p = parser("texture_sampled_2d<i32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
||||
auto* p = parser("texture_sampled_3d<u32>");
|
||||
auto p = parser("texture_sampled_3d<u32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -107,7 +107,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
|
||||
auto* p = parser("texture_sampled_1d<abc>");
|
||||
auto p = parser("texture_sampled_1d<abc>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -117,7 +117,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingType_Old) {
|
||||
auto* p = parser("texture_sampled_1d<>");
|
||||
auto p = parser("texture_sampled_1d<>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -127,7 +127,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingType_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingLessThan_Old) {
|
||||
auto* p = parser("texture_sampled_1d");
|
||||
auto p = parser("texture_sampled_1d");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -138,7 +138,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingLessThan_Old) {
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_SampledTexture_MissingGreaterThan_Old) {
|
||||
auto* p = parser("texture_sampled_1d<u32");
|
||||
auto p = parser("texture_sampled_1d<u32");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ParserImplTest,
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
||||
auto* p = parser("texture_1d<f32>");
|
||||
auto p = parser("texture_1d<f32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -161,7 +161,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||
auto* p = parser("texture_2d<i32>");
|
||||
auto p = parser("texture_2d<i32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -174,7 +174,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||
auto* p = parser("texture_3d<u32>");
|
||||
auto p = parser("texture_3d<u32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -187,7 +187,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
||||
auto* p = parser("texture_1d<abc>");
|
||||
auto p = parser("texture_1d<abc>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -197,7 +197,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingType) {
|
||||
auto* p = parser("texture_1d<>");
|
||||
auto p = parser("texture_1d<>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingLessThan) {
|
||||
auto* p = parser("texture_1d");
|
||||
auto p = parser("texture_1d");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -217,7 +217,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingGreaterThan) {
|
||||
auto* p = parser("texture_1d<u32");
|
||||
auto p = parser("texture_1d<u32");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -227,7 +227,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
||||
auto* p = parser("texture_multisampled_2d<i32>");
|
||||
auto p = parser("texture_multisampled_2d<i32>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -240,7 +240,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
||||
auto* p = parser("texture_multisampled_2d<abc>");
|
||||
auto p = parser("texture_multisampled_2d<abc>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -250,7 +250,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_MissingType) {
|
||||
auto* p = parser("texture_multisampled_2d<>");
|
||||
auto p = parser("texture_multisampled_2d<>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
|
@ -261,7 +261,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_MissingType) {
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_MultisampledTexture_MissingLessThan) {
|
||||
auto* p = parser("texture_multisampled_2d");
|
||||
auto p = parser("texture_multisampled_2d");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -271,7 +271,7 @@ TEST_F(ParserImplTest,
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_MultisampledTexture_MissingGreaterThan) {
|
||||
auto* p = parser("texture_multisampled_2d<u32");
|
||||
auto p = parser("texture_multisampled_2d<u32");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -281,7 +281,7 @@ TEST_F(ParserImplTest,
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm_Old) {
|
||||
auto* p = parser("texture_ro_1d<r8unorm>");
|
||||
auto p = parser("texture_ro_1d<r8unorm>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -298,7 +298,7 @@ TEST_F(ParserImplTest,
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_StorageTexture_Writeonly2dR16Float_Old) {
|
||||
auto* p = parser("texture_wo_2d<r16float>");
|
||||
auto p = parser("texture_wo_2d<r16float>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -314,7 +314,7 @@ TEST_F(ParserImplTest,
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
|
||||
auto* p = parser("texture_ro_1d<abc>");
|
||||
auto p = parser("texture_ro_1d<abc>");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -323,7 +323,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingType_Old) {
|
||||
auto* p = parser("texture_wo_1d<>");
|
||||
auto p = parser("texture_wo_1d<>");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -332,7 +332,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingType_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan_Old) {
|
||||
auto* p = parser("texture_ro_1d");
|
||||
auto p = parser("texture_ro_1d");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -342,7 +342,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan_Old) {
|
|||
|
||||
TEST_F(ParserImplTest,
|
||||
TextureSamplerTypes_StorageTexture_MissingGreaterThan_Old) {
|
||||
auto* p = parser("texture_wo_1d<r8unorm");
|
||||
auto p = parser("texture_wo_1d<r8unorm");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -351,7 +351,7 @@ TEST_F(ParserImplTest,
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
||||
auto* p = parser("texture_storage_ro_1d<r8unorm>");
|
||||
auto p = parser("texture_storage_ro_1d<r8unorm>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -367,7 +367,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||
auto* p = parser("texture_storage_wo_2d<r16float>");
|
||||
auto p = parser("texture_storage_wo_2d<r16float>");
|
||||
auto t = p->texture_sampler_types();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -383,7 +383,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
||||
auto* p = parser("texture_storage_ro_1d<abc>");
|
||||
auto p = parser("texture_storage_ro_1d<abc>");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -392,7 +392,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingType) {
|
||||
auto* p = parser("texture_storage_ro_1d<>");
|
||||
auto p = parser("texture_storage_ro_1d<>");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -401,7 +401,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan) {
|
||||
auto* p = parser("texture_storage_ro_1d");
|
||||
auto p = parser("texture_storage_ro_1d");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -410,7 +410,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_MissingGreaterThan) {
|
||||
auto* p = parser("texture_storage_ro_1d<r8unorm");
|
||||
auto p = parser("texture_storage_ro_1d<r8unorm");
|
||||
auto t = p->texture_sampler_types();
|
||||
EXPECT_EQ(t.value, nullptr);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace {
|
|||
TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto* p = parser("type a = i32");
|
||||
auto p = parser("type a = i32");
|
||||
auto t = p->type_alias();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
|||
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||
ast::type::StructType str("B", {});
|
||||
|
||||
auto* p = parser("type a = B");
|
||||
auto p = parser("type a = B");
|
||||
p->register_constructed("B", &str);
|
||||
|
||||
auto t = p->type_alias();
|
||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_MissingIdent) {
|
||||
auto* p = parser("type = i32");
|
||||
auto p = parser("type = i32");
|
||||
auto t = p->type_alias();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, TypeDecl_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_InvalidIdent) {
|
||||
auto* p = parser("type 123 = i32");
|
||||
auto p = parser("type 123 = i32");
|
||||
auto t = p->type_alias();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, TypeDecl_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_MissingEqual) {
|
||||
auto* p = parser("type a i32");
|
||||
auto p = parser("type a i32");
|
||||
auto t = p->type_alias();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -92,7 +92,7 @@ TEST_F(ParserImplTest, TypeDecl_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_InvalidType) {
|
||||
auto* p = parser("type a = B");
|
||||
auto p = parser("type a = B");
|
||||
auto t = p->type_alias();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Invalid) {
|
||||
auto* p = parser("1234");
|
||||
auto p = parser("1234");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_EQ(t.errored, false);
|
||||
EXPECT_EQ(t.matched, false);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, TypeDecl_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
||||
auto* p = parser("A");
|
||||
auto p = parser("A");
|
||||
|
||||
auto* int_type = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
// Pre-register to make sure that it's the same type.
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Identifier_NotFound) {
|
||||
auto* p = parser("B");
|
||||
auto p = parser("B");
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
|
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, TypeDecl_Identifier_NotFound) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Bool) {
|
||||
auto* p = parser("bool");
|
||||
auto p = parser("bool");
|
||||
|
||||
auto* bool_type = tm()->Get(std::make_unique<ast::type::BoolType>());
|
||||
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_F32) {
|
||||
auto* p = parser("f32");
|
||||
auto p = parser("f32");
|
||||
|
||||
auto* float_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ParserImplTest, TypeDecl_F32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_I32) {
|
||||
auto* p = parser("i32");
|
||||
auto p = parser("i32");
|
||||
|
||||
auto* int_type = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
|
@ -117,7 +117,7 @@ TEST_F(ParserImplTest, TypeDecl_I32) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_U32) {
|
||||
auto* p = parser("u32");
|
||||
auto p = parser("u32");
|
||||
|
||||
auto* uint_type = tm()->Get(std::make_unique<ast::type::U32Type>());
|
||||
|
||||
|
@ -142,7 +142,7 @@ class VecTest : public ParserImplTestWithParam<VecData> {};
|
|||
|
||||
TEST_P(VecTest, Parse) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -161,7 +161,7 @@ class VecMissingGreaterThanTest : public ParserImplTestWithParam<VecData> {};
|
|||
|
||||
TEST_P(VecMissingGreaterThanTest, Handles_Missing_GreaterThan) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -179,7 +179,7 @@ class VecMissingLessThanTest : public ParserImplTestWithParam<VecData> {};
|
|||
|
||||
TEST_P(VecMissingLessThanTest, Handles_Missing_GreaterThan) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -197,7 +197,7 @@ class VecBadType : public ParserImplTestWithParam<VecData> {};
|
|||
|
||||
TEST_P(VecBadType, Handles_Unknown_Type) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -215,7 +215,7 @@ class VecMissingType : public ParserImplTestWithParam<VecData> {};
|
|||
|
||||
TEST_P(VecMissingType, Handles_Missing_Type) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -230,7 +230,7 @@ INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
|||
VecData{"vec4<>", 4}));
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr) {
|
||||
auto* p = parser("ptr<function, f32>");
|
||||
auto p = parser("ptr<function, f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -244,7 +244,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) {
|
||||
auto* p = parser("ptr<function, vec2<f32>>");
|
||||
auto p = parser("ptr<function, vec2<f32>>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -262,7 +262,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
|
||||
auto* p = parser("ptr private, f32>");
|
||||
auto p = parser("ptr private, f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -272,7 +272,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingGreaterThan) {
|
||||
auto* p = parser("ptr<function, f32");
|
||||
auto p = parser("ptr<function, f32");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -282,7 +282,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingComma) {
|
||||
auto* p = parser("ptr<function f32>");
|
||||
auto p = parser("ptr<function f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -292,7 +292,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingStorageClass) {
|
||||
auto* p = parser("ptr<, f32>");
|
||||
auto p = parser("ptr<, f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -302,7 +302,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingParams) {
|
||||
auto* p = parser("ptr<>");
|
||||
auto p = parser("ptr<>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -312,7 +312,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingParams) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingType) {
|
||||
auto* p = parser("ptr<function,>");
|
||||
auto p = parser("ptr<function,>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -322,7 +322,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_BadStorageClass) {
|
||||
auto* p = parser("ptr<unknown, f32>");
|
||||
auto p = parser("ptr<unknown, f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -332,7 +332,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_BadStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_BadType) {
|
||||
auto* p = parser("ptr<function, unknown>");
|
||||
auto p = parser("ptr<function, unknown>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -342,7 +342,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_BadType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array) {
|
||||
auto* p = parser("array<f32, 5>");
|
||||
auto p = parser("array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -358,7 +358,7 @@ TEST_F(ParserImplTest, TypeDecl_Array) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
||||
auto* p = parser("[[stride(16)]] array<f32, 5>");
|
||||
auto p = parser("[[stride(16)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -375,7 +375,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
||||
auto* p = parser("[[stride(16)]] array<f32>");
|
||||
auto p = parser("[[stride(16)]] array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -391,7 +391,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
||||
auto* p = parser("[[stride(16), stride(32)]] array<f32>");
|
||||
auto p = parser("[[stride(16), stride(32)]] array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -412,7 +412,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
||||
auto* p = parser("[[stride(16)]] [[stride(32)]] array<f32>");
|
||||
auto p = parser("[[stride(16)]] [[stride(32)]] array<f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -433,7 +433,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingArray) {
|
||||
auto* p = parser("[[stride(16)]] f32");
|
||||
auto p = parser("[[stride(16)]] f32");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -443,7 +443,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingArray) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingClosingAttr) {
|
||||
auto* p = parser("[[stride(16) array<f32, 5>");
|
||||
auto p = parser("[[stride(16) array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -453,7 +453,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Decoration_MissingClosingAttr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Decoration_UnknownDecoration) {
|
||||
auto* p = parser("[[unknown 16]] array<f32, 5>");
|
||||
auto p = parser("[[unknown 16]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -463,7 +463,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Decoration_UnknownDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingLeftParen) {
|
||||
auto* p = parser("[[stride 4)]] array<f32, 5>");
|
||||
auto p = parser("[[stride 4)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -473,7 +473,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingRightParen) {
|
||||
auto* p = parser("[[stride(4]] array<f32, 5>");
|
||||
auto p = parser("[[stride(4]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -483,7 +483,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingValue) {
|
||||
auto* p = parser("[[stride()]] array<f32, 5>");
|
||||
auto p = parser("[[stride()]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -494,7 +494,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue) {
|
||||
auto* p = parser("[[stride(invalid)]] array<f32, 5>");
|
||||
auto p = parser("[[stride(invalid)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -505,7 +505,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue_Negative) {
|
||||
auto* p = parser("[[stride(-1)]] array<f32, 5>");
|
||||
auto p = parser("[[stride(-1)]] array<f32, 5>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -515,7 +515,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride_InvalidValue_Negative) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
|
||||
auto* p = parser("array<u32>");
|
||||
auto p = parser("array<u32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -529,7 +529,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
|
||||
auto* p = parser("array<unknown, 3>");
|
||||
auto p = parser("array<unknown, 3>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -539,7 +539,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_ZeroSize) {
|
||||
auto* p = parser("array<f32, 0>");
|
||||
auto p = parser("array<f32, 0>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -549,7 +549,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_ZeroSize) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_NegativeSize) {
|
||||
auto* p = parser("array<f32, -1>");
|
||||
auto p = parser("array<f32, -1>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -559,7 +559,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_NegativeSize) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_BadSize) {
|
||||
auto* p = parser("array<f32, invalid>");
|
||||
auto p = parser("array<f32, invalid>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -569,7 +569,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_BadSize) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MissingLessThan) {
|
||||
auto* p = parser("array f32>");
|
||||
auto p = parser("array f32>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -579,7 +579,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_MissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MissingGreaterThan) {
|
||||
auto* p = parser("array<f32");
|
||||
auto p = parser("array<f32");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -589,7 +589,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_MissingComma) {
|
||||
auto* p = parser("array<f32 3>");
|
||||
auto p = parser("array<f32 3>");
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -612,7 +612,7 @@ class MatrixTest : public ParserImplTestWithParam<MatrixData> {};
|
|||
|
||||
TEST_P(MatrixTest, Parse) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
|
@ -640,7 +640,7 @@ class MatrixMissingGreaterThanTest
|
|||
|
||||
TEST_P(MatrixMissingGreaterThanTest, Handles_Missing_GreaterThan) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -664,7 +664,7 @@ class MatrixMissingLessThanTest : public ParserImplTestWithParam<MatrixData> {};
|
|||
|
||||
TEST_P(MatrixMissingLessThanTest, Handles_Missing_GreaterThan) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -688,7 +688,7 @@ class MatrixBadType : public ParserImplTestWithParam<MatrixData> {};
|
|||
|
||||
TEST_P(MatrixBadType, Handles_Unknown_Type) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -712,7 +712,7 @@ class MatrixMissingType : public ParserImplTestWithParam<MatrixData> {};
|
|||
|
||||
TEST_P(MatrixMissingType, Handles_Missing_Type) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(params.input);
|
||||
auto p = parser(params.input);
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.errored);
|
||||
EXPECT_FALSE(t.matched);
|
||||
|
@ -733,7 +733,7 @@ INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
|||
MatrixData{"mat4x4<>", 4, 4}));
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
||||
auto* p = parser("sampler");
|
||||
auto p = parser("sampler");
|
||||
|
||||
auto* type = tm()->Get(std::make_unique<ast::type::SamplerType>(
|
||||
ast::type::SamplerKind::kSampler));
|
||||
|
@ -748,7 +748,7 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
||||
auto* p = parser("texture_sampled_cube<f32>");
|
||||
auto p = parser("texture_sampled_cube<f32>");
|
||||
|
||||
ast::type::F32Type f32;
|
||||
auto* type = tm()->Get(std::make_unique<ast::type::SampledTextureType>(
|
||||
|
@ -765,7 +765,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Texture) {
|
||||
auto* p = parser("texture_cube<f32>");
|
||||
auto p = parser("texture_cube<f32>");
|
||||
|
||||
ast::type::F32Type f32;
|
||||
auto* type = tm()->Get(std::make_unique<ast::type::SampledTextureType>(
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, UnaryExpression_Postix) {
|
||||
auto* p = parser("a[2]");
|
||||
auto p = parser("a[2]");
|
||||
auto e = p->unary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -48,7 +48,7 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, UnaryExpression_Minus) {
|
||||
auto* p = parser("- 1");
|
||||
auto p = parser("- 1");
|
||||
auto e = p->unary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, UnaryExpression_Minus) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, UnaryExpression_Minus_InvalidRHS) {
|
||||
auto* p = parser("-if(a) {}");
|
||||
auto p = parser("-if(a) {}");
|
||||
auto e = p->unary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -78,7 +78,7 @@ TEST_F(ParserImplTest, UnaryExpression_Minus_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, UnaryExpression_Bang) {
|
||||
auto* p = parser("!1");
|
||||
auto p = parser("!1");
|
||||
auto e = p->unary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, UnaryExpression_Bang) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, UnaryExpression_Bang_InvalidRHS) {
|
||||
auto* p = parser("!if (a) {}");
|
||||
auto p = parser("!if (a) {}");
|
||||
auto e = p->unary_expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecl_Parses) {
|
||||
auto* p = parser("var my_var : f32");
|
||||
auto p = parser("var my_var : f32");
|
||||
auto var = p->variable_decl();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_TRUE(var.matched);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecl_MissingVar) {
|
||||
auto* p = parser("my_var : f32");
|
||||
auto p = parser("my_var : f32");
|
||||
auto v = p->variable_decl();
|
||||
EXPECT_EQ(v.value, nullptr);
|
||||
EXPECT_FALSE(v.matched);
|
||||
|
@ -52,7 +52,7 @@ TEST_F(ParserImplTest, VariableDecl_MissingVar) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecl_InvalidIdentDecl) {
|
||||
auto* p = parser("var my_var f32");
|
||||
auto p = parser("var my_var f32");
|
||||
auto v = p->variable_decl();
|
||||
EXPECT_FALSE(v.matched);
|
||||
EXPECT_TRUE(v.errored);
|
||||
|
@ -62,7 +62,7 @@ TEST_F(ParserImplTest, VariableDecl_InvalidIdentDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecl_WithStorageClass) {
|
||||
auto* p = parser("var<private> my_var : f32");
|
||||
auto p = parser("var<private> my_var : f32");
|
||||
auto v = p->variable_decl();
|
||||
EXPECT_TRUE(v.matched);
|
||||
EXPECT_FALSE(v.errored);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecl_InvalidStorageClass) {
|
||||
auto* p = parser("var<unknown> my_var : f32");
|
||||
auto p = parser("var<unknown> my_var : f32");
|
||||
auto v = p->variable_decl();
|
||||
EXPECT_FALSE(v.matched);
|
||||
EXPECT_TRUE(v.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_Parses) {
|
||||
auto* p = parser(R"([[location(4), builtin(position)]])");
|
||||
auto p = parser(R"([[location(4), builtin(position)]])");
|
||||
auto decos = p->decoration_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_FALSE(decos.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_Empty) {
|
||||
auto* p = parser(R"([[]])");
|
||||
auto p = parser(R"([[]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_Invalid) {
|
||||
auto* p = parser(R"([[invalid]])");
|
||||
auto p = parser(R"([[invalid]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_ExtraComma) {
|
||||
auto* p = parser(R"([[builtin(position), ]])");
|
||||
auto p = parser(R"([[builtin(position), ]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, VariableDecorationList_ExtraComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_MissingComma) {
|
||||
auto* p = parser(R"([[binding(4) location(5)]])");
|
||||
auto p = parser(R"([[binding(4) location(5)]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ParserImplTest, VariableDecorationList_MissingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_BadDecoration) {
|
||||
auto* p = parser(R"([[location(bad)]])");
|
||||
auto p = parser(R"([[location(bad)]])");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, VariableDecorationList_BadDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecorationList_InvalidBuiltin) {
|
||||
auto* p = parser("[[builtin(invalid)]]");
|
||||
auto p = parser("[[builtin(invalid)]]");
|
||||
auto decos = p->decoration_list();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(decos.errored);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Location) {
|
||||
auto* p = parser("location(4)");
|
||||
auto p = parser("location(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Location_MissingLeftParen) {
|
||||
auto* p = parser("location 4)");
|
||||
auto p = parser("location 4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Location_MissingRightParen) {
|
||||
auto* p = parser("location(4");
|
||||
auto p = parser("location(4");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Location_MissingValue) {
|
||||
auto* p = parser("location()");
|
||||
auto p = parser("location()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -72,7 +72,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Location_MissingInvalid) {
|
||||
auto* p = parser("location(nan)");
|
||||
auto p = parser("location(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -95,7 +95,7 @@ class BuiltinTest : public ParserImplTestWithParam<BuiltinData> {};
|
|||
|
||||
TEST_P(BuiltinTest, VariableDecoration_Builtin) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(std::string("builtin(") + params.input + ")");
|
||||
auto p = parser(std::string("builtin(") + params.input + ")");
|
||||
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
|
@ -125,7 +125,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ast::Builtin::kGlobalInvocationId}));
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) {
|
||||
auto* p = parser("builtin position)");
|
||||
auto p = parser("builtin position)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -135,7 +135,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingRightParen) {
|
||||
auto* p = parser("builtin(position");
|
||||
auto p = parser("builtin(position");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -145,7 +145,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingValue) {
|
||||
auto* p = parser("builtin()");
|
||||
auto p = parser("builtin()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -155,7 +155,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Builtin_InvalidValue) {
|
||||
auto* p = parser("builtin(other_thingy)");
|
||||
auto p = parser("builtin(other_thingy)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -165,7 +165,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_InvalidValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingInvalid) {
|
||||
auto* p = parser("builtin(3)");
|
||||
auto p = parser("builtin(3)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -175,7 +175,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Binding) {
|
||||
auto* p = parser("binding(4)");
|
||||
auto p = parser("binding(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -190,7 +190,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Binding_MissingLeftParen) {
|
||||
auto* p = parser("binding 4)");
|
||||
auto p = parser("binding 4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -200,7 +200,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Binding_MissingRightParen) {
|
||||
auto* p = parser("binding(4");
|
||||
auto p = parser("binding(4");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -210,7 +210,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Binding_MissingValue) {
|
||||
auto* p = parser("binding()");
|
||||
auto p = parser("binding()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -221,7 +221,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Binding_MissingInvalid) {
|
||||
auto* p = parser("binding(nan)");
|
||||
auto p = parser("binding(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -232,7 +232,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_set) {
|
||||
auto* p = parser("set(4)");
|
||||
auto p = parser("set(4)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_TRUE(deco.matched);
|
||||
EXPECT_FALSE(deco.errored);
|
||||
|
@ -247,7 +247,7 @@ TEST_F(ParserImplTest, VariableDecoration_set) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingLeftParen) {
|
||||
auto* p = parser("set 2)");
|
||||
auto p = parser("set 2)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -257,7 +257,7 @@ TEST_F(ParserImplTest, VariableDecoration_Set_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingRightParen) {
|
||||
auto* p = parser("set(2");
|
||||
auto p = parser("set(2");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -267,7 +267,7 @@ TEST_F(ParserImplTest, VariableDecoration_Set_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingValue) {
|
||||
auto* p = parser("set()");
|
||||
auto p = parser("set()");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
@ -278,7 +278,7 @@ TEST_F(ParserImplTest, VariableDecoration_Set_MissingValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableDecoration_Set_MissingInvalid) {
|
||||
auto* p = parser("set(nan)");
|
||||
auto p = parser("set(nan)");
|
||||
auto deco = p->decoration();
|
||||
EXPECT_FALSE(deco.matched);
|
||||
EXPECT_TRUE(deco.errored);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_Parses) {
|
||||
auto* p = parser("my_var : f32");
|
||||
auto p = parser("my_var : f32");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_FALSE(decl.errored);
|
||||
|
@ -37,7 +37,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MissingIdent) {
|
||||
auto* p = parser(": f32");
|
||||
auto p = parser(": f32");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MissingColon) {
|
||||
auto* p = parser("my_var f32");
|
||||
auto p = parser("my_var f32");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MissingColon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MissingType) {
|
||||
auto* p = parser("my_var :");
|
||||
auto p = parser("my_var :");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_InvalidIdent) {
|
||||
auto* p = parser("123 : f32");
|
||||
auto p = parser("123 : f32");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) {
|
||||
auto* p = parser("my_var : invalid");
|
||||
auto p = parser("my_var : invalid");
|
||||
auto decl = p->expect_variable_ident_decl("test");
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_TRUE(decl.errored);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl) {
|
||||
auto* p = parser("var a : i32;");
|
||||
auto p = parser("var a : i32;");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_WithInit) {
|
||||
auto* p = parser("var a : i32 = 1;");
|
||||
auto p = parser("var a : i32 = 1;");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_WithInit) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_Invalid) {
|
||||
auto* p = parser("var a : invalid;");
|
||||
auto p = parser("var a : invalid;");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_VariableDecl_ConstructorInvalid) {
|
||||
auto* p = parser("var a : i32 = if(a) {}");
|
||||
auto p = parser("var a : i32 = if(a) {}");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ConstructorInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Const) {
|
||||
auto* p = parser("const a : i32 = 1");
|
||||
auto p = parser("const a : i32 = 1");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
|
@ -98,7 +98,7 @@ TEST_F(ParserImplTest, VariableStmt_Const) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Const_InvalidVarIdent) {
|
||||
auto* p = parser("const a : invalid = 1");
|
||||
auto p = parser("const a : invalid = 1");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -108,7 +108,7 @@ TEST_F(ParserImplTest, VariableStmt_Const_InvalidVarIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Const_MissingEqual) {
|
||||
auto* p = parser("const a : i32 1");
|
||||
auto p = parser("const a : i32 1");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -118,7 +118,7 @@ TEST_F(ParserImplTest, VariableStmt_Const_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Const_MissingConstructor) {
|
||||
auto* p = parser("const a : i32 =");
|
||||
auto p = parser("const a : i32 =");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
@ -128,7 +128,7 @@ TEST_F(ParserImplTest, VariableStmt_Const_MissingConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStmt_Const_InvalidConstructor) {
|
||||
auto* p = parser("const a : i32 = if (a) {}");
|
||||
auto p = parser("const a : i32 = if (a) {}");
|
||||
auto e = p->variable_stmt();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
|
|
|
@ -36,7 +36,7 @@ class VariableStorageTest
|
|||
|
||||
TEST_P(VariableStorageTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto* p = parser(std::string("<") + params.input + ">");
|
||||
auto p = parser(std::string("<") + params.input + ">");
|
||||
|
||||
auto sc = p->variable_storage_decoration();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
|
@ -64,7 +64,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
VariableStorageData{"function", ast::StorageClass::kFunction}));
|
||||
|
||||
TEST_F(ParserImplTest, VariableStorageDecoration_NoMatch) {
|
||||
auto* p = parser("<not-a-storage-class>");
|
||||
auto p = parser("<not-a-storage-class>");
|
||||
auto sc = p->variable_storage_decoration();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(sc.errored);
|
||||
|
@ -73,7 +73,7 @@ TEST_F(ParserImplTest, VariableStorageDecoration_NoMatch) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStorageDecoration_Empty) {
|
||||
auto* p = parser("<>");
|
||||
auto p = parser("<>");
|
||||
auto sc = p->variable_storage_decoration();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(sc.errored);
|
||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, VariableStorageDecoration_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStorageDecoration_MissingLessThan) {
|
||||
auto* p = parser("in>");
|
||||
auto p = parser("in>");
|
||||
auto sc = p->variable_storage_decoration();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(sc.errored);
|
||||
|
@ -93,7 +93,7 @@ TEST_F(ParserImplTest, VariableStorageDecoration_MissingLessThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableStorageDecoration_MissingGreaterThan) {
|
||||
auto* p = parser("<in");
|
||||
auto p = parser("<in");
|
||||
auto sc = p->variable_storage_decoration();
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_TRUE(sc.errored);
|
||||
|
|
Loading…
Reference in New Issue