public void CreateInvalidStack() { ParseContext context = new ParseContext(null); Assert.Throws <IndexOutOfRangeException>(() => { context.PushStack(); context.CreateStackVariable("test", 4); context.PopStack(); context.PopStack(); context.CreateStackVariable("test", 4); }); }
private void Body(ParseContext context) { if (Accept(Tokens.If)) { IfStatement(context); Expect(Tokens.End); context.PopStack(); } else if (Accept(Tokens.Var)) { var token = Expect(Tokens.Name); var name = token.Value; string value = null; if (Accept(Tokens.Assigns)) { value = Var(context); } context.CreateStackVariable(name, value); } else if (Accept(Tokens.Name, out var token)) { if (token.Value == "say") { context.responses.Add(Var(context)); } } else if (Accept(Tokens.Stop)) { _shouldStop = true; } else { _shouldStop = true; } }
public void CreateStackTest() { ParseContext context = new ParseContext(null); context.PushStack(); context.CreateStackVariable("test", 4); context.PopStack(); Assert.False(context.HasVariableOnStack("test")); }