 #
 # all_expectations
 #
+
+# TODO: note about there not being that many expectations (i.e. typically fewer than 10?)
 all_expectations = []
 
 clear_all_expectations = ->


uninstall_all_mocked_methods = ->
  for expectation in all_expectations     # TODO: do this in reverse
    object = if typeof expectation._object == 'function' then expectation._object.prototype else expectation._object
    if expectation._original_method?
      object[ expectation.method_name ] = expectation._original_method
    else
      delete object[ expectation.method_name ]

build_convenience_mock_objects = ->
  ( new Object() for i in [1..5] )

  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)" )
