         return i if l.indexOf(p) isnt -1
     -1
 
-  registerSpecs: =>
+  registerSpecs: (results) =>
     set = @root.children
     set = set.sort(@randomSort) if @options.random
     for example in set
       @register example, @root.hasExclusiveExamples()
+
+    results
 
   register: (child, exclusiveOnly=false) ->
     if child.children?


    return

  executeSpecs: =>
    promise = new spectacular.Promise
    @nextExample promise
    promise

  nextExample: (defer) =>
    spectacular.nextTick =>
      if @stack.length is 0
        defer.resolve()
      else
        nextExample = @stack.shift()

        @env.currentExample = nextExample
        nextExample.run()
        .then =>
          @handleResult nextExample
          @nextExample defer
        .fail (reason) =>
          @handleResult nextExample
          @nextExample defer

  handleResult: (example) ->
    @dispatch new spectacular.Event 'result', example
    @env.currentExample = null

  notifyEnd: =>
    @dispatch new spectacular.Event 'end', this

  hasFailures: -> @examples.some (e) ->
    e.result.state in ['skipped', 'failure', 'errored']

    @seed = (@seed * 9301 + 49297) % 233280
    @seed / 233280.0

class spectacular.RunnerResults
  constructor: (@runner) ->
    @errors = []
    @failures = []
    @skipped = []
    @pending = []
    @results = []
    @examples = []
    {@loadStartedAt, @loadEndedAt} = @runner
    @specsStartedAt = null
    @specsEndedAt = null

  hasFailures: -> @examples.some (e) ->
    e.result.state in ['skipped', 'failure', 'errored']

class spectacular.Runner

  @include spectacular.EventDispatcher
