mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[commands] Add until() as alias for withInterrupt() (#3981)
This is a clearer description for the functionality. Will deprecate withInterrupt next year.
This commit is contained in:
@@ -39,11 +39,11 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void withInterruptTest() {
|
||||
void untilTest() {
|
||||
try (CommandScheduler scheduler = new CommandScheduler()) {
|
||||
ConditionHolder condition = new ConditionHolder();
|
||||
|
||||
Command command = new WaitCommand(10).withInterrupt(condition::getCondition);
|
||||
Command command = new WaitCommand(10).until(condition::getCondition);
|
||||
|
||||
scheduler.schedule(command);
|
||||
scheduler.run();
|
||||
|
||||
@@ -40,7 +40,7 @@ class CommandGroupErrorTest extends CommandTestBase {
|
||||
void redecoratedCommandErrorTest() {
|
||||
Command command = new InstantCommand();
|
||||
|
||||
assertDoesNotThrow(() -> command.withTimeout(10).withInterrupt(() -> false));
|
||||
assertDoesNotThrow(() -> command.withTimeout(10).until(() -> false));
|
||||
assertThrows(IllegalArgumentException.class, () -> command.withTimeout(10));
|
||||
CommandGroupBase.clearGroupedCommand(command);
|
||||
assertDoesNotThrow(() -> command.withTimeout(10));
|
||||
|
||||
@@ -34,13 +34,12 @@ TEST_F(CommandDecoratorTest, WithTimeout) {
|
||||
frc::sim::ResumeTiming();
|
||||
}
|
||||
|
||||
TEST_F(CommandDecoratorTest, WithInterrupt) {
|
||||
TEST_F(CommandDecoratorTest, Until) {
|
||||
CommandScheduler scheduler = GetScheduler();
|
||||
|
||||
bool finished = false;
|
||||
|
||||
auto command =
|
||||
RunCommand([] {}, {}).WithInterrupt([&finished] { return finished; });
|
||||
auto command = RunCommand([] {}, {}).Until([&finished] { return finished; });
|
||||
|
||||
scheduler.Schedule(&command);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user