/[cparse]/cparse/ctype-test.lisp
ViewVC logotype

Contents of /cparse/ctype-test.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Aug 17 18:13:30 2001 UTC (12 years, 8 months ago) by clynbech
Branch point for: MAIN, CPARSE
Initial revision
1 (in-package "CPARSE")
2
3 ;;; test parameters
4
5 (defparameter +int1+ (make-instance 'int-const :value 123))
6 (defparameter +int2+ (make-instance 'int-const :value 456))
7
8 (defun test1 ()
9 (let ((result (c+ *target-compiler* +int1+ +int2+)))
10 (assert (eq (type-of result) 'int-const))
11 (assert (eql (value result) 579))))
12
13 (defparameter +char1+ (make-instance 'unsigned-char-const :value 128))
14
15 (defun test2 ()
16 (let ((result (c+ *target-compiler* +int1+ +char1+)))
17 (assert (eq (type-of result) 'int-const))
18 (assert (eql (value result) 251))))
19
20 (defparameter +double1+ (make-instance 'double-const :value 1.0d0))
21
22 (defun test3 ()
23 (let ((result (c+ *target-compiler* +int1+ +double1+)))
24 (assert (eq (type-of result) 'double-const))
25 (assert (= (value result) 124.0))))
26
27 (defparameter +float1+ (make-instance 'cfloat-const :value 2.0))
28
29 (defun test4 ()
30 (let ((result (c+ *target-compiler* +int1+ +float1+)))
31 (assert (eq (type-of result) 'cfloat-const))
32 (assert (= (value result) 125.0))))
33
34 (defparameter +long1+ (make-instance 'long-const :value 1234567))
35 (defparameter +unsigned1+ (make-instance 'unsigned-int-const :value 23456))
36
37 (defun test5 ()
38 (let ((result (c+ *target-compiler* +unsigned1+ +long1+)))
39 (assert (eq (type-of result) 'unsigned-long-const))
40 (assert (= (value result) 1258023))))
41
42 ;;; Overflow
43
44 (defparameter +long2+ (make-instance 'long-const :value #X7fffffff))
45 (defparameter +unsigned2+ (make-instance 'unsigned-int-const :value #Xabc))
46
47 (defun test6 ()
48 (let ((result (c+ *target-compiler* +long2+ +unsigned2+)))
49 (assert (eq (type-of result) 'unsigned-long-const))
50 (assert (= (value result) #X80000abb))))
51
52 (defparameter +long3+ (make-instance 'long-const :value #X7fffffff))
53 (defparameter +int3+ (make-instance 'int-const :value 1))
54
55 (defun test7 ()
56 (let ((result (c+ *target-compiler* +long3+ +int3+)))
57 (assert (eq (type-of result) 'long-const))
58 (assert (= (value result) -2147483648))))
59
60 (defun test8 ()
61 (let ((result (c- *target-compiler* +int1+ +int2+)))
62 (assert (eq (type-of result) 'int-const))
63 (assert (eql (value result) -333))))
64
65 (defun test9 ()
66 (let ((result (c- *target-compiler* +int1+ +char1+)))
67 (assert (eq (type-of result) 'int-const))
68 (assert (eql (value result) -5))))
69
70 (defun test10 ()
71 (let ((result (c- *target-compiler* +int1+ +double1+)))
72 (assert (eq (type-of result) 'double-const))
73 (assert (= (value result) 122.0))))
74
75 (defun test11 ()
76 (let ((result (c- *target-compiler* +int1+ +float1+)))
77 (assert (eq (type-of result) 'cfloat-const))
78 (assert (= (value result) 121.0))))
79
80 (defun test12 ()
81 (let ((result (c- *target-compiler* +unsigned1+ +long1+)))
82 (assert (eq (type-of result) 'unsigned-long-const))
83 (assert (= (value result) 4293756185))))
84
85 (defun test13 ()
86 (let ((result (c- *target-compiler* +long2+ +unsigned2+)))
87 (assert (eq (type-of result) 'unsigned-long-const))
88 (assert (= (value result) 2147480899))))
89
90 (defun test14 ()
91 (let ((result (c- *target-compiler* +int3+ +long3+)))
92 (assert (eq (type-of result) 'long-const))
93 (assert (= (value result) -2147483646))))
94
95 (defun test15 ()
96 (let ((result (c* *target-compiler* +float1+ +int1+)))
97 (assert (eq (type-of result) 'cfloat-const))
98 (assert (= (value result) 246.0))))
99
100 (defun test16 ()
101 (let ((result (c/ *target-compiler* +int2+ +int1+)))
102 (assert (eq (type-of result) 'int-const))
103 (assert (eql (value result) 3))))
104
105 (defun test17 ()
106 (let ((result (c/ *target-compiler* +double1+ +float1+)))
107 (assert (eq (type-of result) 'double-const))
108 (assert (= (value result) .5))))
109
110 (defparameter +int4+ (make-instance 'int-const :value -1))
111 (defparameter +int5+ (make-instance 'int-const :value 1))
112
113 (defun test18 ()
114 (let ((result (c>> *target-compiler* +int4+ +int5+)))
115 (assert (eq (type-of result) 'int-const))
116 (assert (eql (value result) -1))))
117

  ViewVC Help
Powered by ViewVC 1.1.5