From c7e8c9c1a9a077063e7153982f51752e8b24061d Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 23 Apr 2020 20:15:33 +0000 Subject: [PATCH] [spirv-reader] Test position field of BlockInfo Bug: tint:3 Change-Id: I746b04b545da9dcd7c0b8805f264b67cb59c8a1c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20240 Reviewed-by: dan sinclair --- src/reader/spirv/function_cfg_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/reader/spirv/function_cfg_test.cc b/src/reader/spirv/function_cfg_test.cc index 6e0ae03886..397d1d3ee6 100644 --- a/src/reader/spirv/function_cfg_test.cc +++ b/src/reader/spirv/function_cfg_test.cc @@ -894,6 +894,10 @@ TEST_F(SpvParserTest, ComputeBlockOrder_OneBlock) { fe.ComputeBlockOrderAndPositions(); EXPECT_THAT(fe.block_order(), ElementsAre(42)); + + const auto* bi = fe.GetBlockInfo(42); + ASSERT_NE(bi, nullptr); + EXPECT_EQ(bi->pos, 0u); } TEST_F(SpvParserTest, ComputeBlockOrder_IgnoreStaticalyUnreachable) { @@ -986,6 +990,16 @@ TEST_F(SpvParserTest, ComputeBlockOrder_ReorderSequence) { fe.ComputeBlockOrderAndPositions(); EXPECT_THAT(fe.block_order(), ElementsAre(10, 20, 30)); + + const auto* bi10 = fe.GetBlockInfo(10); + ASSERT_NE(bi10, nullptr); + EXPECT_EQ(bi10->pos, 0u); + const auto* bi20 = fe.GetBlockInfo(20); + ASSERT_NE(bi20, nullptr); + EXPECT_EQ(bi20->pos, 1u); + const auto* bi30 = fe.GetBlockInfo(30); + ASSERT_NE(bi30, nullptr); + EXPECT_EQ(bi30->pos, 2u); } TEST_F(SpvParserTest, ComputeBlockOrder_DupConditionalBranch) {