Permalink
Browse files

Added test and fixed bug in class method calling.

  • Loading branch information...
1 parent c8574bf commit 6ee172f234d0a82cabeec97fdfd895f010fb3628 @probablycorey committed Feb 8, 2011
Showing with 19 additions and 4 deletions.
  1. +1 −3 lib/wax_instance.m
  2. +14 −1 tools/Tests/scripts/tests/classTest.lua
  3. +4 −0 tools/Tests/scripts/tests/fixtures/Deer.lua
View
@@ -270,7 +270,7 @@ static int __index(lua_State *L) {
lua_rawget(L, 3);
// Check instance's class userdata
- if (lua_isnil(L, -1) && !instanceUserdata->isClass && !instanceUserdata->isSuper) {
+ if (lua_isnil(L, -1) && !instanceUserdata->isSuper) {
Class classToCheck = [instanceUserdata->instance class];
// Keep checking superclasses if they are waxclasses, we want to treat those like they are lua
@@ -756,8 +756,6 @@ static BOOL overrideMethod(lua_State *L, wax_instance_userdata *instanceUserdata
argCount++;
}
- //if (argCount == 0) continue; // When we are creating our own methods, just always assume there will be at least one argument
-
size_t typeDescriptionSize = 3 + argCount;
typeDescription = calloc(typeDescriptionSize + 1, sizeof(char));
memset(typeDescription, '@', typeDescriptionSize);
@@ -106,6 +106,14 @@ describe["A WaxClass instance with an WaxClass Super"] = function()
local hash = o:hash()
expect(hash).should_be("100:10")
end
+
+ it["can call super method with multiple args"] = function()
+ local o = Bambi:initWithAge(10)
+ local a,b,c = o:returnsWhatYouSendIn(1,2,3)
+ expect(a).should_be(1)
+ expect(b).should_be(2)
+ expect(c).should_be(3)
+ end
end
describe["A WaxClass with an WaxClass Super"] = function()
@@ -123,7 +131,12 @@ describe["A WaxClass with an WaxClass Super"] = function()
result = Bambi:isEqual(NSString)
expect(result).should_be(false)
-
end
+ it["can call super method with multiple args"] = function()
+ local a, b, c = Bambi:returnsWhatYouSendIn(1,2,3)
+ expect(a).should_be(1)
+ expect(b).should_be(2)
+ expect(c).should_be(3)
+ end
end
@@ -11,6 +11,10 @@ function isEqual(class, other)
return class.super:isEqual(other)
end
+function returnsWhatYouSendIn(class, a, b, c)
+ return a, b, c
+end
+
-- instance methods
-------------------
function initWithName(self, name)

0 comments on commit 6ee172f

Please sign in to comment.