示例#1
0
文件: MapTests.cs 项目: ajlopez/AjErl
        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
文件: MapTests.cs 项目: ajlopez/AjErl
        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
文件: MapTests.cs 项目: ajlopez/AjErl
        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);
            }
        }
示例#4
0
文件: MapTests.cs 项目: ajlopez/AjErl
        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);
            }
        }
示例#5
0
文件: Map.cs 项目: ajlopez/AjErl
 private Map(Map parent, object[] keys, object[] values)
 {
     this.keys = keys;
     this.values = values;
     this.parent = parent;
 }
示例#6
0
文件: Map.cs 项目: ajlopez/AjErl
 private Map(object[] keys, object[] values)
 {
     this.keys = keys;
     this.values = values;
     this.parent = null;
 }
示例#7
0
文件: Map.cs 项目: ajlopez/AjErl
 public Map(IList<object> keys, IList<object> values)
 {
     this.keys = keys.ToArray();
     this.values = values.ToArray();
     this.parent = null;
 }