示例#1
0
        public void CachedHashCodeLiteralExpr()
        {
            var literal = new LiteralExpr(Token.NoToken, true, /*immutable=*/ true);

            Assert.AreEqual(literal.ComputeHashCode(), literal.GetHashCode());

            var literal2 = new LiteralExpr(Token.NoToken, Microsoft.BaseTypes.BigNum.FromInt(0), /*immutable=*/ true);

            Assert.AreEqual(literal2.ComputeHashCode(), literal2.GetHashCode());

            var literal3 = new LiteralExpr(Token.NoToken, Microsoft.BaseTypes.BigDec.FromInt(0), /*immutable=*/ true);

            Assert.AreEqual(literal3.ComputeHashCode(), literal3.GetHashCode());

            var literal4 = new LiteralExpr(Token.NoToken, Microsoft.BaseTypes.BigNum.FromInt(0), 8, /*immutable=*/ true);

            Assert.AreEqual(literal4.ComputeHashCode(), literal4.GetHashCode());

            var literal5 = new LiteralExpr(Token.NoToken, Microsoft.BaseTypes.BigFloat.FromInt(0), /*immutable=*/ true);

            Assert.AreEqual(literal5.ComputeHashCode(), literal5.GetHashCode());

            var literal6 = new LiteralExpr(Token.NoToken, Microsoft.BaseTypes.RoundingMode.RNE, /*immutable=*/ true);

            Assert.AreEqual(literal6.ComputeHashCode(), literal6.GetHashCode());
        }
示例#2
0
    public void LiteralReal() {
      var constant = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real
      var constant2 = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real

      Assert.AreNotSame(constant, constant2); // These are different references

      Assert.IsTrue(constant.Equals(constant2)); // These are "structurally equal"
      Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode()); // If the .Equals() is true then hash codes must be the same
    }
示例#3
0
    public void LiteralInt() {
      var constant = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer
      var constant2 = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer

      Assert.AreNotSame(constant, constant2); // These are different references

      Assert.IsTrue(constant.Equals(constant2)); // These are "structurally equal"
      Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode()); // If the .Equals() is true then hash codes must be the same
    }
示例#4
0
        public void LiteralReal()
        {
            var constant  = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real
            var constant2 = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real

            Assert.AreNotSame(constant, constant2);                                    // These are different references

            Assert.IsTrue(constant.Equals(constant2));                                 // These are "structurally equal"
            Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode());          // If the .Equals() is true then hash codes must be the same
        }
示例#5
0
        public void LiteralInt()
        {
            var constant  = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer
            var constant2 = new LiteralExpr(Token.NoToken, BigNum.FromInt(18)); // Integer

            Assert.AreNotSame(constant, constant2);                             // These are different references

            Assert.IsTrue(constant.Equals(constant2));                          // These are "structurally equal"
            Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode());   // If the .Equals() is true then hash codes must be the same
        }
示例#6
0
        public void CachedHashCodeLiteralExpr()
        {
            var literal = new LiteralExpr(Token.NoToken, true, /*immutable=*/true);
            Assert.AreEqual(literal.ComputeHashCode(), literal.GetHashCode());

            var literal2 = new LiteralExpr(Token.NoToken, Microsoft.Basetypes.BigNum.FromInt(0), /*immutable=*/true);
            Assert.AreEqual(literal2.ComputeHashCode(), literal2.GetHashCode());

            var literal3 = new LiteralExpr(Token.NoToken, Microsoft.Basetypes.BigDec.FromInt(0), /*immutable=*/true);
            Assert.AreEqual(literal3.ComputeHashCode(), literal3.GetHashCode());

            var literal4 = new LiteralExpr(Token.NoToken, Microsoft.Basetypes.BigNum.FromInt(0), 8, /*immutable=*/true);
            Assert.AreEqual(literal4.ComputeHashCode(), literal4.GetHashCode());
        }