mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-12 12:49:13 +03:00
28 lines
801 B
Plaintext
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."
|
|
)
|
|
)
|