<commit_before># simple Jasmine emulator

JE = do ->

  befores   = {}
  tests     = {}
  afters    = {}
  describes = {}
  currentDescribe = undefined

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

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

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

    describe: (name, fn)->
      currentDescribe = name
      befores[name]   = []
      tests[name]     = []
      afters[name]    = []
      describes[name] = fn

    run: (context = this)->
      for desc of describes

        describes[desc].call context

        before.call(context) for before in befores[desc]

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

        after.call(context)  for after in afters[desc]
  }<commit_msg>new functionality for inner describes in JasmineEmulator<commit_after># simple Jasmine emulator

JE = do ->

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

  cleanup = ->
    eval "delete describes[#{currentPath.join('][')}]"
    currentPath.pop()

  {
    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)->
      currentPath.push name
      befores[name]   = []
      tests[name]     = []
      afters[name]    = []
      describes[name] = {func: -> (fn() && cleanup()), name: name, describes: {}}

    run: (context = this)->
      for _, desc of describes

        desc.func.call(context)

        before.call(context)     for before in befores[desc]

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

        idesc.func.call(context) for _, idesc of desc.describes

        after.call(context)      for after in afters[desc]
  }
{'fraction_non_alphanumeric': 0.1368421052631579, 'fraction_numerical': 0.0005263157894736842, 'mean_word_length': 2.3003472222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '940851', 'n_tokens_mistral': 617, 'n_tokens_neox': 602, 'n_words': 142}