Update structty scoring to handle ConcreteNameTy

This commit is contained in:
scottolsen 2020-05-04 11:48:22 -04:00 committed by Nils 'Linkie Pi' Reid
parent 5bc08f200c
commit e1b1a74861
3 changed files with 38 additions and 0 deletions

32
' Normal file
View File

@ -0,0 +1,32 @@
;; Generic tests on sumtypes.
(load "Test.carp")
(use Test)
(deftype A (F [(Fn [] Int)]))
(deftype (Nest a) (Nested [a]))
(def nest (Nest.Nested (Nest.Nested (Nest.Nested 123))))
(defn m [a]
(match a
(A.F f) (f)))
(deftest test
(assert-equal test
123
(m (A.F (fn [] 123)))
"match adds lhs bindings to inner environments")
(assert-equal test
123
(match nest
(Nest.Nested (Nest.Nested (Nest.Nested _)))
123)
"Match matches nested sumtype constructors with underscores")
(assert-equal test
123
(match nest
(Nest.Nested (Nest.Nested (Nest.Nested x)))
x)
"Match matches nested sumtype constructors with variables")
)

BIN
src/.Scoring.hs.swp Normal file

Binary file not shown.

6
t.carp Normal file
View File

@ -0,0 +1,6 @@
(defmodule Foo
(doc Bar "foobar")
(deftype Bar [baz Int])
(defn f [] (Bar.init 2))
)