;;-*- Lisp -*-

(register-directory (subpathname *test-directory* "package-inferred-system-test/"))
(load-system :package-inferred-system-test/a/x)
(load-system :package-inferred-system-test/d)

(signals package-inferred-system-missing-package-error (load-system :package-inferred-system-test/e))

;; No such file.
(signals missing-component
         (handler-bind ((system-out-of-date 'continue)) (load-system :package-inferred-system-test/f)))

;; Test that around-compile is inherited by inferred systems.
(assert-equal 3 (symbol-call :package-inferred-system-test/a :add10 1)) ;; add10 must have been compiled in base 2

;; Test that primary system name returns the correct value when called with a
;; package-inferred-system object.
(assert-equal "package-inferred-system-test" (primary-system-name (find-system :package-inferred-system-test/a/x)))

;; Test that :local-nicknames are recognized on relevant implementations
;; NB: requires ABCL >= ? (old 1.5.0 works), CCL >= 1.12 (unreleased as of Dec 2019),
;; CLASP >= ??? (no less released than anything else?), ECL >= 1.6.4 (unreleased as of Dec 2019),
;; SBCL >= ? (old 1.5.0 works)
#+package-local-nicknames
(progn
  (load-system :package-inferred-system-test/local-nicknames-1)
  (assert-equal "g" (symbol-call :package-inferred-system-test/local-nicknames-1 :f)))

;; Test that SBCL's :lock extension (and the same extension in ECL) successfully infers no dependencies,
;; and that its :implement extension successfully infers dependencies on the packages to be implemented.
;; This test may still run on other implementations, as the implementation-specific defpackage options
;; are behind read-conditionals.
#+ecl(require '#:package-locks)
(with-expected-failure (#+ecl "Old ECL bug with defpackage must be fixed.")
  (load-system :package-inferred-system-test/sbcl-ext-implement)
  (assert-equal "implemented by other package" (symbol-call :package-inferred-system-test/sbcl-ext-lock :implemented-by-other-package)))
