<commit_before># simple Jasmine emulator

JE = do ->

  befores   = {}
  tests     = {}
  afters    = {}
  context   = {}
  root = {describes: {}}
  currentPath = []
  Array::last = -> this[@length - 1]
  currentDescribe = undefined

  addInCurrentPoint = (key, val)->
    if currentPath.length? and currentPath.length > 0
      eval "root.describes.#{currentPath.join('.describes.')}.describes[key] = val;"
    else
      root.describes[key] = val

  cleanup = ->
    if currentPath.length? and currentPath.length > 0
      eval "delete root.describes.#{currentPath.join('.describes.')};"

    currentPath.pop()

  callRecursively = (describes)->
    return unless describes?
    for _, desc of describes
      currentPath.push desc.name
      desc.func.call(context)
      runDependencies.call(context, desc)
      cleanup.call(context)

  runDependencies = (desc)->
    return unless desc? or desc.name?
    before.call(context) for before in befores[desc.name]

    test.call(context) for test in tests[desc.name]

    callRecursively desc.describes

    after.call(context) for after in afters[desc.name]

    true

  {
    beforeEach: (fn)->
      befores[currentPath.last()].push fn

    afterEach: (fn)->
      afters[currentPath.last()].push fn

    it: (name, fn)->
      tests[currentPath.last()].push fn

    describe: (name, fn)->
      desc = {name: name, describes: {}, func: fn}
      addInCurrentPoint(name, desc)
      # currentPath.push name
      befores[name]   = []
      tests[name]     = []
      afters[name]    = []

    run: (env = this)->
      context = env
      callRecursively(root.describes)
  }<commit_msg>fixes in JasmineEmulator<commit_after># simple Jasmine emulator

JE = do ->

  befores   = {}
  tests     = {}
  afters    = {}
  context   = {}
  root = {describes: {}}
  currentPath = []
  Array::last = -> this[@length - 1]
  currentDescribe = undefined

  addInCurrentPoint = (key, val)->
    if currentPath.length? and currentPath.length > 0
      eval "root.describes.#{currentPath.join('.describes.')}.describes[key] = val;"
    else
      root.describes[key] = val

  cleanup = ->
    if currentPath.length? and currentPath.length > 0
      eval "delete root.describes.#{currentPath.join('.describes.')};"

    currentPath.pop()

  callRecursively = (describes)->
    return unless describes?
    for _, desc of describes
      currentPath.push desc.name
      desc.func.call(context)
      runDependencies.call(context, desc)
      cleanup.call(context)

  runDependencies = (desc)->
    return unless desc? or desc.name?

    for test in tests[desc.name]
      before.call(context) for before in befores[desc.name]
      test.call(context)
      after.call(context) for after in afters[desc.name].slice().reverse()

    for name, _ of desc.describes
      befores[name] = befores[desc.name].concat befores[name]
      afters[name] = afters[desc.name].concat afters[name]

    callRecursively desc.describes

  {
    beforeEach: (fn)->
      befores[currentPath.last()].push fn

    afterEach: (fn)->
      afters[currentPath.last()].push fn

    it: (name, fn)->
      tests[currentPath.last()].push fn

    describe: (name, fn)->
      desc = {name: name, describes: {}, func: fn}
      addInCurrentPoint(name, desc)
      # currentPath.push name
      befores[name]   = []
      tests[name]     = []
      afters[name]    = []

    run: (env = this)->
      context = env
      callRecursively(root.describes)
  }
{'fraction_non_alphanumeric': 0.1374133949191686, 'fraction_numerical': 0.0017321016166281756, 'mean_word_length': 2.6900958466453675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2200410', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1121, 'n_words': 245}