public void HasUniqueTypeVariableAsItsType() { using (TypeVariable.TestFactory()) { Type("null").ShouldEqual(NamedType.Nullable(new TypeVariable(6))); } }
public void CanCreateFullyTypedInstance() { using (TypeVariable.TestFactory()) { var @null = (Null)Parse("null"); @null.Type.ShouldEqual(Unknown); var typedNull = WithTypes(@null); typedNull.Type.ShouldEqual(NamedType.Nullable(new TypeVariable(6))); } }
public void HasATypeInWhichTypeVariablesAreFreshenedOnEachScopeLookup() { using (TypeVariable.TestFactory()) { Type("foo", foo => new TypeVariable(0)).ShouldEqual(new TypeVariable(6)); } using (TypeVariable.TestFactory()) { var expectedTypeAfterLookup = new NamedType("A", new TypeVariable(6), new TypeVariable(7), new NamedType("B", new TypeVariable(6), new TypeVariable(7))); var definedType = new NamedType("A", new TypeVariable(0), new TypeVariable(1), new NamedType("B", new TypeVariable(0), new TypeVariable(1))); Type("foo", foo => definedType).ShouldEqual(expectedTypeAfterLookup); } }
public ScopeTests() { using (TypeVariable.TestFactory()) { global = new GlobalScope(); ab = new LocalScope(global); ab.Bind("a", Integer); ab.Bind("b", Integer); cd = new LocalScope(ab); cd.Bind("c", Boolean); cd.Bind("d", Boolean); } }
public void HasATypeInWhichOnlyGenericTypeVariablesAreFreshenedOnEachScopeLookup() { using (TypeVariable.TestFactory()) { //Prevent type '1' from being freshened on type lookup by marking it as non-generic: var typeVariable0 = TypeVariable.CreateGeneric(); var typeVariable1 = TypeVariable.CreateNonGeneric(); var expectedTypeAfterLookup = new NamedType("A", new TypeVariable(8), typeVariable1, new NamedType("B", new TypeVariable(8), typeVariable1)); var definedType = new NamedType("A", typeVariable0, typeVariable1, new NamedType("B", typeVariable0, typeVariable1)); var typeChecker = new TypeChecker(); var globalScope = new GlobalScope(); var localScope = new LocalScope(globalScope); localScope.Bind("foo", definedType); Type("foo", localScope, typeChecker).ShouldEqual(expectedTypeAfterLookup); } }