Make the message send test actually test thing things that it's supposed

to.
main
David Chisnall 10 years ago committed by David Chisnall
parent 8583fc7f61
commit 5cf6d6ac13

@ -97,7 +97,9 @@ __attribute__((objc_root_class))
@end @end
int forwardcalls; int forwardcalls;
void fwd(int a0, void fwdMany(id self,
SEL _cmd,
int a0,
int a1, int a1,
int a2, int a2,
int a3, int a3,
@ -121,34 +123,45 @@ void fwd(int a0,
float f10) float f10)
{ {
forwardcalls++; forwardcalls++;
assert(self == objc_getClass("Test"));
if (sel_isEqual(_cmd, sel_registerName("manyArgs:::::::::::::::::::::")))
assert(a0 == 0); assert(a0 == 0);
assert(a1 == 0); assert(a1 == 1);
assert(a2 == 0); assert(a2 == 2);
assert(a3 == 0); assert(a3 == 3);
assert(a4 == 0); assert(a4 == 4);
assert(a5 == 0); assert(a5 == 5);
assert(a6 == 0); assert(a6 == 6);
assert(a7 == 0); assert(a7 == 7);
assert(a8 == 0); assert(a8 == 8);
assert(a9 == 0); assert(a9 == 9);
assert(a10 == 10); assert(a10 == 10);
assert(f0 == 0); assert(f0 == 0);
assert(f1 == 0); assert(f1 == 1);
assert(f2 == 0); assert(f2 == 2);
assert(f3 == 0); assert(f3 == 3);
assert(f4 == 0); assert(f4 == 4);
assert(f5 == 0); assert(f5 == 5);
assert(f6 == 0); assert(f6 == 6);
assert(f7 == 0); assert(f7 == 7);
assert(f8 == 0); assert(f8 == 8);
assert(f9 == 0); assert(f9 == 9);
assert(f10 == 10); assert(f10 == 10);
} }
void fwd(void)
{
forwardcalls++;
}
IMP forward(id o, SEL s) IMP forward(id o, SEL s)
{ {
assert(o == objc_getClass("Test")); assert(o == objc_getClass("Test"));
if (sel_isEqual(s, sel_registerName("missing")))
{
return (IMP)fwd; return (IMP)fwd;
}
return (IMP)fwdMany;
} }
int main(void) int main(void)
@ -167,6 +180,7 @@ int main(void)
assert((id)0x42 == objc_msgSend(TestCls, @selector(foo))); assert((id)0x42 == objc_msgSend(TestCls, @selector(foo)));
objc_msgSend(TestCls, @selector(nothing)); objc_msgSend(TestCls, @selector(nothing));
objc_msgSend(TestCls, @selector(missing)); objc_msgSend(TestCls, @selector(missing));
assert(forwardcalls == 1);
assert(0 == objc_msgSend(0, @selector(nothing))); assert(0 == objc_msgSend(0, @selector(nothing)));
id a = objc_msgSend(objc_getClass("Test"), @selector(foo)); id a = objc_msgSend(objc_getClass("Test"), @selector(foo));
assert((id)0x42 == a); assert((id)0x42 == a);
@ -197,6 +211,7 @@ int main(void)
assert(0 == [f ldzero]); assert(0 == [f ldzero]);
assert(0 == [f fzero]); assert(0 == [f fzero]);
[TestCls manyArgs: 0 : 1 : 2 : 3: 4: 5: 6: 7: 8: 9: 10 : 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10]; [TestCls manyArgs: 0 : 1 : 2 : 3: 4: 5: 6: 7: 8: 9: 10 : 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10];
assert(forwardcalls == 2);
#ifdef BENCHMARK #ifdef BENCHMARK
const int iterations = 1000000000; const int iterations = 1000000000;
double times[3]; double times[3];

Loading…
Cancel
Save