(require-extension ports npdiff format-textdiff patch test) (define hunks (let ((large0 (call-with-input-file "tests/large0" read-lines)) (large1 (call-with-input-file "tests/large1" read-lines))) (textdiff large0 large1 3))) (define format make-format-textdiff) (test-group "s-expression patch" (let* ((spatch (textdiff->sexp hunks)) (large1 (with-input-from-file "tests/large1" read-string))) (test "large0 -> large1" large1 (with-output-to-string (lambda () (with-input-from-file "tests/large0" (lambda () (apply-patch spatch)))))))) (test-group "normal diff patch" (let* ((npatch (call-with-output-string (lambda (out) ((format 'normal) out hunks)))) (large1 (with-input-from-file "tests/large1" read-string))) (test "large0 -> large1" large1 (with-output-to-string (lambda () (with-input-from-file "tests/large0" (lambda () (apply-patch (with-input-from-string npatch make-patch))))))))) (define patch-files (list "tests/large0.patch.ed" "tests/large0.patch.rcs" "tests/large0.patch.context")) (define patch-procs (list (lambda (port) ((format 'ed) port hunks)) (lambda (port) ((format 'rcs) port hunks)) (lambda (port) ((format 'context) port hunks "large0" "Sun Jun 3 18:28:06 2007" "large1" "Sun Jun 3 18:28:06 2007")))) (for-each (lambda (patch-file f) (call-with-output-file patch-file f)) patch-files patch-procs)