{"size": 2954, "ext": "rktl", "max_stars_repo_path": "pkgs/racket-test-core/tests/racket/collects.rktl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-05T21:18:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-04T14:48:37.000Z", "max_issues_repo_path": "pkgs/racket-test-core/tests/racket/collects.rktl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-05-10T07:33:20.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-19T15:49:46.000Z", "max_forks_repo_path": "pkgs/racket-test-core/tests/racket/collects.rktl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 9, "max_forks_count": 3, "avg_line_length": 39.9189189189, "max_line_length": 109, "alphanum_fraction": 0.5592417062}

(load-relative "loadtest.rktl")

(Section 'collects)

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require racket/file)

(let ()
  (define tmp-dir (make-temporary-file "collects~a" 'directory))

  (make-directory* (build-path tmp-dir "zjhyq-1"))
  (with-output-to-file (build-path tmp-dir "zjhyq-1" "m.rkt")
    (lambda ()
      (displayln "#lang racket/base")
      (displayln "(provide v)")
      (displayln "(define v 1)")))
  
  (test #f collection-path "zjhyq-1" #:fail (lambda (s) #f))
  (define (test-found)
    (test (build-path (build-path tmp-dir "zjhyq-1"))
          collection-path "zjhyq-1")
    (test (build-path (build-path tmp-dir "zjhyq-1" "m.rkt"))
          collection-file-path "m.rkt" "zjhyq-1"))

  ;; Add to paths
  (parameterize ([current-library-collection-paths
                  (append (current-library-collection-paths)
                          (list tmp-dir))])
    (test-found))

  ;; Add to link as hash table from #f:
  (parameterize ([current-library-collection-links
                  (append (current-library-collection-links)
                          (list (hash #f (list tmp-dir))))])
    (test-found))

  ;; Add to link as hash table from 'zjhyq-1:
  (parameterize ([current-library-collection-links
                  (append (current-library-collection-links)
                          (list (hash 'zjhyq-1 (list (build-path tmp-dir "zjhyq-1")))))])
    (test-found))

  (delete-directory/files tmp-dir))

;; ----------------------------------------

(err/rt-test (current-library-collection-paths 5))
(err/rt-test (current-library-collection-paths (list 5)))
(err/rt-test (current-library-collection-paths (list "relative")))
;; strings coreced to paths:
(test #t andmap path? (parameterize ([current-library-collection-paths (list (path->string
                                                                              (current-directory)))])
                        (current-library-collection-paths)))

(err/rt-test (current-library-collection-links 5))
(err/rt-test (current-library-collection-links (list 5)))
(err/rt-test (current-library-collection-links (list #t)))
(err/rt-test (current-library-collection-links (list "relative")))
(err/rt-test (current-library-collection-links (list (hash 'bad! null))))
(err/rt-test (current-library-collection-links (list (hash 'ok 5))))
(err/rt-test (current-library-collection-links (list (hash 'ok (list 5)))))
(err/rt-test (current-library-collection-links (list (hash 'ok (list "relative")))))
;; strings coreced to paths:
(test #t andmap path? (parameterize ([current-library-collection-links (list (path->string
                                                                              (build-path (current-directory)
                                                                                          "links.rktd")))])
                        (current-library-collection-links)))

;; ----------------------------------------

(report-errs)
