<commit_before>#include "ROOT/TDFNodes.hxx"

#include <thread>

#include "gtest/gtest.h"

using namespace ROOT::Experimental;

TEST(TDataFrameNodes, TSlotStackCheckSameThreadSameSlot)
{
   unsigned int n(7);
   ROOT::Internal::TDF::TSlotStack s(n);
   EXPECT_EQ(s.GetSlot(), s.GetSlot());
}

TEST(TDataFrameNodes, TSlotStackGetOneTooMuch)
{
   auto theTest = []() {
      unsigned int n(2);
      ROOT::Internal::TDF::TSlotStack s(n);

      std::vector<std::thread> ts;

      for (unsigned int i = 0; i < 3; ++i) {
         ts.emplace_back([&s]() { s.GetSlot(); });
      }

      for (auto &&t : ts)
         t.join();
   };

   ASSERT_DEATH(theTest(), "TSlotStack assumes that a value can be always obtained.");
}

TEST(TDataFrameNodes, TSlotStackPutBackTooMany)
{
   auto theTest = []() {
      unsigned int n(2);
      ROOT::Internal::TDF::TSlotStack s(n);

      std::vector<std::thread> ts;

      for (unsigned int i = 0; i < 2; ++i) {
         ts.emplace_back([&s]() { s.GetSlot(); });
      }
      for (unsigned int i = 0; i < 2; ++i) {
         ts.emplace_back([&s, i]() { s.ReturnSlot(i); });
      }

      for (auto &&t : ts)
         t.join();
   };

   ASSERT_DEATH(theTest(), "TSlotStack has a reference count relative to an index which will become negative");
}

TEST(TDataFrameNodes, TLoopManagerGetImplPtr)
{
   ROOT::Detail::TDF::TLoopManager lm(nullptr, {});
   ASSERT_EQ(&lm, lm.GetImplPtr());
}

TEST(TDataFrameNodes, TLoopManagerJit)
{
   ROOT::Detail::TDF::TLoopManager lm(nullptr, {});
   lm.Jit("souble d = 3.14");
   int ret (1);
   try {
      testing::internal::CaptureStderr();
      lm.Run();
   } catch (const std::runtime_error &e) {
      ret = 0;
   }
   EXPECT_EQ(0, ret) << "Bogus C++ code was jitted and nothing was detected!";
}<commit_msg>[TDF] Do not run death tests in opt and fst mode<commit_after>#include "ROOT/TDFNodes.hxx"

#include <thread>

#include "gtest/gtest.h"

using namespace ROOT::Experimental;

TEST(TDataFrameNodes, TSlotStackCheckSameThreadSameSlot)
{
   unsigned int n(7);
   ROOT::Internal::TDF::TSlotStack s(n);
   EXPECT_EQ(s.GetSlot(), s.GetSlot());
}

#ifndef NDEBUG

TEST(TDataFrameNodes, TSlotStackGetOneTooMuch)
{
   auto theTest = []() {
      unsigned int n(2);
      ROOT::Internal::TDF::TSlotStack s(n);

      std::vector<std::thread> ts;

      for (unsigned int i = 0; i < 3; ++i) {
         ts.emplace_back([&s]() { s.GetSlot(); });
      }

      for (auto &&t : ts)
         t.join();
   };

   ASSERT_DEATH(theTest(), "TSlotStack assumes that a value can be always obtained.");
}

TEST(TDataFrameNodes, TSlotStackPutBackTooMany)
{
   auto theTest = []() {
      unsigned int n(2);
      ROOT::Internal::TDF::TSlotStack s(n);

      std::vector<std::thread> ts;

      for (unsigned int i = 0; i < 2; ++i) {
         ts.emplace_back([&s]() { s.GetSlot(); });
      }
      for (unsigned int i = 0; i < 2; ++i) {
         ts.emplace_back([&s, i]() { s.ReturnSlot(i); });
      }

      for (auto &&t : ts)
         t.join();
   };

   ASSERT_DEATH(theTest(), "TSlotStack has a reference count relative to an index which will become negative");
}

#endif

TEST(TDataFrameNodes, TLoopManagerGetImplPtr)
{
   ROOT::Detail::TDF::TLoopManager lm(nullptr, {});
   ASSERT_EQ(&lm, lm.GetImplPtr());
}

TEST(TDataFrameNodes, TLoopManagerJit)
{
   ROOT::Detail::TDF::TLoopManager lm(nullptr, {});
   lm.Jit("souble d = 3.14");
   int ret (1);
   try {
      testing::internal::CaptureStderr();
      lm.Run();
   } catch (const std::runtime_error &e) {
      ret = 0;
   }
   EXPECT_EQ(0, ret) << "Bogus C++ code was jitted and nothing was detected!";
}
{'fraction_non_alphanumeric': 0.17048275862068965, 'fraction_numerical': 0.008275862068965517, 'mean_word_length': 3.206496519721578, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3220687', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1320, 'n_words': 295}