]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Adjust tests. 17373/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 23 Jul 2024 22:23:55 +0000 (16:23 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 23 Jul 2024 22:25:42 +0000 (16:25 -0600)
tests/base/lazy_01.cc
tests/base/lazy_01.output
tests/base/lazy_02.cc
tests/base/lazy_02.output

index 8644999974fc591cdd94917b469d0100dd9e13e2..9dfe429f624bcda90c464537e3b9d526271677d1 100644 (file)
@@ -30,6 +30,8 @@ main()
   initlog();
 
   {
+    deallog << "Part 1:" << std::endl;
+
     Lazy<int> lazy_integer;
     deallog << "lazy_integer.has_value() = " << lazy_integer.has_value()
             << std::endl;
@@ -38,7 +40,15 @@ main()
       deallog << "[initializing object]" << std::endl;
       return 42;
     });
-    deallog << "lazy_integer.has_value() = " << lazy_integer.has_value()
+
+    // Lazy computes the result on a different task, which may be on a
+    // different thread. To avoid producing unreliable output, make
+    // sure we don't say
+    //   deallog << "lazy_integer.has_value() = " << lazy_integer.has_value()
+    // but the following, where the order of computation and output are
+    // clear and well defined:
+    deallog << "lazy_integer.has_value() = " +
+                 std::to_string(lazy_integer.has_value())
             << std::endl;
     deallog << "lazy_integer.value() = " << lazy_integer.value() << std::endl;
 
@@ -47,17 +57,20 @@ main()
       return -1;
     });
 
-    deallog << "lazy_integer.value() = " << lazy_integer.value() << std::endl;
+    deallog << "lazy_integer.value() = " + std::to_string(lazy_integer.value())
+            << std::endl;
   }
 
   {
+    deallog << "Part 2:" << std::endl;
+
     Lazy<int> lazy_integer;
 
-    deallog << "lazy_integer.value() = "
-            << lazy_integer.value_or_initialize([&]() {
-                 deallog << "... [initializing object] ... ";
-                 return 42;
-               })
+    deallog << "lazy_integer.value() = " +
+                 std::to_string(lazy_integer.value_or_initialize([&]() {
+                   deallog << "... [initializing object] ... " << std::endl;
+                   return 42;
+                 }))
             << std::endl;
   }
 
index 728e7260e7004fac16fb8f86edcc9fca3c93801e..55b653213421c7affb6bd52c425fa70243349c01 100644 (file)
@@ -1,8 +1,11 @@
 
+DEAL::Part 1:
 DEAL::lazy_integer.has_value() = 0
 DEAL::[initializing object]
 DEAL::lazy_integer.has_value() = 1
 DEAL::lazy_integer.value() = 42
 DEAL::lazy_integer.value() = 42
-DEAL::lazy_integer.value() = ... [initializing object] ... 42
+DEAL::Part 2:
+DEAL::... [initializing object] ... 
+DEAL::lazy_integer.value() = 42
 DEAL::OK!
index 4f9aa77a59401355ebb36d7a075e3afdf3ea6b54..b54d119dd7dbe71a4163d53738d51bfdea4c82d6 100644 (file)
@@ -71,11 +71,11 @@ main()
 
   deallog << "... [ reset ] ... " << std::endl;
   lazy_integer_4.reset();
-  deallog << "value_or_initialize: "
-          << lazy_integer_4.value_or_initialize([&]() {
-               deallog << "... [ initialized ] ... ";
-               return 45;
-             })
+  deallog << "value_or_initialize: " +
+               std::to_string(lazy_integer_4.value_or_initialize([&]() {
+                 deallog << "... [ initialized ] ... " << std::endl;
+                 return 45;
+               }))
           << std::endl;
 
   deallog << "OK!" << std::endl;
index 54697dcbb59fe9da7d6fe457691084ccd8030012..a1bba381b22b2fdf67b6fc1aa1525f9a46ec6323 100644 (file)
@@ -11,5 +11,6 @@ DEAL::... [ reset ] ...
 DEAL::... [ initialized ] ... 
 DEAL::Reset: 43
 DEAL::... [ reset ] ... 
-DEAL::value_or_initialize: ... [ initialized ] ... 45
+DEAL::... [ initialized ] ... 
+DEAL::value_or_initialize: 45
 DEAL::OK!

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.