same as `before` except it will run after matched tests.
 @note `after` hooks will run even on failed tests.
       however it wont run if some exception arise inside test.
767838
def after *matchers, &proc
      proc || raise(ArgumentError, 'block is missing')
      matchers.flatten!
      matchers = [:*] if matchers.empty?
      return if after?.find {|x| x[0] == matchers && x[1].source_location == proc.source_location}
      after?.push([matchers, proc])
    end
906802
def _run_hooked_methods(self, hook: str):
        
        for method in self._potentially_hooked_methods:
            for callback_specs in method._hooked:
                if callback_specs['hook'] != hook:
                    continue

                when = callback_specs.get('when')

                if when:
                    if self._check_callback_conditions(callback_specs):
                        method()
                else:
                    method()
82239
function (fn, repeatTest = 0, args = []) {
    let result, error

    /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */
    // commandIsRunning = false

    try {
        result = fn.apply(this, args)
    } catch (e) {
        error = e
    }

    /**
     * handle errors that get thrown directly and are not cause by
     * rejected promises
     */
    if (error) {
        if (repeatTest) {
            return executeAsync(fn, --repeatTest, args)
        }
        return new Promise((resolve, reject) => reject(error))
    }

    /**
     * if we don't retry just return result
     */
    if (repeatTest === 0 || !result || typeof result.catch !== 'function') {
        return new Promise(resolve => resolve(result))
    }

    /**
     * handle promise response
     */
    return result.catch((e) => {
        if (repeatTest) {
            return executeAsync(fn, --repeatTest, args)
        }

        e.stack = e.stack.split('\n').filter(STACKTRACE_FILTER_FN).join('\n')
        return Promise.reject(e)
    })
}
1316226
def _run_hooks(self):
        """"""
        for hook in self.hooks:
            getattr(self, hook)(self._state)
655293
function executeHooks(data, allHooks, checkHooks, creationMode) {
    var hooksToCall = creationMode ? allHooks : checkHooks;
    if (hooksToCall) {
        callHooks(data, hooksToCall);
    }
}
408595
function() {
			debug('next hook');
			var hook = global.requestSSLHooks[index++];
			if (hook) {
				debug('init hook',hook);
				// if async
				global.requestSSLInsideHook = true;
				if (hook.length > 0) {
					debug('calling a hook async');
					hook(nextHook);
					debug('after calling a hook async');
				}
				// else sync
				else {
					debug('calling a hook sync');
					hook();
					nextHook();
					debug('after calling a hook sync');
				}
				global.requestSSLInsideHook = false;
			}
			else {
				debug('init has no more hooks');
				done();
			}
		}
538970
def process
      # Invoke before hook and stop if false
      res = @hooks.invoke_hook_events(job_name, :before_perform, *args)
      return false unless res
      # Execute the job
      @hooks.around_hook_events(job_name, :around_perform, *args) do
        # We subtract one to ensure we timeout before beanstalkd does, except if:
        #  a) ttr == 0, to support never timing out
        #  b) ttr == 1, so that we don't accidentally set it to never time out
        #  NB: A ttr of 1 will likely result in race conditions between
        #  Backburner and beanstalkd and should probably be avoided
        timeout_job_after(task.ttr > 1 ? task.ttr - 1 : task.ttr) { job_class.perform(*args) }
      end
      task.delete
      # Invoke after perform hook
      @hooks.invoke_hook_events(job_name, :after_perform, *args)
    rescue => e
      @hooks.invoke_hook_events(job_name, :on_failure, e, *args)
      raise e
    end
1148178
public function runBeforeView($context = null) {
        if($this->_beforeView !== null) {
            foreach($this->_beforeView as $hookProvider) {
                $hookProvider->doBeforeView($context);
            }
        }
    }
598798
private boolean insertCodeBodyHook(TestMethod method, CtMethod ctMethod,
            String classQualifiedName, String methodSimpleName, String methodArgClassesStr) throws CannotCompileException {
        String hookClassName = HookMethodDef.class.getCanonicalName();
        String initializeSrc = hookInitializeSrc();
        boolean transformed = false;

        // iterate code body in the inverse order,
        // so that beforeHook is always inserted after the afterHook of the previous line
        // even if target line of these two hooks are the same
        for (int i = method.getCodeBody().size() - 1; i >= 0; i--) {
            int hookedLine = method.getCodeBody().get(i).getStartLine();

            // insert afterHook first and beforeHook second in each iteration,
            // so that beforeHook is always inserted before the afterHook
            // even if actual inserted lines for these two hooks are the same

            int afterHookInsertedLine = afterHookInsertLine(method, i);
            if (afterHookInsertedLine != -1) {
                int actualAfterHookInsertedLine = ctMethod.insertAt(afterHookInsertedLine, false, null);
                ctMethod.insertAt(afterHookInsertedLine,
                        String.format("%s%s.afterCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);",
                                initializeSrc, hookClassName, classQualifiedName,
                                methodSimpleName, methodSimpleName,
                                methodArgClassesStr, hookedLine, actualAfterHookInsertedLine));
                transformed = true;
            }

            int beforeHookInsertedLine = beforeHookInsertLine(method, i);
            if (beforeHookInsertedLine != -1) {
                int actualBeforeHookInsertedLine = ctMethod.insertAt(beforeHookInsertedLine, false, null);
                ctMethod.insertAt(beforeHookInsertedLine,
                        String.format("%s%s.beforeCodeLineHook(\"%s\",\"%s\",\"%s\",\"%s\",%d, %d);",
                                initializeSrc, hookClassName, classQualifiedName,
                                methodSimpleName, methodSimpleName,
                                methodArgClassesStr, hookedLine, actualBeforeHookInsertedLine));
                transformed = true;
            }
        }

        return transformed;
    }
450327
public function runBefore() {
        if($this->_beforeController !== null) {
            foreach($this->_beforeController as $hookProvider) {
                $hookProvider->doBefore();
            }
        }
    }
3232
def before(complete = true, index = 0, &block)
        unless @before_run
          while callback = machine.callbacks[:before][index]
            index += 1
            
            if callback.type == :around
              # Around callback: need to handle recursively.  Execution only gets
              # paused if:
              # * The block fails and the callback doesn't run on failures OR
              # * The block succeeds, but after callbacks are disabled (in which
              #   case a continuation is stored for later execution)
              return if catch(:cancel) do
                callback.call(object, context, self) do
                  before(complete, index, &block)
                  
                  pause if @success && !complete
                  throw :cancel, true unless @success
                end
              end
            else
              # Normal before callback
              callback.call(object, context, self)
            end
          end
          
          @before_run = true
        end
        
        action = {:success => true}.merge(block_given? ? yield : {})
        @result, @success = action[:result], action[:success]
      end
488323
def before(self, context):
        ""
        run.before_each.execute(context)
        self._invoke(self._before, context)
614143
def run_hook(hook_name, *args)
      list = self.class.all_hooks(hook_name)
      shell = self
      list.each do |hook|
        result = hook.call(shell, *args)
        return :break if result == :break
      end
      list.any?
    end
1347584
def after(self, after):
        
        if after is not None and len(after) > 32:
            raise ValueError("Invalid value for `after`, length must be less than or equal to `32`")
        if after is not None and len(after) < 32:
            raise ValueError("Invalid value for `after`, length must be greater than or equal to `32`")

        self._after = after
869614
def run
      # We can't just rescue exception because Firefox automatically closes alert when exception raised
      return unless @after_hooks.any? && !@browser.alert.exists?

      each { |after_hook| after_hook.call(@browser) }
    rescue Selenium::WebDriver::Error::NoSuchWindowError => ex
      Watir.logger.info "Could not execute After Hooks because browser window was closed #{ex}"
    end
342519
public static boolean valueChanged(Enum<?> before, Enum<?> after) {
        if (before == null && after == null) {
            return false;
        }
        if (after == null) {
            return false;
        }
        if (before == null && after != null) {
            return true;
        }
        return !(before == after);
    }
491297
public function afterSuite(Suite $suite)
    {
        $hook = $suite->getHook('after');
        if ($hook && $hook->getException()) {
            $this->handleHookFailure($hook);
        }
    }