 # TODO: In error message names: Called, Used, or Specified: pick one
-# TODO: pull the errors from the file and hard-code them here
 messages = require("../messages/messages.en.json")
+
 
 
 mock = (args...) ->

  finally
    mock_methods.restore_original_methods()
    delete Object.prototype[expects_method_name]
  
  
class MockObject
  
    # empty

  
class Expectation
  
  constructor: ->
    @_args = []
    @_returns = undefined
    @_throws = undefined
    @_called = no
    
  args: (args...) ->
    _check_args_usage(@, args)
    @_args = args
    @
    
  returns: (value) ->
    _check_returns_usage(@, value, arguments.length)
    @_returns = value
    @
    
  throws: (error) ->
    _check_throws_usage(@, error, arguments.length)
    @_throws = error
    @
    
  # is this expectation the same as this other one
  equals: (other) ->
    @matches(other._args...)

      for inner in [outer+1..@_list.length-1]             # loops produce the pairs (a,b), (a,c), (b,c)
        if @_list[outer].equals( @_list[inner] )
          fail(messages.DuplicateExpectation, method_name, @_list[outer]._args)

  find_errors: (method_name) ->                           # method_name is for error messages; TODO: is there a better way?
    format(messages.ExpectationNeverCalled, method_name, expectation._args) for expectation in @_list when ! expectation._called



class MockMethodList

  constructor: ->
    @_list = []

  add: (mock_method) ->
    @_list.push(mock_method)

  find_errors: ->
    errors = []
    errors = errors.concat( mock_method.expectations.find_errors(mock_method.method_name) ) for mock_method in @_list
    errors

  restore_original_methods: ->
    for mock_method in @_list
      if mock_method.original_method?
