Carp/test/deftype.carp
Erik Svedäng 48489a5771
feat: Implicit struct init (#1003)
* feat: Can omit .init in simple cases

* fix: Don't treat unqualified modules as interface sym:s

* feat: Can handle implicit init of type inside 'use':d module

* fix: Give deftypes and sumtypes correct parent environment!

* test: A few test cases

* refactor: Remove commented out code

Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
2020-11-23 09:59:35 +01:00

27 lines
504 B
Plaintext

(load "Test.carp")
(use Test)
(deftype A [])
(defmodule Wrap
(deftype B []))
(defmodule Wrap2
(deftype C []))
(use Wrap2)
(deftest test
(assert-equal test
"(A)"
(ref (str (ref (A))))
"implicit .init for global type works")
(assert-equal test
"(B)"
(ref (str (ref (Wrap.B))))
"implicit .init for qualified type defined inside module works")
(assert-equal test
"(C)"
(ref (str (ref (C))))
"implicit .init for 'use':d type defined inside module works")
)