コード例 #1
0
ファイル: MapTypeTests.cs プロジェクト: ajlopez/Husky
        public void CreateMapTypeIntegerToInteger()
        {
            var type = new MapType(IntegerType.Instance, IntegerType.Instance);

            Assert.AreSame(IntegerType.Instance, type.FromType);
            Assert.AreSame(IntegerType.Instance, type.ToType);
        }
コード例 #2
0
ファイル: FunctionTests.cs プロジェクト: ajlopez/Husky
        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));
        }
コード例 #3
0
ファイル: FunctionTests.cs プロジェクト: ajlopez/Husky
        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)));
        }
コード例 #4
0
ファイル: MapTypeTests.cs プロジェクト: ajlopez/Husky
        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)));
        }
コード例 #5
0
ファイル: FunctionTests.cs プロジェクト: ajlopez/Husky
        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);
            }
        }
コード例 #6
0
ファイル: MapTypeTests.cs プロジェクト: ajlopez/Husky
        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());
        }
コード例 #7
0
ファイル: Function.cs プロジェクト: ajlopez/Husky
 public Function(MapType type)
 {
     this.type = type;
 }
コード例 #8
0
ファイル: ConstructorFunction.cs プロジェクト: ajlopez/Husky
 public ConstructorFunction(MapType type)
 {
     this.type = type;
 }