File: constraint_test.go

package info (click to toggle)
golang-github-chewxy-hm 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 216 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package hm

import "testing"

func TestConstraint(t *testing.T) {
	c := Constraint{
		a: TypeVariable('a'),
		b: NewFnType(TypeVariable('b'), TypeVariable('c')),
	}

	ftv := c.FreeTypeVar()
	if !ftv.Equals(TypeVarSet{TypeVariable('a'), TypeVariable('b'), TypeVariable('c')}) {
		t.Error("the free type variables of a Constraint is not as expected")
	}

	subs := mSubs{
		'a': NewFnType(proton, proton),
		'b': proton,
		'c': neutron,
	}

	c = c.Apply(subs).(Constraint)
	if !c.a.Eq(NewFnType(proton, proton)) {
		t.Errorf("c.a: %v", c)
	}

	if !c.b.Eq(NewFnType(proton, neutron)) {
		t.Errorf("c.b: %v", c)
	}
}