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); }
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); }
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")]); }
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"]); }
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]); }
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]); }