<commit_before>module Test.Spec.Reporter.Dot (dotReporter) where

import Prelude
import Test.Spec.Color as Color
import Test.Spec.Runner.Event as Event
import Test.Spec.Speed as Speed
import Control.Monad.Eff.Console (CONSOLE)
import Test.Spec.Color (colored)
import Test.Spec.Console (write) as Console
import Test.Spec.Reporter.Base (defaultReporter)
import Test.Spec.Runner (Reporter)

type DotReporterState = Int
type DotReporterConfig = { slow :: Int, width :: Int }

dotReporter
  :: DotReporterConfig
  -> ∀ e. Reporter (console :: CONSOLE | e)
dotReporter { slow, width } =
  defaultReporter (-1) update

  where
    update n = case _ of
      Event.Pass _ speed ms ->
        let col = Speed.toColor speed
        in wrap $ Console.write (colored col ".")
      Event.Fail _ _ _ -> wrap $ Console.write (colored Color.Fail "!")
      Event.Pending _  -> wrap $ Console.write (colored Color.Pass ",")
      Event.End _      -> n <$ Console.write "\n"
      _                -> pure n

      where
        wrap action =
          let n' = n + 1
          in n' <$ do
            when (n' `mod` width == 0) (Console.write "\n")
            action
<commit_msg>Remove unused "slow" from Dot reporter config<commit_after>module Test.Spec.Reporter.Dot (dotReporter) where

import Prelude
import Test.Spec.Color as Color
import Test.Spec.Runner.Event as Event
import Test.Spec.Speed as Speed
import Control.Monad.Eff.Console (CONSOLE)
import Test.Spec.Color (colored)
import Test.Spec.Console (write) as Console
import Test.Spec.Reporter.Base (defaultReporter)
import Test.Spec.Runner (Reporter)

type DotReporterState = Int
type DotReporterConfig = { width :: Int }

dotReporter
  :: DotReporterConfig
  -> ∀ e. Reporter (console :: CONSOLE | e)
dotReporter { width } =
  defaultReporter (-1) update

  where
    update n = case _ of
      Event.Pass _ speed ms ->
        let col = Speed.toColor speed
        in wrap $ Console.write (colored col ".")
      Event.Fail _ _ _ -> wrap $ Console.write (colored Color.Fail "!")
      Event.Pending _  -> wrap $ Console.write (colored Color.Pass ",")
      Event.End _      -> n <$ Console.write "\n"
      _                -> pure n

      where
        wrap action =
          let n' = n + 1
          in n' <$ do
            when (n' `mod` width == 0) (Console.write "\n")
            action

{'fraction_non_alphanumeric': 0.11011523687580026, 'fraction_numerical': 0.002560819462227913, 'mean_word_length': 2.4725925925925925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '498579', 'n_tokens_mistral': 733, 'n_tokens_neox': 708, 'n_words': 221}