Example #1
0
        public void CanGetLexiconIndex()
        {
            var list = new Lexicon();

            list.Add(new StringValue("foo"), new StringValue("bar"));
            cpu.PushStack(list);

            const string INDEX = "foo";

            cpu.PushStack(INDEX);

            var opcode = new OpcodeGetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(new StringValue("bar"), cpu.PopStack());
        }
Example #2
0
        public void CanGetLexiconIndex()
        {
            var list = new Lexicon <object, object>();

            list.Add("foo", "bar");
            cpu.PushStack(list);

            const string INDEX = "foo";

            cpu.PushStack(INDEX);

            var opcode = new OpcodeGetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("bar", cpu.PopStack());
        }
Example #3
0
        public void CanGetListIndex()
        {
            var list = new ListValue();

            list.Add(new StringValue("bar"));
            cpu.PushStack(list);

            const int INDEX = 0;

            cpu.PushStack(INDEX);

            var opcode = new OpcodeGetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, list.Count());
            Assert.AreEqual(new StringValue("bar"), cpu.PopStack());
        }
Example #4
0
        public void CanGetDoubleIndex()
        {
            var list = new ListValue();

            list.Add(new StringValue("bar"));
            list.Add(new StringValue("foo"));
            list.Add(new StringValue("fizz"));
            cpu.PushStack(list);

            const double INDEX = 2.5;

            cpu.PushStack(INDEX);

            var opcode = new OpcodeGetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(3, list.Count());
            Assert.AreEqual(new StringValue("fizz"), cpu.PopStack());
        }
Example #5
0
        public void CanGetCorrectListIndex()
        {
            var list = new ListValue();

            list.Add("bar");
            list.Add("foo");
            list.Add("fizz");
            cpu.PushStack(list);

            const int INDEX = 1;

            cpu.PushStack(INDEX);

            var opcode = new OpcodeGetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual("foo", cpu.PopStack());
        }