Exemplo n.º 1
0
        public void WillThrowOnNonListType()
        {
            const string INDEX = "foo";

            var lex = new object();

            cpu.PushArgumentStack(lex);

            cpu.PushArgumentStack(INDEX);

            const string VALUE = "fizz";

            cpu.PushArgumentStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);
        }
Exemplo n.º 2
0
        public void WillThrowOnNonIntListIndex()
        {
            var list = new ListValue();

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

            const string INDEX = "fizz";

            cpu.PushArgumentStack(INDEX);

            const string VALUE = "foo";

            cpu.PushArgumentStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);
        }
Exemplo n.º 3
0
        public void CanSetLexiconIndex()
        {
            Encapsulation.Structure index = new StringValue("foo");

            var lex = new Lexicon();

            lex.Add(index, new StringValue("bar"));
            cpu.PushArgumentStack(lex);

            cpu.PushArgumentStack(index);

            const string VALUE = "fizz";

            cpu.PushArgumentStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, lex.Count);
            Assert.AreNotEqual("bar", lex[new StringValue("foo")]);
        }
Exemplo n.º 4
0
        public void CanSetLexiconIndex()
        {
            const string INDEX = "foo";

            var lex = new Lexicon <object, object>();

            lex.Add(INDEX, "bar");
            cpu.PushStack(lex);

            cpu.PushStack(INDEX);

            const string VALUE = "fizz";

            cpu.PushStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, lex.Count);
            Assert.AreNotEqual("bar", lex["foo"]);
        }
Exemplo n.º 5
0
        public void CanSetListIndexWithDouble()
        {
            var list = new ListValue();

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

            const double INDEX = 0.0d;

            cpu.PushArgumentStack(INDEX);

            const string VALUE = "foo";

            cpu.PushArgumentStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, list.Count);
            Assert.AreNotEqual(new StringValue("bar"), list[0]);
            Assert.AreEqual(new StringValue("foo"), list[0]);
        }
Exemplo n.º 6
0
        public void CanSetListIndexWithFloat()
        {
            var list = new ListValue();

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

            const float INDEX = 0.0f;

            cpu.PushStack(INDEX);

            const string VALUE = "foo";

            cpu.PushStack(VALUE);

            var opcode = new OpcodeSetIndex();

            opcode.Execute(cpu);

            Assert.AreEqual(1, list.Count);
            Assert.AreNotEqual("bar", list[0]);
            Assert.AreEqual("foo", list[0]);
        }