mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-18 22:41:18 +00:00
add behavior tests for methods, ivars, and inheritance; currently, one of the ivar tests fails due to bug #498
This commit is contained in:
1 parent
0802b80c35
commit
8cc61cccfd
3 files changed
+313
No files matched your search
@@ -0,0 +1,65 @@
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
@implementation MathClass : CPObject
|
||||
{
|
||||
}
|
||||
|
||||
- (CPNumber)five
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
- (CPNumber)sqrt:(CPNumber)operand
|
||||
{
|
||||
return Math.sqrt(operand);
|
||||
}
|
||||
|
||||
- (CPNumber)multiply:(CPNumber)firstOperand with:(CPNumber)secondOperand
|
||||
{
|
||||
return firstOperand * secondOperand;
|
||||
}
|
||||
|
||||
- (CPNumber)multiply:(CPNumber)operand, ...
|
||||
{
|
||||
var product;
|
||||
|
||||
for (var i = 0, ii = arguments.length; i < ii; ++i)
|
||||
product = product ? product * arguments[i] : arguments[i];
|
||||
|
||||
return product;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MethodTest : OJTestCase
|
||||
{
|
||||
MathClass testClass;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
testClass = [[MathClass alloc] init];
|
||||
}
|
||||
|
||||
- (void)testNoParameters
|
||||
{
|
||||
[self assert:5 equals:[testClass five]];
|
||||
}
|
||||
|
||||
- (void)testOneParameter
|
||||
{
|
||||
[self assert:2 equals:[testClass sqrt:4]];
|
||||
}
|
||||
|
||||
- (void)testTwoParameters
|
||||
{
|
||||
[self assert:6 equals:[testClass multiply:2 with:3]];
|
||||
}
|
||||
|
||||
- (void)testVarArgs
|
||||
{
|
||||
[self assert:30 equals:[testClass multiply:2,3,5]];
|
||||
[self assert:2310 equals:[testClass multiply:2,3,5,7,11]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user