Added method "functions" to DLLWrapper that grabs the DLL's "functions" so that people can continue to test for function existence via .functions['blah'], evne though I hate this, I want to be backwards compatible. This will be deprecated eventually

git-svn-id: file:///home/svn/framework3/trunk@13198 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Chao Mu 2011-07-17 15:15:26 +00:00
parent 2eeffc39fc
commit 572a5a5b8b
2 changed files with 29 additions and 0 deletions

View File

@ -12,6 +12,13 @@ class DLLWrapper
@_client = client
end
# For backwards compatability. People check if functions are added this way
# XXX: Depricate this
def functions
# warn 'Depricated.'
_dll.functions
end
def method_missing(sym, *args)
_dll.call_function(sym, args, _client)
end

View File

@ -17,6 +17,28 @@ class DLLWrapper::UnitTest < Test::Unit::TestCase
include MockMagic
def test_functions
mock_function_descriptions.each do |func|
client = make_mock_client(func[:platform], func[:request_to_client], func[:response_from_client])
dll = DLL.new(func[:dll_name], client)
dll_wrapper = DLLWrapper.new(dll, client)
# This represents how people check if a function doesn't exist
assert(!dll_wrapper.functions[func[:name]], 'Function non-existence can be chucked via .functions')
dll.add_function(func[:name], func[:return_type], func[:params])
# This represents how people check if a function exist
assert(dll_wrapper.functions[func[:name]], 'Function existence can be chucked via .functions')
actual_returned_hash = dll_wrapper.send(:method_missing, func[:name].to_sym, *func[:ruby_args])
assert_equal(func[:returned_hash], actual_returned_hash,
"method_missing should result in a successful call to specified function")
end
end
def test_method_missing
mock_function_descriptions.each do |func|
client = make_mock_client(func[:platform], func[:request_to_client], func[:response_from_client])