From: Taylor R Campbell Date: Sat, 8 Dec 2018 14:10:14 +0000 (+0000) Subject: Export binary-port-position and set-binary-port-position!. X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=ed92ea0688368f215c4cf4f2e9b186c9105cb622;p=mit-scheme.git Export binary-port-position and set-binary-port-position!. Currently busted for output ports. --- diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 040fe0a20..52cfee958 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -2564,6 +2564,7 @@ USA. binary-i/o-port? binary-input-port? binary-output-port? + binary-port-position binary-port? call-with-output-bytevector get-output-bytevector @@ -2573,6 +2574,7 @@ USA. read-bytevector read-bytevector! read-u8 + set-binary-port-position! textual->binary-port u8-ready? write-bytevector diff --git a/tests/runtime/test-binary-port.scm b/tests/runtime/test-binary-port.scm index 5f4e73118..f2751f423 100644 --- a/tests/runtime/test-binary-port.scm +++ b/tests/runtime/test-binary-port.scm @@ -179,4 +179,28 @@ USA. (assert-false (textual-port? port)) (assert-false (input-port? port)) (assert-true (output-port? port)) - (assert-false (i/o-port? port))) \ No newline at end of file + (assert-false (i/o-port? port))) + +(define-test 'position + (lambda () + (call-with-temporary-file-pathname + (lambda (pathname) + (call-with-binary-output-file pathname + (lambda (port) + (assert-= (binary-port-position port) 0) + (write-u8 42 port) + (expect-failure + (lambda () + (assert-= (binary-port-position port) 1))) + (write-bytevector (make-bytevector 1000 0) port) + (expect-failure + (lambda () + (assert-= (binary-port-position port) 1001))))) + (call-with-binary-input-file pathname + (lambda (port) + (assert-= (binary-port-position port) 0) + (assert-= (read-u8 port) 42) + (assert-= (binary-port-position port) 1) + (assert-equal (read-bytevector 1000 port) + (make-bytevector 1000 0)) + (assert-= (binary-port-position port) 1001))))))) \ No newline at end of file