Carp/test/reload.carp
2018-11-08 07:16:52 +01:00

27 lines
778 B
Plaintext

;; Sometimes code breaks when it is reloaded
;; It is hard to test proper reloading (using :r or '(reload)' though, since the
;; reload function keep tracks of what files has already evaluated and will ignore
;; those during startup). Instead, these tests will "simulate" reload by code duplication.
(load-and-use Test)
(deftype (Foo t) [x t])
(defmodule Foo
(defn = [a b]
(= (Foo.x a) (Foo.x b))))
;;(deftype (Foo t) [x t]) ;; <- this was the bug, simulate a reload of deftype
(defn test-deftype-bug []
(let [a (= &(Foo.init 123) &(Foo.init 666))
b (= &(Foo.init 123) &(Foo.init 123))]
(and (not a) b)))
(deftest test
(assert-true test
(test-deftype-bug)
"Ensure that bug with redefining type doesn't come back."
)
)