Changeset 31393 in project


Ignore:
Timestamp:
09/12/14 03:38:02 (5 years ago)
Author:
Ivan Raikov
Message:

ersatz: added op-pad builtin

Location:
release/4/ersatz/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • release/4/ersatz/trunk/ersatz-lib.scm

    r31371 r31393  
    6464         op-upper op-lower op-join op-substring
    6565         op-replace op-truncate
    66          op-capitalize op-title op-escape-html op-urlize op-striptags
     66         op-capitalize op-title op-escape-html op-urlize op-striptags op-trim op-pad
    6767         op-wordcount op-sort op-dictsort
    6868         op-list op-sublist op-group-by
     
    8585        (import (only utf8 string-length substring)
    8686                (only utf8-srfi-13 string-null? string-every string-upcase
    87                       string-downcase string-titlecase string-concatenate string-trim-both
     87                      string-downcase string-titlecase string-concatenate string-trim-both string-pad
    8888                      string-ci< string<)
    8989                (only utf8-srfi-14 char-set:lower-case char-set:upper-case char-set:whitespace
     
    449449    (title      . ,(func-arg1 op-title))
    450450    (trim       . ,(func-arg1 op-trim))
     451    (pad        . ,(func-arg2 op-pad))
    451452    (urlize     . ,(func-arg1 op-urlize))
    452453    (wordcount  . ,(func-arg1 op-wordcount))
  • release/4/ersatz/trunk/ersatz.setup

    r31373 r31393  
    44  (make-pathname #f fn ##sys#load-dynamic-extension))   
    55
    6 (define version 1.14)
     6(define version 1.15)
    77
    88(use make)
  • release/4/ersatz/trunk/runtime.scm

    r31371 r31393  
    957957    (Tstr (string-trim-both str char-set:whitespace))))
    958958
     959(define (op-pad len str kwargs)
     960  (let ((len (unbox-int len))
     961        (str (unbox-string str)))
     962    (Tstr (string-pad str (+ (string-length str) len)))))
     963
    959964
    960965; procedure: string->goodHTML STRING
  • release/4/ersatz/trunk/tests/run.scm

    r31371 r31393  
    173173                            (op-striptags (Tstr "<p class='indent'>xxx</p> yyy <b>zzz</b>" ) kwargs)
    174174                            (Tstr "xxx yyy zzz")))
     175
     176              (test-assert "trim"
     177                           (tval-equal?
     178                            (op-trim (Tstr "   this is a test   " ) kwargs)
     179                            (Tstr "this is a test")))
     180
     181              (test-assert "pad"
     182                           (tval-equal?
     183                            (op-pad (Tint 5) (Tstr "this is a test" ) kwargs)
     184                            (Tstr "     this is a test")))
    175185
    176186              )
Note: See TracChangeset for help on using the changeset viewer.