;;; -*- Lisp -*-

#+scl
(require :http-library)

;; Compare the source files with local versions before loading them.
#+(and (or abcl scl) trust-the-net)
(flet ((compare (url local)
         (with-open-file (stream1 url :element-type 'character
                                      :external-format :utf-8)
           (with-open-file (stream2 local :element-type 'character
                                          :external-format :utf-8)
             (loop
               (let ((ch1 (read-char stream1 nil nil))
                     (ch2 (read-char stream2 nil nil)))
                 (unless (eql ch1 ch2)
                   (error "Unexpected source content."))
                 (unless (and ch1 ch2)
                   (return))))))))
  (let* ((system (find-system "test-urls-1"))
         (url (asdf:component-pathname
               (asdf:find-component system "test"))))
    (compare url "test.lisp"))

  (load-system 'test-urls-1)

  ;; test that it compiled
  (let* ((path (component-pathname
                (find-component "test-urls-1" "test")))
         (test (test-fasl path))
         (test-date (file-write-date test)))
    (format t "~&test-urls-1 1: ~S ~S~%" test test-date)
    (assert test-date)))
