Carp/test/reload.carp

28 lines
801 B
Plaintext
Raw Normal View History

2018-09-21 19:09:14 +03:00
;; Sometimes code breaks when it is reloaded
2018-09-21 20:42:43 +03:00
;; 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.
2018-09-21 19:09:14 +03:00
(load-and-use Test)
(deftype (Foo t) [x t])
2018-09-21 19:09:14 +03:00
(defmodule Foo
(defn = [a b]
2020-05-11 05:53:35 +03:00
(= (Foo.x a) (Foo.x b)))
(implements = Foo.=))
2018-09-21 19:09:14 +03:00
;;(deftype (Foo t) [x t]) ;; <- this was the bug, simulate a reload of deftype
2018-09-21 19:09:14 +03:00
(defn test-deftype-bug []
(let [a (= &(Foo.init 123) &(Foo.init 666))
b (= &(Foo.init 123) &(Foo.init 123))]
(and (not a) b)))
2018-09-21 19:09:14 +03:00
2018-11-07 18:11:38 +03:00
(deftest test
(assert-true test
(test-deftype-bug)
"Ensure that bug with redefining type doesn't come back."
)
)