mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-15 11:13:50 +00:00
New test cases to test ivar handling in new compiler
This commit is contained in:
1 parent
982da962e5
commit
b1cec9480e
1 file changed
+59
-4
@@ -41,6 +41,31 @@
|
||||
self.ivar1 = ivar1;
|
||||
}
|
||||
|
||||
- (void)returnShadowingLocalVariable
|
||||
{
|
||||
var ivar1 = 2;
|
||||
|
||||
return ivar1;
|
||||
}
|
||||
|
||||
- (void)returnShadowingHoistedLocalVariable
|
||||
{
|
||||
return ivar1;
|
||||
|
||||
var ivar1;
|
||||
}
|
||||
|
||||
- (void)returnFunctionWithShadowingFunctionParameter
|
||||
{
|
||||
return function(ivar1) { return ivar1 };
|
||||
}
|
||||
|
||||
- (void)returnFunctionWithShadowingHoistedLocalVariable
|
||||
{
|
||||
return function() { return ivar1; }
|
||||
var ivar1;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation IvarTest : OJTestCase
|
||||
@@ -78,15 +103,12 @@
|
||||
[self assert:5 equals:testClass.ivar1];
|
||||
}
|
||||
|
||||
/*
|
||||
TODO Reactivate this test after issue #498 is resolved.
|
||||
|
||||
- (void)testIvarShadowing
|
||||
{
|
||||
[self assert:nil equals:testClass.ivar1];
|
||||
[testClass setIvar1UsingAShadowingLocalVariable:5];
|
||||
[self assert:5 equals:testClass.ivar1];
|
||||
}*/
|
||||
}
|
||||
|
||||
- (void)testAccessorGeneration
|
||||
{
|
||||
@@ -117,4 +139,37 @@ TODO Reactivate this test after issue #498 is resolved.
|
||||
[self assert:nil equals:testClass.ivar3];
|
||||
}
|
||||
|
||||
- (void)testShadowingLocalVariable
|
||||
{
|
||||
[self assert:nil equals:testClass.ivar1];
|
||||
testClass.ivar1 = 99;
|
||||
var x = [testClass returnShadowingLocalVariable];
|
||||
[self assert:2 equals:x];
|
||||
}
|
||||
|
||||
- (void)testShadowingHoistedLocalVariable
|
||||
{
|
||||
[self assert:nil equals:testClass.ivar1];
|
||||
testClass.ivar1 = 99;
|
||||
var x = [testClass returnShadowingHoistedLocalVariable];
|
||||
[self assert:"undefined" equals:typeof x];
|
||||
}
|
||||
|
||||
- (void)testFunctionWithShadowingFunctionParameter
|
||||
{
|
||||
[self assert:nil equals:testClass.ivar1];
|
||||
testClass.ivar1 = 99;
|
||||
var f = [testClass returnFunctionWithShadowingFunctionParameter];
|
||||
[self assert:8 equals:f(8)];
|
||||
}
|
||||
|
||||
- (void)testFunctionWithShadowingHoistedLocalVariable
|
||||
{
|
||||
[self assert:nil equals:testClass.ivar1];
|
||||
testClass.ivar1 = 99;
|
||||
var f = [testClass returnFunctionWithShadowingHoistedLocalVariable];
|
||||
|
||||
[self assert:"undefined" equals:typeof f()];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user