Carp/test/reload.carp
2020-05-10 22:53:35 -04:00

28 lines
801 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)))
(implements = Foo.=))
;;(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."
)
)