From: Adrian Kuegel Date: Tue, 31 Jan 2023 07:08:44 +0000 (+0100) Subject: [mlir] Adjust AttributeTest to show skip behavior. X-Git-Tag: upstream/17.0.6~19106 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1fa8179d4e5300a67ebdf41916a18f9c6330121;p=platform%2Fupstream%2Fllvm.git [mlir] Adjust AttributeTest to show skip behavior. walk() skips identical sub-attributes. Adjust the unit test to show this. Differential Revision: https://reviews.llvm.org/D142956 --- diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 7c0572e..94345d00 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -432,13 +432,15 @@ TEST(SubElementTest, Nested) { BoolAttr trueAttr = builder.getBoolAttr(true); BoolAttr falseAttr = builder.getBoolAttr(false); - ArrayAttr boolArrayAttr = builder.getArrayAttr({trueAttr, falseAttr}); + ArrayAttr boolArrayAttr = + builder.getArrayAttr({trueAttr, falseAttr, trueAttr}); StringAttr strAttr = builder.getStringAttr("array"); DictionaryAttr dictAttr = builder.getDictionaryAttr(builder.getNamedAttr(strAttr, boolArrayAttr)); SmallVector subAttrs; dictAttr.walk([&](Attribute attr) { subAttrs.push_back(attr); }); + // Note that trueAttr appears only once, identical subattributes are skipped. EXPECT_EQ(llvm::ArrayRef(subAttrs), ArrayRef( {strAttr, trueAttr, falseAttr, boolArrayAttr, dictAttr}));