tint/sem: Add tests for IsConstructable
Change-Id: Id0eb03f2f8fd1053b62d3238214fc982f02a960f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106223 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
95dd428c75
commit
f17497cb6d
|
@ -125,5 +125,15 @@ TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
|
||||||
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
|
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ArrayTest, IsConstructable) {
|
||||||
|
auto* fixed_sized = create<Array>(create<U32>(), ConstantArrayCount{2u}, 4u, 8u, 32u, 16u);
|
||||||
|
auto* override_sized = create<Array>(create<U32>(), OverrideArrayCount{}, 4u, 8u, 32u, 16u);
|
||||||
|
auto* runtime_sized = create<Array>(create<U32>(), RuntimeArrayCount{}, 4u, 8u, 32u, 16u);
|
||||||
|
|
||||||
|
EXPECT_TRUE(fixed_sized->IsConstructible());
|
||||||
|
EXPECT_FALSE(override_sized->IsConstructible());
|
||||||
|
EXPECT_FALSE(runtime_sized->IsConstructible());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::sem
|
||||||
|
|
|
@ -124,5 +124,38 @@ TEST_F(StructTest, Location) {
|
||||||
EXPECT_FALSE(sem->Members()[1]->Location().has_value());
|
EXPECT_FALSE(sem->Members()[1]->Location().has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(StructTest, IsConstructable) {
|
||||||
|
auto* inner = //
|
||||||
|
Structure("Inner", utils::Vector{
|
||||||
|
Member("a", ty.i32()),
|
||||||
|
Member("b", ty.u32()),
|
||||||
|
Member("c", ty.f32()),
|
||||||
|
Member("d", ty.vec3<f32>()),
|
||||||
|
Member("e", ty.mat4x2<f32>()),
|
||||||
|
});
|
||||||
|
|
||||||
|
auto* outer = Structure("Outer", utils::Vector{
|
||||||
|
Member("inner", ty.type_name("Inner")),
|
||||||
|
Member("a", ty.i32()),
|
||||||
|
});
|
||||||
|
|
||||||
|
auto* outer_runtime_sized_array =
|
||||||
|
Structure("OuterRuntimeSizedArray", utils::Vector{
|
||||||
|
Member("inner", ty.type_name("Inner")),
|
||||||
|
Member("a", ty.i32()),
|
||||||
|
Member("runtime_sized_array", ty.array<i32>()),
|
||||||
|
});
|
||||||
|
auto p = Build();
|
||||||
|
ASSERT_TRUE(p.IsValid()) << p.Diagnostics().str();
|
||||||
|
|
||||||
|
auto* sem_inner = p.Sem().Get(inner);
|
||||||
|
auto* sem_outer = p.Sem().Get(outer);
|
||||||
|
auto* sem_outer_runtime_sized_array = p.Sem().Get(outer_runtime_sized_array);
|
||||||
|
|
||||||
|
EXPECT_TRUE(sem_inner->IsConstructible());
|
||||||
|
EXPECT_TRUE(sem_outer->IsConstructible());
|
||||||
|
EXPECT_FALSE(sem_outer_runtime_sized_array->IsConstructible());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::sem
|
} // namespace tint::sem
|
||||||
|
|
Loading…
Reference in New Issue