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()); }
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()); }
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()); }
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()); }
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()); }