Пример #1
0
        public void EqualsBig(Integer left, Integer right, bool expected)
        {
            using (Immutability.Guard(left, right))
            {
                var actualOp  = left == right;
                var actualFu  = left.Equals(right);
                var actualObj = left.Equals((object)right);

                Assert.Equal(expected, actualOp);
                Assert.Equal(expected, actualFu);
                Assert.Equal(expected, actualObj);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Integer a = new Integer(10);
            Integer b = new Integer(5);

            b = (Integer)b.Mult(2);
            Console.WriteLine("a.Num = " + a.Num);
            Console.WriteLine("b.Num = " + b.Num);
            Real c = new Real(8);
            Real d = new Real(4);

            c = (Real)c.Divide(0);
            Console.WriteLine("c.Num = " + c.Num);
            Console.WriteLine("a.Equals(b) == " + a.Equals(b) + ", because a.Num == b.Num - " + (a.Num == b.Num));
            Console.WriteLine("a.GetHashCode() = " + a.GetHashCode() + ", b.GetHashCode() = " + b.GetHashCode());
            Console.WriteLine("a.ToString(): " + a.ToString());
            Series ser = new Series();

            ser.EventAdd    += ShowMessage;
            ser.EventSet    += ShowMessage;
            ser.EventInsert += ShowMessage;
            ser.EventDelete += ShowMessage;
            ser.Add(a);
            ser.Add(b);
            ser.Add(c);
            ser.Add(d);
            ser.Set(1, new Real(6.2));
            ser.Insert(2, new Integer(3));
            // ser.Delete(1);
            Console.WriteLine(ser.ToString());
            Console.ReadKey();
        }
Пример #3
0
        public void IntegerCompare()
        {
            var i1 = new Integer(1);
            var i2 = new Integer(1);

            Assert.IsTrue(i1 == i2);
            Assert.IsTrue(i1.Equals(i2));
        }
        public void Test_Main()
        {
            testengine.Reset();
            var result = testengine.ExecuteTestCaseStandard("main");

            Integer wantresult = 22;

            Assert.IsTrue(wantresult.Equals(result.Pop()));
        }
        public void Test_Return_Integer()
        {
            testengine.Reset();
            var result = testengine.ExecuteTestCaseStandard("returnInteger");

            Integer wantresult = 42;

            Assert.IsTrue(wantresult.Equals(result.Pop()));
        }
Пример #6
0
        public void Test_OneReturn()
        {
            testengine.Reset();
            var result = testengine.GetMethod("subtract").Run(5, 9);

            Integer wantresult = -4;

            Assert.IsTrue(wantresult.Equals(result));
        }
Пример #7
0
        public void Test_Main()
        {
            testengine.Reset();
            var result = testengine.GetMethod("main").Run();

            Integer wantresult = 22;

            Assert.IsTrue(wantresult.Equals(result));
        }
Пример #8
0
        public void Test_Return_Integer()
        {
            testengine.Reset();
            var result = testengine.GetMethod("returnInteger").Run();

            Integer wantresult = 42;

            Assert.IsTrue(wantresult.Equals(result));
        }
Пример #9
0
        private static CameraFacingDirection ToCameraFacingDirection(Integer lensFacing)
        {
            if (lensFacing.Equals(LENS_FACING_BACK))
            {
                Tracer.Create("ToCameraFacingDirection").Debug("lensFacing == LENS_FACING_BACK");
                return(CameraFacingDirection.Rear);
            }

            Tracer.Create("ToCameraFacingDirection").Debug("lensFacing == LENS_FACING_FRONT");
            return(CameraFacingDirection.Front);
        }
Пример #10
0
        public void Test_OneReturn()
        {
            var testengine = new TestEngine();

            testengine.AddEntryScript("./TestClasses/Contract_Returns.cs");

            var result = testengine.GetMethod("subtract").Run(5, 9);

            Integer wantresult = -4;

            Assert.IsTrue(wantresult.Equals(result));
        }
Пример #11
0
        public void TestCompareAndSet()
        {
            AtomicReference <Integer> ai = new AtomicReference <Integer>(one);

            assertTrue(ai.CompareAndSet(one, two));
            assertTrue(ai.CompareAndSet(two, m4));
            assertEquals(m4, ai.Value);
            assertFalse(ai.CompareAndSet(m5, seven));
            assertFalse((seven.Equals(ai.Value)));
            assertTrue(ai.CompareAndSet(m4, seven));
            assertEquals(seven, ai.Value);
        }
Пример #12
0
            public bool Equals(TestObject other)
            {
                if (other == null)
                {
                    return(false);
                }

                return(Ascii.Equals(other.Ascii) &&
                       Integer.Equals(other.Integer) &&
                       Boolean.Equals(other.Boolean) &&
                       Unicode.Equals(other.Unicode) &&
                       Single.Equals(other.Single));
            }
Пример #13
0
        public void TestCompareAndSet()
        {
            AtomicReferenceArray <Integer> ai = new AtomicReferenceArray <Integer>(SIZE);

            for (int i = 0; i < SIZE; ++i)
            {
                ai[i] = one;
                assertTrue(ai.CompareAndSet(i, one, two));
                assertTrue(ai.CompareAndSet(i, two, m4));
                assertEquals(m4, ai[i]);
                assertFalse(ai.CompareAndSet(i, m5, seven));
                assertFalse((seven.Equals(ai[i])));
                assertTrue(ai.CompareAndSet(i, m4, seven));
                assertEquals(seven, ai[i]);
            }
        }
Пример #14
0
        public void SerializeIntegerTest(int val)
        {
            Integer inte = new Integer(val);

            using (StreamWriter sw = new StreamWriter($"ser_{nameof(SerializeIntegerTest)}.txt"))
            {
                inte.Serialize(sw);
            }

            using (StreamReader sr = new StreamReader($"ser_{nameof(SerializeIntegerTest)}.txt"))
            {
                Integer inte1 = Integer.Deserialize(sr);

                Assert.IsTrue(inte1.Equals(inte));
            }
        }
Пример #15
0
        public bool equals(object obj)
        {
            if (!(obj is HashEntry))
            {
                return(false);
            }
            var     hashentry = (HashEntry)obj;
            Integer integer   = Integer.valueOf(getHash());
            Integer integer1  = Integer.valueOf(hashentry.getHash());

            if (integer == integer1 || integer != null && integer.Equals(integer1))
            {
                object obj1 = getValue();
                object obj2 = hashentry.getValue();
                if (obj1 == obj2 || obj1 != null && obj1.Equals(obj2))
                {
                    return(true);
                }
            }
            return(false);
        }