예제 #1
0
        public void TestBooleanHashKey()
        {
            Boolean_AST hello1 = new Boolean_AST(true);
            Boolean_AST hello2 = new Boolean_AST(true);

            Boolean_AST diff1 = new Boolean_AST(false);
            Boolean_AST diff2 = new Boolean_AST(false);

            //Assert.Equals(hello1.HashKey(), hello2.HashKey());//this assertion works on structs fine

            //if (hello1.HashKey() != hello2.HashKey()) {//outof the box, comparison like this do not work for structs.
            if (!hello1.HashKey().Equals(hello2.HashKey()))
            {
                throw new AssertFailedException("trues do not have same hash key");
            }

            //if (diff1.HashKey() != diff2.HashKey()) {
            if (!diff1.HashKey().Equals(diff2.HashKey()))
            {
                throw new AssertFailedException("falses do not have same hash key");
            }

            //if (hello1.HashKey() == diff1.HashKey()) {
            if (hello1.HashKey().Equals(diff1.HashKey()))
            {
                throw new AssertFailedException("true has same hash key as false");
            }
        }
예제 #2
0
        private void testBooleanObject(Object_AST resultObj, Object_AST expectedObj)
        {
            Boolean_AST result = resultObj as Boolean_AST;

            if (result is null)
            {
                throw new AssertFailedException(string.Format("resultObj is not Boolean. got={0}", resultObj));
            }

            Boolean_AST expected = expectedObj as Boolean_AST;

            if (result is null)
            {
                throw new AssertFailedException(string.Format("expectedObj is not Boolean. got={0}", resultObj));
            }

            Assert.AreEqual(result.Value, expected.Value, string.Format("resultObj has wrong value. got={0}, want={1}", result.Value, expected.Value));
        }