Replace StructDecoration::IsBlock with Castable

Change-Id: I4b053aab610b18f99b72156f92317bc8eaf430b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34313
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 731372f0b4
commit 8a82dcd977
8 changed files with 13 additions and 18 deletions

View File

@@ -13,6 +13,7 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/type/struct_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -65,7 +66,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithDecoration) {
EXPECT_EQ(s->impl()->members()[0]->name(), "a");
EXPECT_EQ(s->impl()->members()[1]->name(), "b");
ASSERT_EQ(s->impl()->decorations().size(), 1u);
EXPECT_TRUE(s->impl()->decorations()[0]->IsBlock());
EXPECT_TRUE(s->impl()->decorations()[0]->Is<ast::StructBlockDecoration>());
}
TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) {
@@ -90,8 +91,8 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) {
EXPECT_EQ(s->impl()->members()[0]->name(), "a");
EXPECT_EQ(s->impl()->members()[1]->name(), "b");
ASSERT_EQ(s->impl()->decorations().size(), 2u);
EXPECT_TRUE(s->impl()->decorations()[0]->IsBlock());
EXPECT_TRUE(s->impl()->decorations()[1]->IsBlock());
EXPECT_TRUE(s->impl()->decorations()[0]->Is<ast::StructBlockDecoration>());
EXPECT_TRUE(s->impl()->decorations()[1]->Is<ast::StructBlockDecoration>());
}
TEST_F(ParserImplTest, StructDecl_EmptyMembers) {

View File

@@ -13,6 +13,7 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "src/ast/struct_block_decoration.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -29,7 +30,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_Parses) {
EXPECT_TRUE(decos.matched);
ASSERT_EQ(decos.value.size(), 1u);
auto* struct_deco = decos.value[0]->As<ast::StructDecoration>();
EXPECT_TRUE(struct_deco->IsBlock());
EXPECT_TRUE(struct_deco->Is<ast::StructBlockDecoration>());
}
TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) {

View File

@@ -13,6 +13,7 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_decoration.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -45,7 +46,7 @@ TEST_P(StructDecorationTest, Parses) {
ASSERT_NE(deco.value, nullptr);
auto* struct_deco = deco.value->As<ast::StructDecoration>();
ASSERT_NE(struct_deco, nullptr);
EXPECT_EQ(struct_deco->IsBlock(), params.is_block);
EXPECT_EQ(struct_deco->Is<ast::StructBlockDecoration>(), params.is_block);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
StructDecorationTest,