following methods are used for calling from the function block
 raise an error if argument count got does not match the expected
488877
def validate_args_count(expected, got)
      if (expected.is_a?(Numeric) and expected != got) or
         (expected.is_a?(Range) and !(expected === got))
        raise ArgumentError, "wrong number of arguments for '#{name}' (#{got} for #{expected})"
      end
    end
291465
def call(func, args):
    
    assert hasattr(func, '__call__'), 'Cannot call func: {}'.format(
        func.__name__)
    raw_func = (
        func if isinstance(func, FunctionType) else func.__class__.__call__)
    hints = collections.defaultdict(lambda: Any, get_type_hints(raw_func))
    argspec = _getargspec(raw_func)
    named_args = {}
    varargs = ()
    for k, nk, v in _normalize(args):
        if nk == argspec.varargs:
            hints[nk] = Tuple[hints[nk], ...]
        elif nk not in argspec.args and argspec.varkw in hints:
            hints[nk] = hints[argspec.varkw]
        try:
            value = cast(hints[nk], v)
        except TypeError as e:
            _LOGGER.exception(e)
            six.raise_from(exc.InvalidCliValueError(k, v), e)
        if nk == argspec.varargs:
            varargs = value
        elif (nk in argspec.args or argspec.varkw) and (
                nk not in named_args or named_args[nk] is None):
            named_args[nk] = value
    return func(*varargs, **named_args)
287977
def method_missing(method, *args, &block)
      return rpc(method, args.first, args[1]) if function(method)

      super
    end
656503
def call(method, *args)
      ok, param = call2(method, *args) 
      if ok
        param
      else
        raise param
      end
    end
711184
def assertCallerError(self, expected_arg0, callable_obj, *args, **kwargs):
        
        try:
            callable_obj(*args, **kwargs)
            self.fail('Expected AssertionError, but no exception raised')
        except AssertionError, exc:
            self.assertEqual(exc.args[0], expected_arg0)
        except Exception, exc:
            self.fail('Expected AssertionError, but got %s' % repr(exc))
993961
def invoke(object, args, block, called_from)
      check_arity!(args.size)

      if base_object.is_a? Class
        result = if @plan
                   check_for_too_many_arguments!(@plan)
                   @plan.call(object, *args, &block)
                 end
      else
        result = if @plan
                   check_for_too_many_arguments!(@plan)
                   @plan.call(*args, &block)
                 end
      end
    ensure
      calls << CallLog.new(object, called_from, args, block, result)
    end
714992
function(func,args){
    if(!(typeof func === 'function')){
      throw new Error('The arguments must passed and they be a function .');
    }
    var funcStr = func.toString();
    var regexpComment = /\/\*([\s\S]*?)\*\//;
    var regexpVariable = /#{([\s\S]*?)}/g;
    if(!regexpComment.test(funcStr)){
      throw new Error("Comment not found.");
    }
    var match = regexpComment.exec(funcStr);
    var str = match[1];
    if(regexpVariable.test(str) && !args){
      throw new Error('args not passed .');
    }
    return str.replace(regexpVariable, function(match, key, index, str){
      key = key.trim();
      if(!(key in args)){
        throw new Error(key + ' is not passed from arguments.', key);
        return '';
      }else{
        return args[key];
      }
    });
  }
1342440
def get_func_params(method, called_params):
    
    insp = inspect.getfullargspec(method)
    if not isinstance(called_params, dict):
        raise UserWarning()
    _called_params = called_params.copy()
    params = {}
    arg_count = len(insp.args)
    arg_def_count = len(insp.defaults) if insp.defaults is not None else 0
    for i in range(arg_count):
        arg = insp.args[i]
        if i == 0 and isinstance(method, types.MethodType):
            continue  # skip self argument
        if arg in _called_params:
            params[arg] = _called_params.pop(arg)
        elif i - arg_count + arg_def_count >= 0:
            params[arg] = insp.defaults[i - arg_count + arg_def_count]
        else:
            raise TypeError('Argument "%s" not given' % arg)
    for kwarg in insp.kwonlyargs:
        if kwarg in _called_params:
            params[kwarg] = _called_params.pop(kwarg)
        elif kwarg in insp.kwonlydefaults:
            params[kwarg] = insp.kwonlydefaults[kwarg]
        else:
            raise TypeError('Argument "%s" not given' % kwarg)
    if insp.varkw is None:
        if len(_called_params) > 0:
            raise TypeError('Got unexpected parameter(s): %s'
                            '' % (", ".join(_called_params)))
    else:
        params.update(_called_params)
    return params
279925
def invalid_type_error(method_name, arg_name, got_value, expected_type,
                       version='0.13.0'):
    
    got_type = type(got_value)
    msg = ("As of {version}, 'adapter.{method_name}' expects argument "
           "'{arg_name}' to be of type '{expected_type}', instead got "
           "{got_value} ({got_type})")
    raise_compiler_error(msg.format(version=version, method_name=method_name,
                         arg_name=arg_name, expected_type=expected_type,
                         got_value=got_value, got_type=got_type))
765939
function checkArgument(i) {
  let l;

  if (l = checkBrackets(i)) tokens[i].argument_child = 1;
  else if (l = checkParentheses(i)) tokens[i].argument_child = 2;
  else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3;
  else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4;
  else if (l = checkFunction(i)) tokens[i].argument_child = 5;
  else if (l = checkVariablesList(i)) tokens[i].argument_child = 6;
  else if (l = checkVariable(i)) tokens[i].argument_child = 7;
  else if (l = checkSC(i)) tokens[i].argument_child = 8;
  else if (l = checkDelim(i)) tokens[i].argument_child = 9;
  else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10;
  else if (l = checkString(i)) tokens[i].argument_child = 11;
  else if (l = checkPercentage(i)) tokens[i].argument_child = 12;
  else if (l = checkDimension(i)) tokens[i].argument_child = 13;
  else if (l = checkNumber(i)) tokens[i].argument_child = 14;
  else if (l = checkUri(i)) tokens[i].argument_child = 15;
  else if (l = checkInterpolation(i)) tokens[i].argument_child = 16;
  else if (l = checkIdent(i)) tokens[i].argument_child = 17;
  else if (l = checkVhash(i)) tokens[i].argument_child = 18;
  else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19;
  else if (l = checkOperator(i)) tokens[i].argument_child = 20;
  else if (l = checkUnary(i)) tokens[i].argument_child = 21;
  else if (l = checkParentSelector(i)) tokens[i].argument_child = 22;
  else if (l = checkImportant(i)) tokens[i].argument_child = 23;
  else if (l = checkGlobal(i)) tokens[i].argument_child = 24;
  else if (l = checkDefault(i)) tokens[i].argument_child = 25;
  else if (l = checkOptional(i)) tokens[i].argument_child = 26;

  return l;
}
74076
function() {
          var methodString = 'expected ' + object.toString() + '.' + method + '()' + (negate ? ' not' : '' )
          
          function times(n) {
            return n > 2 ?  n + ' times' : { 1: 'once', 2: 'twice' }[n]
          }
          
          if (this.expectedResult != null && (negate ? this.anyResultsPass() : this.anyResultsFail()))
            this.message = methodString + ' to return ' + puts(this.expectedResult) + 
              ' but ' + (negate ? 'it did' : 'got ' + puts(this.failingResult())) 

          if (this.expectedArgs && (negate ? !this.expectedResult && this.anyArgsPass() : this.anyArgsFail()))
            this.message = methodString + ' to be called with ' + puts.apply(this, this.expectedArgs) +
             ' but was' + (negate ? '' : ' called with ' + puts.apply(this, this.failingArgs()))

          if (negate ? !this.expectedResult && !this.expectedArgs && this.calls.length >= this.times : this.calls.length != this.times)
            this.message = methodString + ' to be called ' + times(this.times) + 
            ', but ' +  (this.calls.length == 0 ? ' was not called' : ' was called ' + times(this.calls.length))
                
          if (!this.message.length) 
            this.passed = true
          
          return this
        }
795246
def check_argument_size(args)
      if @command.numerical_arg_size? && args.size != @command.arg_size
        command_size, args_size = args.size > @command.arg_size ?
          [@command.arg_size, args.size] :
          [@command.arg_size - 1, args.size - 1]
        raise CommandArgumentError,
          "wrong number of arguments (#{args_size} for #{command_size})"
      end
    end
1215541
def ensure_call(value)
      @count += 1

      if value.nil? && expects_argument?
        if default_value
          @value = default_value
        elsif !suppress_errors?
          raise Slop::MissingArgument.new("missing argument for #{flag}", flags)
        end
      else
        @value = call(value)
      end

      block.call(@value) if block.respond_to?(:call)
    end
793326
def raise_null_argument(func):
    """"""
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except TypeError as ex:
            if any(statement in ex.args[0] for statement in ['takes exactly',
                                                             'required positional argument']):
                raise NullArgument('Wrong number of arguments provided: ' + str(ex.args[0]))
            else:
                raise
    return wrapper
402436
function( name, match, block ) {
		var self = this, result = { passed: false, extra: 'Block did not throw error' };

		// Variable arguments
		if ( block === undefined && munit.isFunction( match ) ) {
			block = match;
			match = undefined;
		}

		// Fail quick if block isn't a function
		if ( ! munit.isFunction( block ) ) {
			throw new Error( "Block passed to assert.throws is not a function: '" + block + "'" );
		}

		// test for throwing
		try {
			block();
		}
		catch ( e ) {
			result = self._errorMatch( e, match );
		}

		return self.ok( name, result.passed, self.throws, result.extra );
	}
1365940
function checkArguments () {
    var obj = flag(this, 'object')
      , type = Object.prototype.toString.call(obj);
    this.assert(
        '[object Arguments]' === type
      , 'expected #{this} to be arguments but got ' + type
      , 'expected #{this} to not be arguments'
    );
  }
1319183
def _call_method(self, request):
        """"""
        method = self.method_data[request['method']]['method']
        params = request['params']
        result = None
        try:
            if isinstance(params, list):
                # Does it have enough arguments?
                if len(params) < self._man_args(method):
                    raise InvalidParamsError('not enough arguments')
                # Does it have too many arguments?
                if not self._vargs(method) \
                        and len(params) > self._max_args(method):
                    raise InvalidParamsError('too many arguments')

                result = yield defer.maybeDeferred(method, *params)
            elif isinstance(params, dict):
                # Do not accept keyword arguments if the jsonrpc version is
                # not >=1.1.
                if request['jsonrpc'] < 11:
                    raise KeywordError

                result = yield defer.maybeDeferred(method, **params)
            else:  # No params
                result = yield defer.maybeDeferred(method)
        except JSONRPCError:
            raise
        except Exception:
            # Exception was raised inside the method.
            log.msg('Exception raised while invoking RPC method "{}".'.format(
                    request['method']))
            log.err()
            raise ServerError

        defer.returnValue(result)