Changeset 40463 in project


Ignore:
Timestamp:
09/08/21 18:36:22 (2 weeks ago)
Author:
Kon Lovett
Message:

reflow, new test runner

Location:
release/5/bitwise-utils/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/bitwise-utils/trunk/bitwise-utils.egg

    r39982 r40463  
    33
    44((synopsis "Bitwise utilities")
    5  (version "1.2.3")
     5 (version "1.2.4")
    66 (category data)
    77 (author "Kon Lovett")
     8 ;uhh, portions from
    89 (license "Public Domain")
    910 (dependencies)
  • release/5/bitwise-utils/trunk/bitwise-utils.scm

    r39982 r40463  
    9696(define logical-shift-left arithmetic-shift-left)
    9797(define (logical-shift-right n w)
    98   (if (zero? w) n
     98  (if (zero? w)
     99    n
    99100    (let ((res (bitwise-drop-right (abs n) w)))
    100101      (if (negative? n) (- res) res) ) ) )
     
    107108;123 0 => '()
    108109(define (bitwise-split n w)
    109   (if (or (zero? n) (zero? w)) `(,n)
     110  (if (or (zero? n) (zero? w))
     111    `(,n)
    110112    (let ((neg? (negative? n)) (mask (bitwise-ones w)))
    111113      (let loop ((n (abs n)) (ns '()))
    112         (if (zero? n) (if neg? (map - ns) ns)
     114        (if (zero? n)
     115          (if neg? (map - ns) ns)
    113116          (loop (bitwise-drop-right n w) (cons (bitwise-and n mask) ns)) ) ) ) ) )
    114117
     
    116119
    117120#>
    118 #define TWO( c )       ( ((C_uword) 1u) << (c))
     121#define TWO( c )       (((C_uword) 1u) << (c))
    119122#define MASK( c )      (((C_uword) -1) / (TWO( TWO( c ) ) + 1u))
    120123#define COUNT( x, c )  ((x) & MASK( c )) + (((x) >> (TWO( c ))) & MASK( c ))
     
    159162(define (bitwise-count n)
    160163  (let ((n (bitwise-abs n)))
    161     (if (fixnum? n) (uword-bitwise-count n)
     164    (if (fixnum? n)
     165      (uword-bitwise-count n)
    162166      (foldl add-uword-bits 0 (integer->uwords n)) ) ) )
    163167
     
    176180       (k (sub1 k) (sub1 k))
    177181       (rvs 0 (bitwise-ior (arithmetic-shift rvs 1) (bitwise-and 1 m))) )
    178       ((negative? k) (if (negative? n) (bitwise-not rvs) rvs))))
     182      ((negative? k) (if (negative? n) (bitwise-not rvs) rvs)) ) )
    179183
    180184(define (bitwise-rotate k count len) (bitwise-field-rotate k count 0 len))
    181185
    182186(define (bitwise-set-nth to index on?)
    183   (if on? (bitwise-ior to (arithmetic-shift 1 index))
     187  (if on?
     188    (bitwise-ior to (arithmetic-shift 1 index))
    184189    (bitwise-and to (bitwise-not (arithmetic-shift 1 index))) ) )
    185190
     
    189194
    190195(define (bitwise-field-copy to from start end)
    191   (bitwise-merge
    192     (arithmetic-shift (bitwise-not (arithmetic-shift -1 (- end start))) start)
    193     (arithmetic-shift from start)
    194     to) )
     196  (bitwise-merge  (arithmetic-shift (bitwise-not (arithmetic-shift -1 (- end start)))
     197                                    start)
     198                  (arithmetic-shift from start)
     199                  to) )
    195200
    196201(define (bitwise-field-reverse n start end)
     
    213218            (bitwise-and (bitwise-not (arithmetic-shift mask start)) n)) ) )
    214219
     220;NOTE rather than an {{integer-length}} {{len}} arg default, an unlimited length
     221;with a zero termination condition amount to the same thing
    215222(define (integer->list k #!optional (len most-positive-fixnum))
    216223  (do ((idx len (sub1 idx))
  • release/5/bitwise-utils/trunk/tests/run.scm

    r39781 r40463  
    77    make-pathname pathname-file pathname-replace-directory pathname-strip-extension)
    88  (only (chicken process) system)
    9   (only (chicken process-context) command-line-arguments)
     9  (only (chicken process-context) command-line-arguments get-environment-variable)
    1010  (only (chicken format) format)
    1111  (only (chicken file) file-exists? find-files)
     
    1313
    1414;; Globals
     15
     16(define *csi* (or (get-environment-variable "CHICKEN_CSI") "csi"))
     17(define *csc* (or (get-environment-variable "CHICKEN_CSC") "csc"))
    1518
    1619(define *csc-init-options* '(
     
    7982
    8083(define (run-test-evaluated source)
    81   (format #t "*** csi ~A ***~%" (pathname-file source))
    82   (system-must (string-append "csi -s " source)) )
     84  (format #t "*** ~A ~A ***~%" *csi* (pathname-file source))
     85  (system-must (string-append *csi* " -s " source)) )
    8386
    8487(define (run-test-compiled source csc-options)
    8588  (let ((optstr (apply string-append (intersperse csc-options " "))))
    86     (format #t "*** csc ~A ~A ***~%" (pathname-file source) optstr)
     89    (format #t "*** ~A ~A ~A ***~%" *csc* (pathname-file source) optstr)
    8790    ;csc output is in current directory
    88     (system-must (string-append "csc" " " optstr " " source)) )
     91    (system-must (string-append *csc* " " optstr " " source)) )
    8992  (system-must (pathname-replace-directory (pathname-strip-extension source) *test-directory*)) )
    9093
Note: See TracChangeset for help on using the changeset viewer.