示例#1
0
        public void CreateMap()
        {
            Map map = new Map(new object[] { new Atom("a"), new Atom("b") }, new object[] { 1, 2 });

            Assert.AreEqual(1, map.GetValue(new Atom("a")));
            Assert.AreEqual(2, map.GetValue(new Atom("b")));
        }
示例#2
0
        public void SetKeyValues()
        {
            Map map = new Map(new object[] { new Atom("a"), new Atom("b"), new Atom("c") }, new object[] { 1, 2, 3 });

            Map newmap = map.SetKeyValues(new object[] { new Atom("c"), new Atom("a") }, new object[] { 4, 5 });

            Assert.AreEqual(1, map.GetValue(new Atom("a")));
            Assert.AreEqual(2, map.GetValue(new Atom("b")));
            Assert.AreEqual(3, map.GetValue(new Atom("c")));

            Assert.AreEqual(5, newmap.GetValue(new Atom("a")));
            Assert.AreEqual(2, newmap.GetValue(new Atom("b")));
            Assert.AreEqual(4, newmap.GetValue(new Atom("c")));
        }
示例#3
0
        public void RaiseIfUndefinedKey()
        {
            Map map = new Map(new object[] { new Atom("a"), new Atom("b") }, new object[] { 1, 2 });

            try
            {
                map.GetValue(new Atom("c"));
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("undefined key c", ex.Message);
            }
        }