boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

013-slurp-large.scm (697B)


      1 ;; tests/cc-util/13-slurp-large.scm — slurp-fd handles inputs that span
      2 ;; multiple BUFSIZE refills (BUFSIZE = 4096 in the prelude).
      3 ;; Assumes cc/util.scm is loaded.
      4 
      5 ;; Build a > 2 * BUFSIZE bv (10000 bytes of 'A').
      6 (define big (make-bytevector 10000 65))
      7 
      8 (define op-r (open-output "/tmp/cc-util-13.bin"))
      9 (if (car op-r) 0 (sys-exit 50))
     10 (define wfd (port-fd (cdr op-r)))
     11 (write-bv-fd wfd big)
     12 (sys-close wfd)
     13 
     14 (define ip-r (open-input "/tmp/cc-util-13.bin"))
     15 (if (car ip-r) 0 (sys-exit 51))
     16 (define rfd (port-fd (cdr ip-r)))
     17 (define got (slurp-fd rfd))
     18 (sys-close rfd)
     19 
     20 (if (= (bytevector-length got) 10000) 0 (sys-exit 1))
     21 (if (bv= got big)                     0 (sys-exit 2))
     22 (sys-exit 0)