summaryrefslogtreecommitdiff
path: root/MLKLowLevelTests.m
blob: d4c478df57732afff8a69be4d008e163c618829b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* -*- mode: objc; coding: utf-8 -*- */
/* Étoilisp/Mulklisp, a Common Lisp subset for the Étoilé runtime.
 * Copyright (C) 2008  Matthias Andreas Benkard.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
                           
#include <UnitKit/UnitKit.h>
#include <Foundation/Foundation.h>

#include "MLKCons.h"
#include "MLKDynamicContext.h"
#include "MLKEnvironment.h"
#include "MLKLinkedList.h"
#include "MLKSymbol.h"

@interface MLKLowLevelTests : NSObject <UKTest>
@end


@implementation MLKLowLevelTests
-(id) initForTest
{
  self = [super init];
  return self;
}


-(id) testCons
{
  id obj1 = @"Mulk.";
  id obj2 = AUTORELEASE ([[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();
  //  UKNotNil (nil);
  //  UKTrue (1);
  //  UKStringsNotEqual (@"a", @"b");
  // UKPass();
  return nil;
}
@end