Changeset 39844 in project


Ignore:
Timestamp:
04/05/21 09:24:43 (4 months ago)
Author:
Kon Lovett
Message:

use optional instead of key, add tail-zero parameter type

Location:
release/5/semantic-version/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/semantic-version/trunk/semantic-version.scm

    r39843 r39844  
    4545
    4646(: version-punctuation  (#!optional string -> string))
     47(: version-tail-zero    (#!optional boolean -> boolean))
     48
    4749(: make-version         (#!rest ver-part --> ver))
    48 (: version-compare      (ver ver #!rest --> integer))
    49 (: version<?            (ver ver #!rest --> boolean))
    50 (: version=?            (ver ver #!rest --> boolean))
    51 (: version>?            (ver ver #!rest --> boolean))
    52 (: version<=?           (ver ver #!rest --> boolean))
    53 (: version>=?           (ver ver #!rest --> boolean))
     50(: version-compare      (ver ver #!optional boolean --> integer))
     51(: version<?            (ver ver #!optional boolean --> boolean))
     52(: version=?            (ver ver #!optional boolean --> boolean))
     53(: version>?            (ver ver #!optional boolean --> boolean))
     54(: version<=?           (ver ver #!optional boolean --> boolean))
     55(: version>=?           (ver ver #!optional boolean --> boolean))
    5456(: version-hash         (ver #!rest --> integer))
    5557(: version-comparator   (--> (struct comparator)))
     
    126128          (ver-puncs? puncs) ) ) ) ) )
    127129
    128 (define (version-compare ver1 ver2 #!key (tail-zero? (version-tail-zero)))
     130(define (version-compare ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
    129131  (define (tail-zeros ls) (if tail-zero? ls (drop-tailing-zeros ls)))
    130132  (let loop ((p1 (tail-zeros (ver-parts (check-version 'version-compare ver1))))
     
    145147            cmp ) ) ) ) ) )
    146148
    147 (define (version<? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
    148   (negative? (version-compare ver1 ver2 #:tail-zero? tail-zero?)) )
    149 
    150 (define (version=? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
    151   (zero? (version-compare ver1 ver2 #:tail-zero? tail-zero?)) )
    152 
    153 (define (version>? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
    154   (positive? (version-compare ver1 ver2 #:tail-zero? tail-zero?)) )
    155 
    156 (define (version<=? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
    157   (<= (version-compare ver1 ver2 #:tail-zero? tail-zero?) 0) )
    158 
    159 (define (version>=? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
    160   (>= (version-compare ver1 ver2 #:tail-zero? tail-zero?) 0) )
     149(define (version<? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     150  (negative? (version-compare ver1 ver2 tail-zero?)) )
     151
     152(define (version=? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     153  (zero? (version-compare ver1 ver2 tail-zero?)) )
     154
     155(define (version>? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     156  (positive? (version-compare ver1 ver2 tail-zero?)) )
     157
     158(define (version<=? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     159  (<= (version-compare ver1 ver2 tail-zero?) 0) )
     160
     161(define (version>=? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
     162  (>= (version-compare ver1 ver2 tail-zero?) 0) )
    161163
    162164(define (version-hash ver . rest)
     
    164166
    165167#;
    166 (define (version*=? ver1 ver2 #!key (tail-zero? (version-tail-zero)))
     168(define (version*=? ver1 ver2 #!optional (tail-zero? (version-tail-zero)))
    167169  (and
    168     (zero? (version-compare ver1 ver2 #:tail-zero? tail-zero?))
     170    (zero? (version-compare ver1 ver2 tail-zero?))
    169171    (equal? (ver-puncs1 ver) (ver-puncs ver2))) )
    170172
  • release/5/semantic-version/trunk/tests/semantic-version-test.scm

    r39840 r39844  
    3131(test-assert (zero? (version-compare (make-version 1 2 3) (make-version 1 2 3))))
    3232
    33 (test-assert (negative? (version-compare (make-version 1 2 3) (make-version 1 2 3 0) #:tail-zero? #t)))
     33(test-assert (negative? (version-compare (make-version 1 2 3) (make-version 1 2 3 0) #t)))
    3434(test-assert (zero? (version-compare (make-version 1 2 3) (make-version 1 2 3 0))))
    3535
Note: See TracChangeset for help on using the changeset viewer.