   #   ...
   #
   throws: (error) ->
-    _check_throws_usage(@, error)
-    _save_throws(@, error)
+    @_check_throws_usage(error)
+    @_save_throws(error)
     @
 
   #

      ( @_args.length == args.length ) and
      ( @_args.every ( element, i ) -> element == args[ i ] )


# private

_check_args_usage = (expectation, args...) ->
  _throw_args_usage() if args.length == 0
  _throw_args_used_more_than_once() unless expectation._args.length == 0

_check_returns_usage = (expectation, value) ->
  _throw_returns_usage() unless value?
  _throw_returns_used_more_than_once() if expectation._returns?
  _throw_returns_and_throws_both_used() if expectation._throws?

_check_throws_usage = (expectation, error) ->
  _throw_throws_usage(error) unless error?
  _throw_throws_used_more_than_once() if expectation._throws?
  _throw_returns_and_throws_both_used() if expectation._returns?

_save_args = (expectation, args) ->
  expectation._args = args

_save_returns = (expectation, value) ->
  expectation._returns = value

_save_throws = (expectation, error) ->
  expectation._throws = error

_install_mock_method = (expectation, object, method_name) ->
  object = object.prototype if is_class(object)
  original_method = object[ method_name ]
  object[ method_name ] = build_mocked_method(method_name)
  if original_method?
    expectation.uninstall_mocked_method = -> object[ method_name ] = original_method
  else
    expectation.uninstall_mocked_method = -> delete object[ method_name ]

_throw_args_usage = ->
  throw new Error( "you need to supply at least one argument to args(), e.g. my_mock.expects('my_method').args(42)" )

_throw_args_used_more_than_once = ->
  throw new Error( "you specified args() more than once, e.g. my_mock.expects('my_method').args(1).args(2); use it once per expectation" )

_throw_returns_usage = ->
  throw new Error( "you need to supply an argument to returns(), e.g. my_mock.expects('my_method').returns(123)" )

_throw_returns_used_more_than_once = ->
  throw new Error( "you specified returns() more than once, e.g. my_mock.expects('my_method').returns(1).returns(2); use it once per expectation" )

_throw_throws_usage = ->
  throw new Error( "you need to supply an argument to throws(), e.g. my_mock.expects('my_method').throws('an error')" )

_throw_throws_used_more_than_once = ->
  throw new Error( "you specified throws() more than once, e.g. my_mock.expects('my_method').throws('something').throws('something else'); use it once per expectation" )

_throw_returns_and_throws_both_used = ->
  throw new Error( "you specified both returns() and throws() on the same expectation; use one or the other on an expectation" )

  #   ...
  #
  args: (args...) ->
    @_check_args_usage(args...)
    @_save_args(args)
    @

  #
