Add a scalar argument case for the Fortran spread intrinsic unit test.
authorMark Leair <leairmark@gmail.com>
Mon, 12 Jul 2021 19:38:55 +0000 (12:38 -0700)
committerMark Leair <leairmark@gmail.com>
Fri, 16 Jul 2021 19:19:08 +0000 (12:19 -0700)
flang/unittests/RuntimeGTest/Transformational.cpp

index 00495fc..90c1fa3 100644 (file)
@@ -150,6 +150,18 @@ TEST(Transformational, Spread) {
     EXPECT_EQ(*result.ZeroBasedIndexedElement<std::int32_t>(j), 1 + j % 3);
   }
   result.Destroy();
+
+  auto scalar{MakeArray<TypeCategory::Integer, 4>(
+      std::vector<int>{}, std::vector<std::int32_t>{1})};
+  RTNAME(Spread)(result, *scalar, 1, 2, __FILE__, __LINE__);
+  EXPECT_EQ(result.type(), array->type());
+  EXPECT_EQ(result.rank(), 1);
+  EXPECT_EQ(result.GetDimension(0).LowerBound(), 1);
+  EXPECT_EQ(result.GetDimension(0).Extent(), 2);
+  for (int j{0}; j < 2; ++j) {
+    EXPECT_EQ(*result.ZeroBasedIndexedElement<std::int32_t>(j), 1);
+  }
+  result.Destroy();
 }
 
 TEST(Transformational, Transpose) {