public void HasFactoryThatProvidesStreamOfUniqueTypeVariables() { var x = TypeVariable.CreateGeneric(); var y = TypeVariable.CreateGeneric(); var xName = ulong.Parse(x.Name); x.ShouldEqual(new TypeVariable(xName)); y.ShouldEqual(new TypeVariable(xName + 1)); TypeVariable.CreateGeneric().ShouldEqual(new TypeVariable(xName + 2)); TypeVariable.CreateNonGeneric().ShouldEqual(new TypeVariable(xName + 3, false)); TypeVariable.CreateGeneric().ShouldEqual(new TypeVariable(xName + 4)); }
public void CanFreshenGenericTypeVariables() { using (TypeVariable.TestFactory()) { //Prevent type '1' from being freshened by marking it as non-generic: var typeVariable0 = TypeVariable.CreateGeneric(); var typeVariable1 = TypeVariable.CreateNonGeneric(); var expectedTypeAfterLookup = new NamedType("A", new TypeVariable(2), typeVariable1, new NamedType("B", new TypeVariable(2), typeVariable1)); var definedType = new NamedType("A", typeVariable0, typeVariable1, new NamedType("B", typeVariable0, typeVariable1)); definedType.FreshenGenericTypeVariables().ShouldEqual(expectedTypeAfterLookup); } }
public void HasFactoryThatCanBeTemporarilyReplacedForTestingPursposes() { using (TypeVariable.TestFactory()) { var x = TypeVariable.CreateGeneric(); var y = TypeVariable.CreateGeneric(); x.ShouldEqual(new TypeVariable(0)); y.ShouldEqual(new TypeVariable(1)); TypeVariable.CreateGeneric().ShouldEqual(new TypeVariable(2)); TypeVariable.CreateNonGeneric().ShouldEqual(new TypeVariable(3, false)); TypeVariable.CreateGeneric().ShouldEqual(new TypeVariable(4)); } }
public void CanNeverBeAGenericTypeDefinition() { TypeVariable.CreateGeneric().IsGenericTypeDefinition.ShouldBeFalse(); TypeVariable.CreateNonGeneric().IsGenericTypeDefinition.ShouldBeFalse(); }
public void CanBeEitherGenericOrNonGeneric() { TypeVariable.CreateGeneric().IsGeneric.ShouldBeTrue(); TypeVariable.CreateNonGeneric().IsGeneric.ShouldBeFalse(); }