1(define-library (srfi 33 test) 2 (export run-tests) 3 (import (scheme base) (srfi 33) (chibi test)) 4 (begin 5 (define (run-tests) 6 (test-begin "srfi-33: bitwise operations") 7 8 (test 0 (bitwise-and #b0 #b1)) 9 (test 1 (bitwise-and #b1 #b1)) 10 (test 0 (bitwise-and #b1 #b10)) 11 (test #b10 (bitwise-and #b11 #b10)) 12 (test #b101 (bitwise-and #b101 #b111)) 13 (test #b111 (bitwise-and -1 #b111)) 14 (test #b110 (bitwise-and -2 #b111)) 15 (test 3769478 (bitwise-and -4290775858 1694076839)) 16 (test 1680869008 (bitwise-and -193073517 1689392892)) 17 (test -4294967295 (bitwise-ior 1 (- -1 #xffffffff))) 18 (test -18446744073709551615 (bitwise-ior 1 (- -1 #xffffffffffffffff))) 19 (test -4294967126 (bitwise-xor #b10101010 (- -1 #xffffffff))) 20 (test -18446744073709551446 (bitwise-xor #b10101010 (- -1 #xffffffffffffffff))) 21 (test -2600468497 (bitwise-ior 1694076839 -4290775858)) 22 (test -184549633 (bitwise-ior -193073517 1689392892)) 23 (test -2604237975 (bitwise-xor 1694076839 -4290775858)) 24 (test -1865418641 (bitwise-xor -193073517 1689392892)) 25 (test 3769478 (bitwise-and 1694076839 -4290775858)) 26 (test 1680869008 (bitwise-and -193073517 1689392892)) 27 28 (test 1 (arithmetic-shift 1 0)) 29 (test 2 (arithmetic-shift 1 1)) 30 (test 4 (arithmetic-shift 1 2)) 31 (test 8 (arithmetic-shift 1 3)) 32 (test 16 (arithmetic-shift 1 4)) 33 (test (expt 2 31) (arithmetic-shift 1 31)) 34 (test (expt 2 32) (arithmetic-shift 1 32)) 35 (test (expt 2 33) (arithmetic-shift 1 33)) 36 (test (expt 2 63) (arithmetic-shift 1 63)) 37 (test (expt 2 64) (arithmetic-shift 1 64)) 38 (test (expt 2 65) (arithmetic-shift 1 65)) 39 (test (expt 2 127) (arithmetic-shift 1 127)) 40 (test (expt 2 128) (arithmetic-shift 1 128)) 41 (test (expt 2 129) (arithmetic-shift 1 129)) 42 (test 3028397001194014464 (arithmetic-shift 11829675785914119 8)) 43 44 (test -1 (arithmetic-shift -1 0)) 45 (test -2 (arithmetic-shift -1 1)) 46 (test -4 (arithmetic-shift -1 2)) 47 (test -8 (arithmetic-shift -1 3)) 48 (test -16 (arithmetic-shift -1 4)) 49 (test (- (expt 2 31)) (arithmetic-shift -1 31)) 50 (test (- (expt 2 32)) (arithmetic-shift -1 32)) 51 (test (- (expt 2 33)) (arithmetic-shift -1 33)) 52 (test (- (expt 2 63)) (arithmetic-shift -1 63)) 53 (test (- (expt 2 64)) (arithmetic-shift -1 64)) 54 (test (- (expt 2 65)) (arithmetic-shift -1 65)) 55 (test (- (expt 2 127)) (arithmetic-shift -1 127)) 56 (test (- (expt 2 128)) (arithmetic-shift -1 128)) 57 (test (- (expt 2 129)) (arithmetic-shift -1 129)) 58 59 (test 0 (arithmetic-shift 1 -63)) 60 (test 0 (arithmetic-shift 1 -64)) 61 (test 0 (arithmetic-shift 1 -65)) 62 63 (test #x1000000000000000100000000000000000000000000000000 64 (arithmetic-shift #x100000000000000010000000000000000 64)) 65 (test #x8e73b0f7da0e6452c810f32b809079e5 66 (arithmetic-shift #x8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b -64)) 67 68 (test-not (bit-set? 64 1)) 69 (test-assert (bit-set? 64 #x10000000000000000)) 70 71 (test 3 (bitwise-merge 1 1 2)) 72 (test #b00110011 (bitwise-merge #b00111100 #b11110000 #b00001111)) 73 74 (test-end)))) 75