Example #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")));
        }
Example #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")));
        }
Example #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);
            }
        }
Example #4
0
        public void RaiseIfSetUndefinedKey()
        {
            Map map = new Map(new object[] { new Atom("a"), new Atom("b"), new Atom("c") }, new object[] { 1, 2, 3 });

            try
            {
                map.SetKeyValues(new object[] { new Atom("d"), new Atom("a") }, new object[] { 4, 5 });
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("undefined key d", ex.Message);
            }
        }
Example #5
0
 private Map(Map parent, object[] keys, object[] values)
 {
     this.keys = keys;
     this.values = values;
     this.parent = parent;
 }
Example #6
0
 private Map(object[] keys, object[] values)
 {
     this.keys = keys;
     this.values = values;
     this.parent = null;
 }
Example #7
0
 public Map(IList<object> keys, IList<object> values)
 {
     this.keys = keys.ToArray();
     this.values = values.ToArray();
     this.parent = null;
 }