예제 #1
0
        public void ErlAtomTest()
        {
            var am_test = new ErlAtom("test");

            Assert.IsTrue(am_test.Equals(new ErlAtom("test")));
            Assert.AreEqual(am_test, new ErlAtom("test"));
            Assert.AreEqual("test", am_test.Value);
            Assert.AreEqual("test", am_test.ToString());
            Assert.IsTrue(am_test.IsScalar);
            Assert.AreEqual(ErlTypeOrder.ErlAtom, am_test.TypeOrder);

            Assert.IsTrue(am_test.Matches(new ErlAtom("test")));
            Assert.AreEqual(new ErlVarBind(), am_test.Match(new ErlAtom("test")));

            var am_Test = new ErlAtom("Test");

            Assert.AreEqual("'Test'", am_Test.ToString());
            Assert.AreEqual(4, am_Test.Length);
            Assert.AreNotEqual(am_test, am_Test);

            IErlObject temp = null;

            Assert.IsFalse(am_test.Subst(ref temp, new ErlVarBind()));

            Assert.IsTrue(am_Test.Visit(true, (acc, o) => acc));

            Assert.DoesNotThrow(() => { var x = am_test.ValueAsObject; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsInt; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsLong; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDecimal; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDateTime; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsTimeSpan; });
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDouble; });
            Assert.DoesNotThrow(() => { var x = am_test.ValueAsString; });
            Assert.DoesNotThrow(() => { var x = am_test.ValueAsBool; });
            Assert.AreEqual('a', new ErlAtom("a").ValueAsChar);
            Assert.Throws <ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsByteArray; });

            string s = am_test; // Implicit conversion

            Assert.AreEqual("test", s);

            ErlAtom a = "abc"; // Implicit conversion

            Assert.AreEqual("abc", a.Value);
        }
예제 #2
0
        public void ErlAtomTest()
        {
            var am_test = new ErlAtom("test");
              Assert.IsTrue(am_test.Equals(new ErlAtom("test")));
              Assert.AreEqual(am_test, new ErlAtom("test"));
              Assert.AreEqual("test", am_test.Value);
              Assert.AreEqual("test", am_test.ToString());
              Assert.IsTrue(am_test.IsScalar);
              Assert.AreEqual(ErlTypeOrder.ErlAtom, am_test.TypeOrder);

              Assert.IsTrue(am_test.Matches(new ErlAtom("test")));
              Assert.AreEqual(new ErlVarBind(), am_test.Match(new ErlAtom("test")));

              var am_Test = new ErlAtom("Test");
              Assert.AreEqual("'Test'", am_Test.ToString());
              Assert.AreEqual(4, am_Test.Length);
              Assert.AreNotEqual(am_test, am_Test);

              IErlObject temp = null;
              Assert.IsFalse(am_test.Subst(ref temp, new ErlVarBind()));

              Assert.IsTrue(am_Test.Visit(true, (acc, o) => acc));

              Assert.DoesNotThrow(() => { var x = am_test.ValueAsObject; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsInt; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsLong; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDecimal; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDateTime; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsTimeSpan; });
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsDouble; });
              Assert.DoesNotThrow(() => { var x = am_test.ValueAsString; });
              Assert.DoesNotThrow(() => { var x = am_test.ValueAsBool; });
              Assert.AreEqual('a', new ErlAtom("a").ValueAsChar);
              Assert.Throws<ErlIncompatibleTypesException>(() => { var x = am_test.ValueAsByteArray; });

              string s = am_test;  // Implicit conversion
              Assert.AreEqual("test", s);

              ErlAtom a = "abc";   // Implicit conversion
              Assert.AreEqual("abc", a.Value);
        }