<commit_before>package provide testcl 0.8.2
package require log

namespace eval ::testcl {
  variable nbOfTestFailures 0
  variable before
  namespace export it
  namespace export before
}

# testcl::reset_expectations --
#
# Resets the expectations between specifications
#
# Arguments:
# None
#
# Side Effects:
# Resets expectations
#
# Results:
# None.
proc ::testcl::reset_expectations { } {
  variable expectations
  if { [info exists expectations] } {
    log::log debug "Reset expectations"
    set expectations {}
  }
  variable expectedEndState
  if { [info exists expectedEndState] } {
    log::log debug "Reset end state"
    unset expectedEndState
  }
  variable expectedEvent
  if { [info exists expectedEvent] } {
    log::log debug "Reset expected event"
    unset expectedEvent
  }
}

# testcl::before --
#
#  that actual numeric value matches expected numeric value
#
# Arguments:
# body Body containing statements to be run before the specifications
#
# Side Effects:
# Sets before variable to contain body
#
# Results:
# None
proc ::testcl::before {body} {
  variable before
  set before $body
}

# testcl::it --
#
# Asserts that actual numeric value matches expected numeric value
#
# Arguments:
# description Description describing the specificaiton
# body Body containing statements to be run before running the iRule.
#
# Side Effects:
# None.
#
# Results:
# Prints description and either
# -> Test OK if specification is met
# -> Test failure otherwise
proc ::testcl::it {description body} {

  puts "\n**************************************************************************"
  puts "* it $description"
  puts "**************************************************************************"

  reset_expectations

  variable before
  if { [info exists before] } {
    log::log debug "Calling before"
    eval $before
  } else {
    log::log debug "No before proc"
  }

  variable nbOfTestFailures
  set rc [catch $body result]
  
  if {$rc != 0 } {
    puts "-> Test failure!!"
    puts "-> -> $result"
    log::log error $result 
    incr $nbOfTestFailures
  } else {<commit_msg>Fixed bug related to global number of errors<commit_after>package provide testcl 0.8.2
package require log

namespace eval ::testcl {
  variable nbOfTestFailures 0
  variable before
  namespace export it
  namespace export before
}

# testcl::reset_expectations --
#
# Resets the expectations between specifications
#
# Arguments:
# None
#
# Side Effects:
# Resets expectations
#
# Results:
# None.
proc ::testcl::reset_expectations { } {
  variable expectations
  if { [info exists expectations] } {
    log::log debug "Reset expectations"
    set expectations {}
  }
  variable expectedEndState
  if { [info exists expectedEndState] } {
    log::log debug "Reset end state"
    unset expectedEndState
  }
  variable expectedEvent
  if { [info exists expectedEvent] } {
    log::log debug "Reset expected event"
    unset expectedEvent
  }
}

# testcl::before --
#
#  that actual numeric value matches expected numeric value
#
# Arguments:
# body Body containing statements to be run before the specifications
#
# Side Effects:
# Sets before variable to contain body
#
# Results:
# None
proc ::testcl::before {body} {
  variable before
  set before $body
}

# testcl::it --
#
# Asserts that actual numeric value matches expected numeric value
#
# Arguments:
# description Description describing the specificaiton
# body Body containing statements to be run before running the iRule.
#
# Side Effects:
# None.
#
# Results:
# Prints description and either
# -> Test OK if specification is met
# -> Test failure otherwise
proc ::testcl::it {description body} {

  puts "\n**************************************************************************"
  puts "* it $description"
  puts "**************************************************************************"

  reset_expectations

  variable before
  if { [info exists before] } {
    log::log debug "Calling before"
    eval $before
  } else {
    log::log debug "No before proc"
  }

  variable nbOfTestFailures
  set rc [catch $body result]
  
  if {$rc != 0 } {
    puts "-> Test failure!!"
    puts "-> -> $result"
    log::log error $result 
    incr nbOfTestFailures
  } else {
{'fraction_non_alphanumeric': 0.15745986779981114, 'fraction_numerical': 0.002360717658168083, 'mean_word_length': 3.949766355140187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '7066215', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1165, 'n_words': 421}