Changeset 11016 in project


Ignore:
Timestamp:
06/14/08 03:51:10 (11 years ago)
Author:
kon
Message:

Save

Location:
release/3/string-natural-compare
Files:
2 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • release/3/string-natural-compare/trunk/string-natural-compare.meta

    r9898 r11016  
    11((egg "string-natural-compare.egg")
    22 (category data)
    3  (author "Manuel Serrano & Kon Lovett")
     3 (author "Kon Lovett")
    44 (license "BSD")
    55 (doc-from-wiki)
     
    88 (files
    99  "string-natural-compare.scm"
    10   "string-natural-compare-support.scm"
     10  "string-natural-comparison.scm"
    1111  "string-natural-compare.setup"
    1212  "tests"
  • release/3/string-natural-compare/trunk/string-natural-compare.scm

    r9898 r11016  
    11;;;;; string-natural-compare.scm
    2 ;;;;; Kon Lovett, Mar '08
     2;;;;; Kon Lovett Mar '08
     3
     4(define-extension
     5  string-natural-compare
     6  (export
     7    string-natural=?
     8    string-natural<?
     9    string-natural>?
     10    string-natural<=?
     11    string-natural>=?
     12    string-natural<>?
     13    string-natural-ci=?
     14    string-natural-ci<?
     15    string-natural-ci>?
     16    string-natural-ci<=?
     17    string-natural-ci>=?
     18    string-natural-ci<>? ) )
     19
     20(require-extension
     21  string-natural-comparison )
     22
     23(eval-when (compile)
     24  (declare
     25    (usual-integrations)
     26    (fixnum)
     27    (no-bound-checks)
     28    (no-procedure-checks) ) )
    329
    430;;;;
     
    632;;; Case Sensitive
    733
    8 (define-macro (string-natural=? A B)
    9         `(fx= 0 (string-natural-compare ,A ,B)) )
     34(define (string-natural=? a b)
     35        (= 0 (string-natural-compare a b)) )
    1036
    11 (define-macro (string-natural<? A B)
    12         `(fx= -1 (string-natural-compare ,A ,B)) )
     37(define (string-natural<? a b)
     38        (= -1 (string-natural-compare a b)) )
    1339
    14 (define-macro (string-natural>? A B)
    15         `(fx= 1 (string-natural-compare ,A ,B)) )
     40(define (string-natural>? a b)
     41        (= 1 (string-natural-compare a b)) )
    1642
    17 (define-macro (string-natural<=? A B)
    18         `(fx>= 0 (string-natural-compare ,A ,B)) )
     43(define (string-natural<=? a b)
     44        (>= 0 (string-natural-compare a b)) )
    1945
    20 (define-macro (string-natural>=? A B)
    21         `(fx<= 0 (string-natural-compare ,A ,B)) )
     46(define (string-natural>=? a b)
     47        (<= 0 (string-natural-compare a b)) )
    2248
    23 (define-macro (string-natural<>? A B)
    24         `(not (fx= 0 (string-natural-compare ,A ,B))) )
     49(define (string-natural<>? a b)
     50        (not (= 0 (string-natural-compare a b))) )
    2551
    2652;;; Case Insensitive
    2753
    28 (define-macro (string-natural-ci=? A B)
    29         `(fx= 0 (string-natural-compare-ci ,A ,B)) )
     54(define (string-natural-ci=? a b)
     55        (= 0 (string-natural-compare-ci a b)) )
    3056
    31 (define-macro (string-natural-ci<? A B)
    32         `(fx= -1 (string-natural-compare-ci ,A ,B)) )
     57(define (string-natural-ci<? a b)
     58        (= -1 (string-natural-compare-ci a b)) )
    3359
    34 (define-macro (string-natural-ci>? A B)
    35         `(fx= 1 (string-natural-compare-ci ,A ,B)) )
     60(define (string-natural-ci>? a b)
     61        (= 1 (string-natural-compare-ci a b)) )
    3662
    37 (define-macro (string-natural-ci<=? A B)
    38         `(fx>= 0 (string-natural-compare-ci ,A ,B)) )
     63(define (string-natural-ci<=? a b)
     64        (>= 0 (string-natural-compare-ci a b)) )
    3965
    40 (define-macro (string-natural-ci>=? A B)
    41         `(fx<= 0 (string-natural-compare-ci ,A ,B)) )
     66(define (string-natural-ci>=? a b)
     67        (<= 0 (string-natural-compare-ci a b)) )
    4268
    43 (define-macro (string-natural-ci<>? A B)
    44         `(not (fx= 0 (string-natural-compare-ci ,A ,B))) )
     69(define (string-natural-ci<>? a b)
     70        (not (= 0 (string-natural-compare-ci a b))) )
  • release/3/string-natural-compare/trunk/string-natural-compare.setup

    r9898 r11016  
    11(include "setup-header")
    22
    3 (install-dynld+syntax string-natural-compare string-natural-compare-support *version*)
     3(install-dynld string-natural-comparison *version*)
     4(install-dynld+docu string-natural-compare *version*)
    45
    56(install-test "string-natural-compare-test.scm")
  • release/3/string-natural-compare/trunk/tests/string-natural-compare-test.scm

    r9898 r11016  
    66;;;
    77
    8 (define (natural=? a b)
    9   (string-natural=? a b) )
     8(define-expect-binary string-natural=?)
    109
    11 (define-expect-binary natural=?)
     10(define-expect-binary string-natural<?)
    1211
    13 (define (natural-ci=? a b)
    14   (string-natural-ci=? a b) )
     12(define-expect-binary string-natural>?)
    1513
    16 (define-expect-binary natural-ci=?)
     14(define-expect-binary string-natural-ci=?)
    1715
    18 (define (natural<? a b)
    19   (string-natural<? a b) )
    20 
    21 (define-expect-binary natural<?)
    22 
    23 (define (natural>? a b)
    24   (string-natural>? a b) )
    25 
    26 (define-expect-binary natural>?)
     16(define-expect-binary string-natural-ci<?)
    2717
    2818;;;
     
    132122(define-test string-natural-compare-test= "="
    133123
    134   (expect-natural= "a  b c" "abc")
    135   (expect-natural= "1a3" "1a3  ")
    136   (expect-natural= "  1a3" "1a3")
     124  (expect-string-natural= "a  b c" "abc")
     125  (expect-string-natural= "1a3" "1a3  ")
     126  (expect-string-natural= "  1a3" "1a3")
    137127)
    138128
     
    141131(define-test string-natural-compare-test-ci= "CI ="
    142132
    143   (expect-natural-ci= "a  b c" "ABC")
    144   (expect-natural-ci= "1a3" "1A3  ")
    145   (expect-natural-ci= "  1A3" "1a3")
     133  (expect-string-natural-ci= "a  b c" "ABC")
     134  (expect-string-natural-ci= "1a3" "1A3  ")
     135  (expect-string-natural-ci= "  1A3" "1a3")
    146136)
    147137
     
    150140(define-test string-natural-compare-test< "<"
    151141
    152   (expect-natural< "rfc1.txt" "rfc822.txt")
    153   (expect-natural< "rfc822.txt" "rfc2086.txt")
    154   (expect-natural< "rfc1.txt" "rfc2086.txt")
     142  (expect-string-natural< "rfc1.txt" "rfc822.txt")
     143  (expect-string-natural< "rfc822.txt" "rfc2086.txt")
     144  (expect-string-natural< "rfc1.txt" "rfc2086.txt")
    155145
    156   (expect-equal *test-result-1* (sort *test-set-1* (lambda (a b) (string-natural<? a b))))
    157   (expect-equal *test-result-2* (sort *test-set-2* (lambda (a b) (string-natural<? a b))))
    158   (expect-equal *test-result-3* (sort *test-set-3* (lambda (a b) (string-natural<? a b))))
     146  (expect-string-natural-ci< "RfC1.txt" "rFc822.txt")
     147  (expect-string-natural-ci< "RFc822.txt" "rfC2086.txt")
     148  (expect-string-natural-ci< "rFC1.txt" "Rfc2086.txt")
    159149)
    160150
     
    163153(define-test string-natural-compare-test> ">"
    164154
    165   (expect-natural> "rfc822.txt" "rfc1.txt")
    166   (expect-natural> "rfc2086.txt" "rfc822.txt")
    167   (expect-natural> "rfc2086.txt" "rfc1.txt")
     155  (expect-string-natural> "rfc822.txt" "rfc1.txt")
     156  (expect-string-natural> "rfc2086.txt" "rfc822.txt")
     157  (expect-string-natural> "rfc2086.txt" "rfc1.txt")
     158)
     159
     160;;
     161
     162(define-test string-natural-compare-test-sort "Sort"
     163
     164  (expect-equal *test-result-1* (sort *test-set-1* string-natural<?))
     165  (expect-equal *test-result-2* (sort *test-set-2* string-natural<?))
     166  (expect-equal *test-result-3* (sort *test-set-3* string-natural<?))
    168167)
    169168
Note: See TracChangeset for help on using the changeset viewer.