public void CreateMapTypeIntegerToInteger() { var type = new MapType(IntegerType.Instance, IntegerType.Instance); Assert.AreSame(IntegerType.Instance, type.FromType); Assert.AreSame(IntegerType.Instance, type.ToType); }
public void MatchFunction() { var type = new MapType(IntegerType.Instance, IntegerType.Instance); var func = new Function(type); var func2 = new Function(type); Assert.IsTrue(func.Match(func, null)); Assert.IsFalse(func.Match(null, null)); Assert.IsFalse(func.Match(func2, null)); }
public void ApplyExpression() { var type = new MapType(IntegerType.Instance, IntegerType.Instance); var func = new Function(type); Assert.AreSame(func, func.Reduce()); Assert.AreSame(type, func.Type); func.Map(new IntegerExpression(1), new IntegerExpression(2)); Assert.AreEqual(new IntegerExpression(2), func.Apply(new IntegerExpression(1))); }
public void Match() { var type = new MapType(IntegerType.Instance, DoubleType.Instance); Assert.IsFalse(type.Match(null)); Assert.IsFalse(type.Match(IntegerType.Instance)); Assert.IsFalse(type.Match(DoubleType.Instance)); Assert.IsFalse(type.Match(new MapType(DoubleType.Instance, DoubleType.Instance))); Assert.IsFalse(type.Match(new MapType(IntegerType.Instance, IntegerType.Instance))); Assert.IsTrue(type.Match(new MapType(IntegerType.Instance, DoubleType.Instance))); }
public void MapInvalidToExpression() { var type = new MapType(IntegerType.Instance, IntegerType.Instance); var func = new Function(type); try { func.Map(new IntegerExpression(1), new DoubleExpression(1.2)); Assert.Fail(); } catch (Exception ex) { Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); Assert.AreEqual("Non compatible type", ex.Message); } }
public void Equality() { var type1 = new MapType(IntegerType.Instance, IntegerType.Instance); var type2 = new MapType(IntegerType.Instance, DoubleType.Instance); var type3 = new MapType(IntegerType.Instance, IntegerType.Instance); Assert.IsFalse(type1.Equals(null)); Assert.IsFalse(type1.Equals(42)); Assert.IsFalse(type1.Equals("foo")); Assert.IsFalse(type1.Equals(type2)); Assert.IsFalse(type2.Equals(type1)); Assert.IsTrue(type1.Equals(type1)); Assert.IsTrue(type1.Equals(type3)); Assert.IsTrue(type3.Equals(type1)); Assert.AreEqual(type1.GetHashCode(), type3.GetHashCode()); }
public Function(MapType type) { this.type = type; }
public ConstructorFunction(MapType type) { this.type = type; }