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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
#lang zuo
(require "harness.zuo")
(alert "predicate")
(check (integer? 10))
(check (not (integer? 'a)))
(check (not (integer? '(1 . 2))))
(alert "arithmetic")
(check (+ 1 2) 3)
(check (+ 1 -2) -1)
(check (+ 1 2 3 4) 10)
(check (+) 0)
(check (+ 1) 1)
(check (+ 4294967296 1) 4294967297)
(check (+ -4294967296 1) -4294967295)
(check (+ 4294967296 1) 4294967297)
(check (+ -9223372036854775808 1) -9223372036854775807)
(check (- -9223372036854775808 1) 9223372036854775807)
(check (+ 9223372036854775807 1) -9223372036854775808)
(check-arg-fail (+ 1 'apple) not-integer)
(check (- 2 1) 1)
(check (- 2 -1) 3)
(check (- 1 2 3 4) -8)
(check (- 1) -1)
(check (- 0) 0)
(check (- -9223372036854775808) -9223372036854775808)
(check (- -9223372036854775807) 9223372036854775807)
(check-arg-fail (-) arity)
(check-arg-fail (- 1 'apple) not-integer)
(check (* 10 2) 20)
(check (* 10 -2) -20)
(check (* 1 2 3 4) 24)
(check (*) 1)
(check (* 10) 10)
(check (* 10 0) 0)
(check (* 4294967296 4294967296) 0)
(check (* 4294967296 -4294967296) 0)
(check (* 4294967296 4294967297) 4294967296)
(check (* 4294967296 -4294967297) -4294967296)
(check (* 2147483648 4294967296) -9223372036854775808)
(check (* -9223372036854775808 1) -9223372036854775808)
(check (* -9223372036854775808 -1) -9223372036854775808)
(check (* 9223372036854775807 -1) -9223372036854775807)
(check (* -9223372036854775807 -1) 9223372036854775807)
(check-arg-fail (* 1 'apple) not-integer)
(check (quotient 5 2) 2)
(check (quotient 1 2) 0)
(check (quotient -5 2) -2)
(check (quotient 5 -2) -2)
(check (quotient -9223372036854775808 4294967296) -2147483648)
(check (quotient -9223372036854775808 1) -9223372036854775808)
(check (quotient -9223372036854775808 -1) -9223372036854775808)
(check (quotient 9223372036854775807 -1) -9223372036854775807)
(check (quotient -9223372036854775807 -1) 9223372036854775807)
(check-arg-fail (quotient -5) arity)
(check-arg-fail (quotient 5 'apple) not-integer)
(check-arg-fail (quotient 5 0) "divide by zero")
(check (remainder 5 2) 1)
(check (remainder 2 2) 0)
(check (remainder -5 2) -1)
(check (remainder 5 -2) 1)
(check (remainder -9223372036854775808 1) 0)
(check (remainder -9223372036854775808 -1) 0)
(check (remainder 9223372036854775807 -1) 0)
(check (remainder -9223372036854775807 -1) 0)
(check (remainder -9223372036854775808 9223372036854775807) -1)
(check (remainder 9223372036854775807 -9223372036854775808) 9223372036854775807)
(check-arg-fail (remainder -5) arity)
(check-arg-fail (remainder 5 'apple) not-integer)
(check-arg-fail (remainder 5 0) "divide by zero")
(check (modulo 5 2) 1)
(check (modulo 2 2) 0)
(check (modulo -5 2) 1)
(check (modulo 5 -2) -1)
(check (modulo -9223372036854775808 1) 0)
(check (modulo -9223372036854775808 -1) 0)
(check (modulo 9223372036854775807 -1) 0)
(check (modulo -9223372036854775807 -1) 0)
(check (modulo -9223372036854775808 9223372036854775807) 9223372036854775806)
(check (modulo 9223372036854775807 -9223372036854775808) -1)
(check-arg-fail (modulo -5) arity)
(check-arg-fail (modulo 5 'apple) not-integer)
(check-arg-fail (modulo 5 0) "divide by zero")
(alert "ordering")
(check (= 1 1))
(check (= -9223372036854775808 -9223372036854775808))
(check (<= 1 1))
(check (<= 1 2))
(check (<= -2 -1))
(check (not (<= -1 -2)))
(check (<= -9223372036854775808 -9223372036854775808))
(check (<= -9223372036854775808 9223372036854775807))
(check (not (<= 9223372036854775807 -9223372036854775808)))
(check-arg-fail (<= 'apple 5) not-integer)
(check-arg-fail (<= 5 'apple) not-integer)
(check (not (< 1 1)))
(check (< 1 2))
(check (< -2 -1))
(check (not (< -1 -2)))
(check (not (< -9223372036854775808 -9223372036854775808)))
(check (< -9223372036854775808 9223372036854775807))
(check (not (< 9223372036854775807 -9223372036854775808)))
(check-arg-fail (< 'apple 5) not-integer)
(check-arg-fail (< 5 'apple) not-integer)
(check (not (> 1 1)))
(check (> 2 1))
(check (> -1 -2))
(check (not (> -2 -1)))
(check (not (> -9223372036854775808 -9223372036854775808)))
(check (> 9223372036854775807 -9223372036854775808))
(check (not (> -9223372036854775808 9223372036854775807)))
(check-arg-fail (> 'apple 5) not-integer)
(check-arg-fail (> 5 'apple) not-integer)
(check (>= 1 1))
(check (>= 2 1))
(check (>= -1 -2))
(check (not (>= -2 -1)))
(check (>= -9223372036854775808 -9223372036854775808))
(check (>= 9223372036854775807 -9223372036854775808))
(check (not (>= -9223372036854775808 9223372036854775807)))
(check-arg-fail (>= 'apple 5) not-integer)
(check-arg-fail (>= 5 'apple) not-integer)
(alert "bitwise")
(check 1 (bitwise-and 3 1))
(check 0 (bitwise-and 2 1))
(check 42 (bitwise-and -1 42))
(check -42 (bitwise-and -1 -42))
(check 0 (bitwise-and -1 0))
(check 0 (bitwise-and -9223372036854775808 9223372036854775807))
(check-arg-fail (bitwise-and 'apple 5) not-integer)
(check-arg-fail (bitwise-and 5 'apple) not-integer)
(check 3 (bitwise-ior 3 1))
(check 3 (bitwise-ior 2 1))
(check -1 (bitwise-ior -1 42))
(check 42 (bitwise-ior 0 42))
(check -42 (bitwise-ior 0 -42))
(check -1 (bitwise-ior -9223372036854775808 9223372036854775807))
(check-arg-fail (bitwise-ior 'apple 5) not-integer)
(check-arg-fail (bitwise-ior 5 'apple) not-integer)
(check 2 (bitwise-xor 3 1))
(check 3 (bitwise-xor 2 1))
(check -43 (bitwise-xor -1 42))
(check 42 (bitwise-xor 0 42))
(check -42 (bitwise-xor 0 -42))
(check -1 (bitwise-xor -9223372036854775808 9223372036854775807))
(check-arg-fail (bitwise-xor 'apple 5) not-integer)
(check-arg-fail (bitwise-xor 5 'apple) not-integer)
(check -1 (bitwise-not 0))
(check 0 (bitwise-not -1))
(check 41 (bitwise-not -42))
(check -43 (bitwise-not 42))
(check 9223372036854775807 (bitwise-not -9223372036854775808))
(check-arg-fail (bitwise-not 'apple) not-integer)
|