* ogh * i should save my work * ogh * hhcdfhjbghshbxdfhghshc - lots of bugs in parsing still - invocation is a stub * expr parsing works * awawa * Saving work * Improve APIs a bit all around, add shortcuts. * awa * awa * AAAAAA * save work * Move shit to engine * lord * bql is kill * forgot the fucking bike rack * bql is kill for real * pjb will kill me * aughfhbdj * adgddf * gdsgvfvxshngfgh * b * hfsjhghj * a * tf you mean i have to document it * follow C# standards * Assorted cleanup and documentation pass, minor bugfix in ValueRefParser. * Start porting old commands, remove that pesky prefix in favor of integrating with the shell. * bw * Fix valueref up a bit, improve autocomplete for it. * awa * fix tests * git shut up * Arithmetic commands. * parse improvements * Update engine. --------- Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Toolshed;
|
|
using Robust.Shared.Toolshed.Syntax;
|
|
using Robust.Shared.Toolshed.TypeParsers;
|
|
|
|
namespace Content.IntegrationTests.Tests.Toolshed;
|
|
|
|
[TestFixture]
|
|
public sealed class CommandRunTest : ToolshedTest
|
|
{
|
|
[Test]
|
|
public async Task SimpleCommandRun()
|
|
{
|
|
await Server.WaitAssertion(() =>
|
|
{
|
|
ParseCommand("entities");
|
|
ParseCommand("entities select 1");
|
|
ParseCommand("entities with Item select 1");
|
|
|
|
ExpectError<OutOfInputError>();
|
|
ParseCommand("entities with");
|
|
|
|
ExpectError<NoImplementationError>();
|
|
ParseCommand("player:list with MetaData");
|
|
|
|
ExpectError<ExpressionOfWrongType>();
|
|
ParseCommand("player:list", expectedType: typeof(IEnumerable<EntityUid>));
|
|
|
|
ParseCommand("entities not with MetaData");
|
|
ParseCommand("with MetaData select 2 any", inputType: typeof(List<EntityUid>));
|
|
|
|
ParseCommand("entities not with MetaData => $myEntities");
|
|
ParseCommand("=> $fooBar with MetaData", inputType: typeof(List<EntityUid>));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task EntityUidTypeParser()
|
|
{
|
|
await Server.WaitAssertion(() =>
|
|
{
|
|
ParseCommand("ent 1");
|
|
ParseCommand("ent c1");
|
|
|
|
ExpectError<InvalidEntityUid>();
|
|
ParseCommand("ent foodigity");
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task QuantityTypeParser()
|
|
{
|
|
await Server.WaitAssertion(() =>
|
|
{
|
|
ParseCommand("entities select 100");
|
|
ParseCommand("entities select 50%");
|
|
|
|
ExpectError<InvalidQuantity>();
|
|
ParseCommand("entities select -1");
|
|
|
|
ExpectError<InvalidQuantity>();
|
|
ParseCommand("entities select 200%");
|
|
|
|
ExpectError<InvalidQuantity>();
|
|
ParseCommand("entities select hotdog");
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public async Task ComponentTypeParser()
|
|
{
|
|
await Server.WaitAssertion(() =>
|
|
{
|
|
ParseCommand("entities with MetaData");
|
|
|
|
ExpectError<UnknownComponentError>();
|
|
ParseCommand("entities with Foodiddy");
|
|
|
|
ExpectError<UnknownComponentError>();
|
|
ParseCommand("entities with MetaDataComponent");
|
|
});
|
|
}
|
|
}
|