Toolshed refactor (#33598)
* Content changes for engine toolshed PR * add contains command * more permissive commands
This commit is contained in:
@@ -74,15 +74,15 @@ public abstract class ToolshedTest : IInvocationContext
|
||||
return (T) res!;
|
||||
}
|
||||
|
||||
protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null, bool once = false)
|
||||
protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null)
|
||||
{
|
||||
var parser = new ParserContext(command, Toolshed);
|
||||
var success = CommandRun.TryParse(false, parser, inputType, expectedType, once, out _, out _, out var error);
|
||||
var success = CommandRun.TryParse(parser, inputType, expectedType, out _);
|
||||
|
||||
if (error is not null)
|
||||
ReportError(error);
|
||||
if (parser.Error is not null)
|
||||
ReportError(parser.Error);
|
||||
|
||||
if (error is null)
|
||||
if (parser.Error is null)
|
||||
Assert.That(success, $"Parse failed despite no error being reported. Parsed {command}");
|
||||
}
|
||||
|
||||
@@ -153,11 +153,28 @@ public abstract class ToolshedTest : IInvocationContext
|
||||
return _errors;
|
||||
}
|
||||
|
||||
public bool HasErrors => _errors.Count > 0;
|
||||
|
||||
public void ClearErrors()
|
||||
{
|
||||
_errors.Clear();
|
||||
}
|
||||
|
||||
public object? ReadVar(string name)
|
||||
{
|
||||
return Variables.GetValueOrDefault(name);
|
||||
}
|
||||
|
||||
public void WriteVar(string name, object? value)
|
||||
{
|
||||
Variables[name] = value;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetVars()
|
||||
{
|
||||
return Variables.Keys;
|
||||
}
|
||||
|
||||
public Dictionary<string, object?> Variables { get; } = new();
|
||||
|
||||
protected void ExpectError(Type err)
|
||||
|
||||
Reference in New Issue
Block a user