From: Wolfgang T. <wth...@us...> - 2005-10-05 02:23:33
|
Update of /cvsroot/hoc/hoc/Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32560/Tests Modified Files: TestFoundation.hs Log Message: Add a test for non-outlet instance variables. Index: TestFoundation.hs =================================================================== RCS file: /cvsroot/hoc/hoc/Tests/TestFoundation.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- TestFoundation.hs 27 Sep 2005 11:55:22 -0000 1.6 +++ TestFoundation.hs 5 Oct 2005 02:23:19 -0000 1.7 @@ -44,7 +44,6 @@ Outlet "otherObject" [t| ID () |] ]) - $(declareClass "HaskellObjectWithDescription" "NSObject") $(exportClass "HaskellObjectWithDescription" "ho2_" [ @@ -56,6 +55,13 @@ superDesc <- fmap fromNSString $ super self # description return $ toNSString $ head (words superDesc) ++ " TEST>" +$(declareClass "HaskellObjectWithIVar" "HaskellObjectWithOutlet") + +$(exportClass "HaskellObjectWithIVar" "ho3_" [ + InstanceVariable "magicNumber" [t| Integer |] [| 0 |] + ]) + + $(declareClass "ExceptionThrower" "NSObject") instance Has_throwHaskellException (ExceptionThrower a) @@ -142,6 +148,24 @@ when (num /= num') $ assert "Different Object returned." ) ], + "HaskellObjectWithIVar" ~: test [ + "alloc-init" ~: (assertNoLeaks $ do + _HaskellObjectWithIVar # alloc >>= init >> return () + ), + "set-get-superclass" ~: (assertNoLeaks $ do + num <- _NSNumber # alloc >>= initWithInt 42 + hobj <- _HaskellObjectWithIVar # alloc >>= init + hobj # setOtherObject num + num' <- hobj # otherObject >>= return . castObject + when (num /= num') $ assert "Different Object returned." + ), + "set-get" ~: (assertNoLeaks $ do + hobj <- _HaskellObjectWithIVar # alloc >>= init + hobj # setIVar _magicNumber 42 + answer <- hobj # getIVar _magicNumber + when (answer /= 42) $ assert "Different Value returned." + ) + ], "Memory" ~: test [ "NSMutableArray-Circle" ~: (assertNoLeaks $ do array1 <- _NSMutableArray # alloc >>= Foundation.NSObject.init @@ -231,5 +255,6 @@ main = do initializeClass_HaskellObjectWithOutlet initializeClass_HaskellObjectWithDescription + initializeClass_HaskellObjectWithIVar initializeClass_ExceptionThrower go |