[mlir] Adjust AttributeTest to show skip behavior.
authorAdrian Kuegel <akuegel@google.com>
Tue, 31 Jan 2023 07:08:44 +0000 (08:08 +0100)
committerAdrian Kuegel <akuegel@google.com>
Tue, 31 Jan 2023 07:50:32 +0000 (08:50 +0100)
walk() skips identical sub-attributes. Adjust the unit test to show
this.

Differential Revision: https://reviews.llvm.org/D142956

mlir/unittests/IR/AttributeTest.cpp

index 7c0572e..94345d0 100644 (file)
@@ -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<Attribute> 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<Attribute>(
                 {strAttr, trueAttr, falseAttr, boolArrayAttr, dictAttr}));