From faefa40e18b8bbb283761c67305ba6ed7b346a3c Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 12 Jun 2008 20:47:57 +0200 Subject: MLKLowLevelTests: Add -testCons. --- MLKLowLevelTests.m | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/MLKLowLevelTests.m b/MLKLowLevelTests.m index b274f02..1de05ff 100644 --- a/MLKLowLevelTests.m +++ b/MLKLowLevelTests.m @@ -16,6 +16,13 @@ */ #include +#include + +#include "MLKCons.h" +#include "MLKDynamicContext.h" +#include "MLKEnvironment.h" +#include "MLKLinkedList.h" +#include "MLKSymbol.h" @interface MLKLowLevelTests : NSObject @end @@ -28,6 +35,49 @@ } +-(id) testCons +{ + id obj1 = @"Mulk."; + id obj2 = [[NSMutableDictionary alloc] init]; + + MLKCons *cons2 = [MLKCons cons:obj1 with:obj2]; + MLKCons *cons3 = [MLKCons cons:obj1 with:nil]; + MLKCons *cons4 = [MLKCons cons:nil with:nil]; + MLKCons *cons5 = [MLKCons cons:nil with:obj2]; + + MLKCons *cons6 = AUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:obj2]); + MLKCons *cons7 = AUTORELEASE ([[MLKCons alloc] initWithCar:obj1 cdr:nil]); + MLKCons *cons8 = AUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:nil]); + MLKCons *cons9 = AUTORELEASE ([[MLKCons alloc] initWithCar:nil cdr:obj2]); + + UKTrue ([cons2 car] == obj1); + UKTrue ([cons3 car] == obj1); + UKFalse ([cons4 car] == obj1); + UKFalse ([cons5 car] == obj1); + UKTrue ([cons6 car] == obj1); + UKTrue ([cons7 car] == obj1); + UKFalse ([cons8 car] == obj1); + UKFalse ([cons9 car] == obj1); + + UKTrue ([cons2 cdr] == obj2); + UKFalse ([cons3 cdr] == obj2); + UKFalse ([cons4 cdr] == obj2); + UKTrue ([cons5 cdr] == obj2); + UKTrue ([cons6 cdr] == obj2); + UKFalse ([cons7 cdr] == obj2); + UKFalse ([cons8 cdr] == obj2); + UKTrue ([cons9 cdr] == obj2); + + [cons2 setCdr:obj1]; + UKTrue ([cons2 cdr] == obj1); + + [cons2 setCar:obj2]; + UKTrue ([cons2 car] == obj2); + + return nil; +} + + -(id) testStuff { // UKPass(); UKFail(); -- cgit v1.2.3