Changeset 13536 in project


Ignore:
Timestamp:
03/06/09 08:07:22 (11 years ago)
Author:
Kon Lovett
Message:

Release.

Location:
release/4/stack
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • release/4/stack/tags/2.0.0/stack.scm

    r13531 r13536  
    8787            (%list-for-each-1 (lambda (x) (%stack-push-1! stk x)) ls) ) )
    8888
    89 (define-inline (%list-stack-node-ref loc ls idx)
    90   (let ([pr (%list-pair-ref ls idx)])
     89(define-inline (%stack-node-ref loc stk idx)
     90  (let ([pr (%list-pair-ref (%stack-list stk) idx)])
    9191                (if (not (%null? pr)) pr
    9292                          (##sys#signal-hook #:bounds-error loc "out of range" idx 0 (%stack-count stk)) ) ) )
    93 
    94 (define-inline (%stack-node-ref loc stk idx)
    95   (%list-stack-node-ref loc (%stack-list stk) idx) )
    9693
    9794
     
    118115;;;
    119116
    120 (module mailbox (;export
     117(module stack (;export
    121118        make-stack
    122119        list->stack
     
    178175        (%set-car!/maybe-immediate (%stack-node-ref 'stack-poke! stk idx) obj) )
    179176
    180 (define (stack-push! stk !#rest ls)
     177(define (stack-push! stk #!rest ls)
    181178  (%check-stack 'stack-push! stk)
    182179        (unless (%null? ls) (%stack-push! stk ls)) )
     
    194191        ;then removing leading elements
    195192        (let* ([spr (%stack-list stk)]
    196                [epr (%list-stack-node-ref 'stack-cut! spr (%fx- cnt 1))]
     193               [epr (%list-pair-ref spr (%fx- cnt 1))]
    197194               [ls spr])
    198195          (%stack-list-set! stk (%cdr epr))
     
    201198        ;else removing interior elements
    202199        (let* ([spr (%stack-node-ref 'stack-cut! stk (%fx- start 1))]
    203                [epr (%list-stack-node-ref 'stack-cut! spr (%fx- cnt 1))]
     200               [epr (%list-pair-ref spr cnt)]
    204201               [ls (%cdr spr)])
    205202          (%set-cdr!/maybe-immediate spr (%cdr epr))
     
    233230  (with-output-to-port out
    234231    (lambda ()
    235       (display "#<stack ")
     232      (display "#<stack")
    236233      (display " count = ") (display (%stack-count stk))
    237234      (display ">") ) ) )
  • release/4/stack/tags/2.0.0/tests/run.scm

    r13531 r13536  
    77(import stack)
    88
    9 (test-group "Make/Size"
     9(test-group "Empty Stack"
    1010  (test-assert (make-stack))
    1111  (test-assert (stack? (make-stack)))
     
    1414)
    1515
    16 (test-group "Push/Pop/Peek/Poke"
     16(test-group "Push!/Pop!/Peek/Poke!"
    1717  (let ([stk (make-stack)])
    1818    (stack-push! stk 1)
     
    2929    (test 3 (stack-pop! stk))
    3030    (test 4 (stack-pop! stk))
    31     (test 0 (stack-depth stk)) )
    32 )
    33 
    34 (test-group "Cut"
    35   (let ([stk (make-stack)])
    36     (stack-push! stk 1 2 3)
    37     (test '(2) (stack-cut! stk 1))
    38     (test 2 (stack-count stk))
    39     (stack-push! stk 4 5)
    40     (test '(4 3 1) (stack-cut! stk 1 3))
    4131    (test 1 (stack-count stk)) )
    4232)
    4333
    44 (test-group "Aux"
     34(test-group "Cut!"
     35  (let ([stk (make-stack)])
     36    ;3 2 1
     37    (stack-push! stk 1 2 3)
     38    (test '(2) (stack-cut! stk 1 2))
     39    (test 2 (stack-count stk))
     40    ;3 1
     41    (test '(3) (stack-cut! stk 0 1))
     42    (test 1 (stack-count stk))
     43    ;5 4 1
     44    (stack-push! stk 4 5)
     45    (test '(4 1) (stack-cut! stk 1 3))
     46    (test 1 (stack-count stk))
     47    ;
     48    (test-error (stack-cut! stk -1 3))
     49    (test-error (stack-cut! stk 0 3))
     50    (test-error (stack-cut! stk 0 -3)) )
     51)
     52
     53(test-group "Stack from List"
    4554  (let ([stk (make-stack)]
    4655        [stk1 (list->stack '(1 2 3))])
     56    ;
    4757    (stack-push! stk 1 2 3)
    4858    (test '(3 2 1) (stack->list stk))
     59    ;
    4960    (test-assert (stack? stk1))
    5061    (test 3 (stack-count stk1))
  • release/4/stack/trunk/stack.scm

    r13531 r13536  
    8787            (%list-for-each-1 (lambda (x) (%stack-push-1! stk x)) ls) ) )
    8888
    89 (define-inline (%list-stack-node-ref loc ls idx)
    90   (let ([pr (%list-pair-ref ls idx)])
     89(define-inline (%stack-node-ref loc stk idx)
     90  (let ([pr (%list-pair-ref (%stack-list stk) idx)])
    9191                (if (not (%null? pr)) pr
    9292                          (##sys#signal-hook #:bounds-error loc "out of range" idx 0 (%stack-count stk)) ) ) )
    93 
    94 (define-inline (%stack-node-ref loc stk idx)
    95   (%list-stack-node-ref loc (%stack-list stk) idx) )
    9693
    9794
     
    118115;;;
    119116
    120 (module mailbox (;export
     117(module stack (;export
    121118        make-stack
    122119        list->stack
     
    178175        (%set-car!/maybe-immediate (%stack-node-ref 'stack-poke! stk idx) obj) )
    179176
    180 (define (stack-push! stk !#rest ls)
     177(define (stack-push! stk #!rest ls)
    181178  (%check-stack 'stack-push! stk)
    182179        (unless (%null? ls) (%stack-push! stk ls)) )
     
    194191        ;then removing leading elements
    195192        (let* ([spr (%stack-list stk)]
    196                [epr (%list-stack-node-ref 'stack-cut! spr (%fx- cnt 1))]
     193               [epr (%list-pair-ref spr (%fx- cnt 1))]
    197194               [ls spr])
    198195          (%stack-list-set! stk (%cdr epr))
     
    201198        ;else removing interior elements
    202199        (let* ([spr (%stack-node-ref 'stack-cut! stk (%fx- start 1))]
    203                [epr (%list-stack-node-ref 'stack-cut! spr (%fx- cnt 1))]
     200               [epr (%list-pair-ref spr cnt)]
    204201               [ls (%cdr spr)])
    205202          (%set-cdr!/maybe-immediate spr (%cdr epr))
     
    233230  (with-output-to-port out
    234231    (lambda ()
    235       (display "#<stack ")
     232      (display "#<stack")
    236233      (display " count = ") (display (%stack-count stk))
    237234      (display ">") ) ) )
  • release/4/stack/trunk/tests/run.scm

    r13531 r13536  
    77(import stack)
    88
    9 (test-group "Make/Size"
     9(test-group "Empty Stack"
    1010  (test-assert (make-stack))
    1111  (test-assert (stack? (make-stack)))
     
    1414)
    1515
    16 (test-group "Push/Pop/Peek/Poke"
     16(test-group "Push!/Pop!/Peek/Poke!"
    1717  (let ([stk (make-stack)])
    1818    (stack-push! stk 1)
     
    2929    (test 3 (stack-pop! stk))
    3030    (test 4 (stack-pop! stk))
    31     (test 0 (stack-depth stk)) )
    32 )
    33 
    34 (test-group "Cut"
    35   (let ([stk (make-stack)])
    36     (stack-push! stk 1 2 3)
    37     (test '(2) (stack-cut! stk 1))
    38     (test 2 (stack-count stk))
    39     (stack-push! stk 4 5)
    40     (test '(4 3 1) (stack-cut! stk 1 3))
    4131    (test 1 (stack-count stk)) )
    4232)
    4333
    44 (test-group "Aux"
     34(test-group "Cut!"
     35  (let ([stk (make-stack)])
     36    ;3 2 1
     37    (stack-push! stk 1 2 3)
     38    (test '(2) (stack-cut! stk 1 2))
     39    (test 2 (stack-count stk))
     40    ;3 1
     41    (test '(3) (stack-cut! stk 0 1))
     42    (test 1 (stack-count stk))
     43    ;5 4 1
     44    (stack-push! stk 4 5)
     45    (test '(4 1) (stack-cut! stk 1 3))
     46    (test 1 (stack-count stk))
     47    ;
     48    (test-error (stack-cut! stk -1 3))
     49    (test-error (stack-cut! stk 0 3))
     50    (test-error (stack-cut! stk 0 -3)) )
     51)
     52
     53(test-group "Stack from List"
    4554  (let ([stk (make-stack)]
    4655        [stk1 (list->stack '(1 2 3))])
     56    ;
    4757    (stack-push! stk 1 2 3)
    4858    (test '(3 2 1) (stack->list stk))
     59    ;
    4960    (test-assert (stack? stk1))
    5061    (test 3 (stack-count stk1))
Note: See TracChangeset for help on using the changeset viewer.