From 9cf0fc77b7296c6771faee03455529d05dd4d316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 24 Aug 2024 12:27:12 -0500 Subject: [PATCH 01/45] Do CommandDecoratorTest --- .../command/CommandDecoratorTest.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index 1f9605d010c..d6448da09ff 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -23,7 +23,7 @@ void withTimeoutTest() { HAL.initialize(500, 0); SimHooks.pauseTiming(); try (CommandScheduler scheduler = new CommandScheduler()) { - Command timeout = new RunCommand(() -> {}).withTimeout(0.1); + Command timeout = Commands.idle().withTimeout(0.1); scheduler.schedule(timeout); scheduler.run(); @@ -44,7 +44,7 @@ void untilTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(); - Command command = new RunCommand(() -> {}).until(finish::get); + Command command = Commands.idle().until(finish::get); scheduler.schedule(command); scheduler.run(); @@ -93,7 +93,7 @@ void onlyWhileTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean run = new AtomicBoolean(true); - Command command = new RunCommand(() -> {}).onlyWhile(run::get); + Command command = Commands.idle().onlyWhile(run::get); scheduler.schedule(command); scheduler.run(); @@ -140,7 +140,7 @@ void onlyWhileOrderTest() { @Test void ignoringDisableTest() { try (CommandScheduler scheduler = new CommandScheduler()) { - var command = new RunCommand(() -> {}).ignoringDisable(true); + var command = Commands.idle().ignoringDisable(true); setDSEnabled(false); @@ -157,7 +157,7 @@ void beforeStartingTest() { AtomicBoolean finished = new AtomicBoolean(); finished.set(false); - Command command = new InstantCommand().beforeStarting(() -> finished.set(true)); + Command command = Commands.none().beforeStarting(() -> finished.set(true)); scheduler.schedule(command); @@ -178,7 +178,7 @@ void andThenLambdaTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finished = new AtomicBoolean(false); - Command command = new InstantCommand().andThen(() -> finished.set(true)); + Command command = Commands.none().andThen(() -> finished.set(true)); scheduler.schedule(command); @@ -199,8 +199,8 @@ void andThenTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean condition = new AtomicBoolean(false); - Command command1 = new InstantCommand(); - Command command2 = new InstantCommand(() -> condition.set(true)); + Command command1 = Commands.none(); + Command command2 = Commands.runOnce(() -> condition.set(true)); Command group = command1.andThen(command2); scheduler.schedule(group); @@ -222,9 +222,9 @@ void deadlineForTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(false); - Command dictator = new WaitUntilCommand(finish::get); - Command endsBefore = new InstantCommand(); - Command endsAfter = new WaitUntilCommand(() -> false); + Command dictator = Commands.waitUntil(finish::get); + Command endsBefore = Commands.none(); + Command endsAfter = Commands.idle(); Command group = dictator.deadlineFor(endsBefore, endsAfter); @@ -276,8 +276,8 @@ void alongWithTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(false); - Command command1 = new WaitUntilCommand(finish::get); - Command command2 = new InstantCommand(); + Command command1 = Commands.waitUntil(finish::get); + Command command2 = Commands.none(); Command group = command1.alongWith(command2); @@ -326,8 +326,8 @@ void alongWithOrderTest() { @Test void raceWithTest() { try (CommandScheduler scheduler = new CommandScheduler()) { - Command command1 = new WaitUntilCommand(() -> false); - Command command2 = new InstantCommand(); + Command command1 = Commands.idle(); + Command command2 = Commands.none(); Command group = command1.raceWith(command2); @@ -375,7 +375,7 @@ void unlessTest() { AtomicBoolean hasRun = new AtomicBoolean(false); AtomicBoolean unlessCondition = new AtomicBoolean(true); - Command command = new InstantCommand(() -> hasRun.set(true)).unless(unlessCondition::get); + Command command = Commands.runOnce(() -> hasRun.set(true)).unless(unlessCondition::get); scheduler.schedule(command); scheduler.run(); @@ -394,7 +394,7 @@ void onlyIfTest() { AtomicBoolean hasRun = new AtomicBoolean(false); AtomicBoolean onlyIfCondition = new AtomicBoolean(false); - Command command = new InstantCommand(() -> hasRun.set(true)).onlyIf(onlyIfCondition::get); + Command command = Commands.runOnce(() -> hasRun.set(true)).onlyIf(onlyIfCondition::get); scheduler.schedule(command); scheduler.run(); @@ -480,7 +480,7 @@ void handleInterruptTest() { @Test void withNameTest() { - InstantCommand command = new InstantCommand(); + Command command = Commands.none(); String name = "Named"; Command named = command.withName(name); assertEquals(name, named.getName()); From 2997b22e3a8ace83a8290736df6440d51c0261aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 24 Aug 2024 17:23:38 -0500 Subject: [PATCH 02/45] Do CommandRequirementsTest --- .../wpi/first/wpilibj2/command/CommandRequirementsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandRequirementsTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandRequirementsTest.java index 47657e19ed8..45f017c3880 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandRequirementsTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandRequirementsTest.java @@ -45,7 +45,7 @@ void requirementUninterruptibleTest() { Subsystem requirement = new SubsystemBase() {}; Command notInterrupted = - new RunCommand(() -> {}, requirement) + Commands.idle(requirement) .withInterruptBehavior(Command.InterruptionBehavior.kCancelIncoming); MockCommandHolder interrupterHolder = new MockCommandHolder(true, requirement); Command interrupter = interrupterHolder.getMock(); @@ -63,7 +63,7 @@ void defaultCommandRequirementErrorTest() { try (CommandScheduler scheduler = new CommandScheduler()) { Subsystem system = new SubsystemBase() {}; - Command missingRequirement = new WaitUntilCommand(() -> false); + Command missingRequirement = Commands.idle(); assertThrows( IllegalArgumentException.class, From eb2d761e5b207bbc6f67a9062d40c9b150d2d5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 24 Aug 2024 21:36:00 -0500 Subject: [PATCH 03/45] Do MultiCompositionTestBase.java --- .../command/MultiCompositionTestBase.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java index 9fafc5905c3..882abaec56c 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java @@ -27,38 +27,38 @@ static Stream interruptible() { arguments( "AllCancelSelf", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf)), arguments( "AllCancelIncoming", InterruptionBehavior.kCancelIncoming, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), arguments( "TwoCancelSelfOneIncoming", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), arguments( "TwoCancelIncomingOneSelf", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf))); } @@ -79,27 +79,27 @@ static Stream runsWhenDisabled() { arguments( "AllFalse", false, - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(false)), + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(false)), arguments( "AllTrue", true, - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(true)), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(true)), arguments( "TwoTrueOneFalse", false, - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(false)), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(false)), arguments( "TwoFalseOneTrue", false, - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(true))); + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(true))); } @MethodSource @@ -115,8 +115,8 @@ void runsWhenDisabled( } static Stream composeDuplicates() { - Command a = new InstantCommand(() -> {}); - Command b = new InstantCommand(() -> {}); + Command a = Commands.none(); + Command b = Commands.none(); return Stream.of( arguments("AA", new Command[] {a, a}), arguments("ABA", new Command[] {a, b, a}), From cdd2f05921af178292770df29dd621da427a9398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 24 Aug 2024 21:40:57 -0500 Subject: [PATCH 04/45] Do ConditionalCommandTest --- .../command/ConditionalCommandTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java index 4659f0ec3d4..cd37ad75707 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java @@ -74,33 +74,33 @@ static Stream interruptible() { arguments( "AllCancelSelf", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), (BooleanSupplier) () -> true), arguments( "AllCancelIncoming", InterruptionBehavior.kCancelIncoming, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), (BooleanSupplier) () -> true), arguments( "OneCancelSelfOneIncoming", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), (BooleanSupplier) () -> true), arguments( "OneCancelIncomingOneSelf", InterruptionBehavior.kCancelSelf, - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - new WaitUntilCommand(() -> false) + Commands.idle() .withInterruptBehavior(InterruptionBehavior.kCancelSelf), (BooleanSupplier) () -> true)); } @@ -122,26 +122,26 @@ static Stream runsWhenDisabled() { arguments( "AllFalse", false, - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(false), + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(false), (BooleanSupplier) () -> true), arguments( "AllTrue", true, - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(true), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(true), (BooleanSupplier) () -> true), arguments( "OneTrueOneFalse", false, - new WaitUntilCommand(() -> false).ignoringDisable(true), - new WaitUntilCommand(() -> false).ignoringDisable(false), + Commands.idle().ignoringDisable(true), + Commands.idle().ignoringDisable(false), (BooleanSupplier) () -> true), arguments( "OneFalseOneTrue", false, - new WaitUntilCommand(() -> false).ignoringDisable(false), - new WaitUntilCommand(() -> false).ignoringDisable(true), + Commands.idle().ignoringDisable(false), + Commands.idle().ignoringDisable(true), (BooleanSupplier) () -> true)); } From 599556d7df3f23425a59f55a6d9237ba1132cbf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 24 Aug 2024 21:45:17 -0500 Subject: [PATCH 05/45] Do ParallelDeadlineGroupTest --- .../first/wpilibj2/command/ParallelDeadlineGroupTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelDeadlineGroupTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelDeadlineGroupTest.java index 206d801015b..b3d7dfb5563 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelDeadlineGroupTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelDeadlineGroupTest.java @@ -127,15 +127,15 @@ void parallelDeadlineRequirementErrorTest() { @Test void parallelDeadlineSetDeadlineToDeadlineTest() { - Command a = new InstantCommand(() -> {}); + Command a = Commands.none(); ParallelDeadlineGroup group = new ParallelDeadlineGroup(a); assertDoesNotThrow(() -> group.setDeadline(a)); } @Test void parallelDeadlineSetDeadlineDuplicateTest() { - Command a = new InstantCommand(() -> {}); - Command b = new InstantCommand(() -> {}); + Command a = Commands.none(); + Command b = Commands.none(); ParallelDeadlineGroup group = new ParallelDeadlineGroup(a, b); assertThrows(IllegalArgumentException.class, () -> group.setDeadline(b)); } From 6ab83c892070da9c80c683358b2d047525aa2ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:37:42 -0500 Subject: [PATCH 06/45] Do ParallelRaceGroupTest --- .../edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java index ea780c6216e..d20e851575d 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java @@ -140,7 +140,7 @@ void parallelRaceOnlyCallsEndOnceTest() { MockCommandHolder command3Holder = new MockCommandHolder(true); Command command3 = command3Holder.getMock(); - Command group1 = new SequentialCommandGroup(command1, command2); + Command group1 = command1.andThen(command2); assertNotNull(group1); assertNotNull(command3); Command group2 = new ParallelRaceGroup(group1, command3); From 25114a8e489db44643bfefd3a71b845431eaa21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:40:55 -0500 Subject: [PATCH 07/45] Do ProxyCommandTest --- .../java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java index c4b43a609b7..2eae20bbc85 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ProxyCommandTest.java @@ -31,7 +31,7 @@ void proxyCommandEndTest() { try (CommandScheduler scheduler = CommandScheduler.getInstance()) { AtomicBoolean cond = new AtomicBoolean(); - WaitUntilCommand command = new WaitUntilCommand(cond::get); + Command command = Commands.waitUntil(cond::get); ProxyCommand scheduleCommand = new ProxyCommand(command); From 075237667c3583cebe460f5eeed42583344ef4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:46:58 -0500 Subject: [PATCH 08/45] Do ScheduleCommandTest --- .../edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java index 9014bc7b96e..096168ea879 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java @@ -36,7 +36,7 @@ void scheduleCommandDuringRunTest() { new SequentialCommandGroup(new InstantCommand(), scheduleCommand); scheduler.schedule(group); - scheduler.schedule(new RunCommand(() -> {})); + scheduler.schedule(Commands.idle()); scheduler.run(); assertDoesNotThrow(scheduler::run); } From b1d863affb7cc8458258080e42657f13213bed37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:50:15 -0500 Subject: [PATCH 09/45] Do SchedulerTest --- .../edu/wpi/first/wpilibj2/command/SchedulerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulerTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulerTest.java index 1e0b33332e8..0a6eb3df5ca 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulerTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulerTest.java @@ -23,7 +23,7 @@ void schedulerLambdaTestNoInterrupt() { scheduler.onCommandExecute(command -> counter.incrementAndGet()); scheduler.onCommandFinish(command -> counter.incrementAndGet()); - scheduler.schedule(new InstantCommand()); + scheduler.schedule(Commands.none()); scheduler.run(); assertEquals(counter.get(), 3); @@ -37,7 +37,7 @@ void schedulerInterruptLambdaTest() { scheduler.onCommandInterrupt(command -> counter.incrementAndGet()); - Command command = new WaitCommand(10); + Command command = Commands.idle(); scheduler.schedule(command); scheduler.cancel(command); @@ -162,8 +162,8 @@ void schedulerCancelAllTest() { scheduler.onCommandInterrupt(command -> counter.incrementAndGet()); scheduler.onCommandInterrupt((command, interruptor) -> assertFalse(interruptor.isPresent())); - Command command = new WaitCommand(10); - Command command2 = new WaitCommand(10); + Command command = Commands.idle(); + Command command2 = Commands.idle(); scheduler.schedule(command); scheduler.schedule(command2); From 9d65c17ed5c104b2040309cce45ef398dcf39121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:53:45 -0500 Subject: [PATCH 10/45] Do SchedulingRecursionTest --- .../command/SchedulingRecursionTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java index a253740c028..0153f2f1d1e 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java @@ -48,7 +48,7 @@ public InterruptionBehavior getInterruptionBehavior() { return interruptionBehavior; } }; - Command other = new RunCommand(() -> hasOtherRun.set(true), requirement); + Command other = requirement.run(() -> hasOtherRun.set(true)); assertDoesNotThrow( () -> { @@ -87,7 +87,7 @@ public InterruptionBehavior getInterruptionBehavior() { return interruptionBehavior; } }; - Command other = new RunCommand(() -> hasOtherRun.set(true), requirement); + Command other = requirement.run(() -> hasOtherRun.set(true)); assertDoesNotThrow( () -> { @@ -132,7 +132,7 @@ public InterruptionBehavior getInterruptionBehavior() { return interruptionBehavior; } }; - Command other = new RunCommand(() -> hasOtherRun.set(true), requirement); + Command other = requirement.run(() -> hasOtherRun.set(true)); scheduler.setDefaultCommand(requirement, other); assertDoesNotThrow( @@ -173,7 +173,7 @@ public void end(boolean interrupted) { void cancelFromInterruptAction() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); - Command selfCancels = new RunCommand(() -> {}); + Command selfCancels = Commands.idle(); scheduler.onCommandInterrupt( cmd -> { counter.incrementAndGet(); @@ -329,7 +329,7 @@ void scheduleFromEndCancel() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new SubsystemBase() {}; - InstantCommand other = new InstantCommand(() -> {}, requirement); + Command other = requirement.runOnce(() -> {}); FunctionalCommand selfCancels = new FunctionalCommand( () -> {}, @@ -354,7 +354,7 @@ void scheduleFromEndInterrupt() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new SubsystemBase() {}; - InstantCommand other = new InstantCommand(() -> {}, requirement); + InstantCommand other = requirement.runOnce(() -> {}); FunctionalCommand selfCancels = new FunctionalCommand( () -> {}, @@ -380,8 +380,8 @@ void scheduleFromEndInterruptAction() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new Subsystem() {}; - InstantCommand other = new InstantCommand(() -> {}, requirement); - InstantCommand selfCancels = new InstantCommand(() -> {}, requirement); + InstantCommand other = requirement.runOnce(() -> {}); + InstantCommand selfCancels = requirement.runOnce(() -> {}); scheduler.onCommandInterrupt( cmd -> { counter.incrementAndGet(); @@ -403,7 +403,7 @@ void scheduleInitializeFromDefaultCommand(InterruptionBehavior interruptionBehav AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new SubsystemBase() {}; Command other = - new InstantCommand(() -> {}, requirement).withInterruptBehavior(interruptionBehavior); + requirement.runOnce(() -> {}).withInterruptBehavior(interruptionBehavior); FunctionalCommand defaultCommand = new FunctionalCommand( () -> { @@ -438,7 +438,7 @@ void cancelDefaultCommandFromEnd() { interrupted -> counter.incrementAndGet(), () -> false, requirement); - Command other = new InstantCommand(() -> {}, requirement); + Command other = requirement.runOnce(() -> {}); Command cancelDefaultCommand = new FunctionalCommand( () -> {}, From 1240dc8a84859f402d9bffbcaaf024647c8b9fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 09:55:00 -0500 Subject: [PATCH 11/45] Do SchedulingRecursionTest --- .../wpi/first/wpilibj2/command/SchedulingRecursionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java index 0153f2f1d1e..4980a3c6c1a 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java @@ -354,7 +354,7 @@ void scheduleFromEndInterrupt() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new SubsystemBase() {}; - InstantCommand other = requirement.runOnce(() -> {}); + Command other = requirement.runOnce(() -> {}); FunctionalCommand selfCancels = new FunctionalCommand( () -> {}, @@ -380,8 +380,8 @@ void scheduleFromEndInterruptAction() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new Subsystem() {}; - InstantCommand other = requirement.runOnce(() -> {}); - InstantCommand selfCancels = requirement.runOnce(() -> {}); + Command other = requirement.runOnce(() -> {}); + Command selfCancels = requirement.runOnce(() -> {}); scheduler.onCommandInterrupt( cmd -> { counter.incrementAndGet(); From 063ebaed58ac6386411263276c9e344ff043861a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 10:25:42 -0500 Subject: [PATCH 12/45] Fix ParallelRaceGroupTest failing command1 and command2 are mock Commands that don't actually implement Command decorators --- .../edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java index d20e851575d..bd44a128b8c 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ParallelRaceGroupTest.java @@ -140,7 +140,7 @@ void parallelRaceOnlyCallsEndOnceTest() { MockCommandHolder command3Holder = new MockCommandHolder(true); Command command3 = command3Holder.getMock(); - Command group1 = command1.andThen(command2); + Command group1 = Commands.sequence(command1, command2); assertNotNull(group1); assertNotNull(command3); Command group2 = new ParallelRaceGroup(group1, command3); From c44fb833908ef4abb066d0fcc72bc341e90618c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 10:27:55 -0500 Subject: [PATCH 13/45] Do SelectCommandTest --- .../java/edu/wpi/first/wpilibj2/command/SelectCommandTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SelectCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SelectCommandTest.java index e364468186c..f6f551bd6e9 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SelectCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SelectCommandTest.java @@ -97,7 +97,7 @@ void selectCommandRequirementTest() { () -> "one"); scheduler.schedule(selectCommand); - scheduler.schedule(new InstantCommand(() -> {}, system3)); + scheduler.schedule(system3.runOnce(() -> {})); assertFalse(scheduler.isScheduled(selectCommand)); From 2c879601fae7f7d25c98ba84f3013b3a21dcd170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 10:29:57 -0500 Subject: [PATCH 14/45] Do SingleCompositionTestBase --- .../wpilibj2/command/SingleCompositionTestBase.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java index a063a1de638..ce4ef549bed 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java @@ -20,7 +20,7 @@ public abstract class SingleCompositionTestBase extends Comma void interruptible(Command.InterruptionBehavior interruptionBehavior) { var command = composeSingle( - new WaitUntilCommand(() -> false).withInterruptBehavior(interruptionBehavior)); + Commands.idle().withInterruptBehavior(interruptionBehavior)); assertEquals(interruptionBehavior, command.getInterruptionBehavior()); } @@ -28,27 +28,27 @@ void interruptible(Command.InterruptionBehavior interruptionBehavior) { @ParameterizedTest void runWhenDisabled(boolean runsWhenDisabled) { var command = - composeSingle(new WaitUntilCommand(() -> false).ignoringDisable(runsWhenDisabled)); + composeSingle(Commands.idle().ignoringDisable(runsWhenDisabled)); assertEquals(runsWhenDisabled, command.runsWhenDisabled()); } @Test void commandInOtherCompositionTest() { - var command = new InstantCommand(); + var command = Commands.none(); new WrapperCommand(command) {}; assertThrows(IllegalArgumentException.class, () -> composeSingle(command)); } @Test void commandInMultipleCompositionsTest() { - var command = new InstantCommand(); + var command = Commands.none(); composeSingle(command); assertThrows(IllegalArgumentException.class, () -> composeSingle(command)); } @Test void composeThenScheduleTest() { - var command = new InstantCommand(); + var command = Commands.none(); composeSingle(command); assertThrows( IllegalArgumentException.class, () -> CommandScheduler.getInstance().schedule(command)); @@ -56,7 +56,7 @@ void composeThenScheduleTest() { @Test void scheduleThenComposeTest() { - var command = new RunCommand(() -> {}); + var command = Commands.idle(); CommandScheduler.getInstance().schedule(command); assertThrows(IllegalArgumentException.class, () -> composeSingle(command)); } From 443b982c15516075376adc96605f568f05706abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 25 Aug 2024 10:35:24 -0500 Subject: [PATCH 15/45] Do ScheduleCommandTest --- .../edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java index 096168ea879..68299d86726 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java @@ -30,10 +30,10 @@ void scheduleCommandScheduleTest() { @Test void scheduleCommandDuringRunTest() { try (CommandScheduler scheduler = CommandScheduler.getInstance()) { - InstantCommand toSchedule = new InstantCommand(); + Command toSchedule = Commands.none(); ScheduleCommand scheduleCommand = new ScheduleCommand(toSchedule); - SequentialCommandGroup group = - new SequentialCommandGroup(new InstantCommand(), scheduleCommand); + Command group = + Commands.sequence(Commands.none(), scheduleCommand); scheduler.schedule(group); scheduler.schedule(Commands.idle()); From 8088350cf75e4b1c752b98d035fb53e4aa136957 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 25 Aug 2024 15:56:56 +0000 Subject: [PATCH 16/45] Formatting fixes --- .../command/ConditionalCommandTest.java | 24 +++++-------- .../command/MultiCompositionTestBase.java | 36 +++++++------------ .../wpilibj2/command/ScheduleCommandTest.java | 3 +- .../command/SchedulingRecursionTest.java | 3 +- .../command/SingleCompositionTestBase.java | 7 ++-- 5 files changed, 24 insertions(+), 49 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java index cd37ad75707..7b9817f5645 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ConditionalCommandTest.java @@ -74,34 +74,26 @@ static Stream interruptible() { arguments( "AllCancelSelf", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), (BooleanSupplier) () -> true), arguments( "AllCancelIncoming", InterruptionBehavior.kCancelIncoming, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), (BooleanSupplier) () -> true), arguments( "OneCancelSelfOneIncoming", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), (BooleanSupplier) () -> true), arguments( "OneCancelIncomingOneSelf", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), (BooleanSupplier) () -> true)); } diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java index 882abaec56c..1b0e8e91419 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/MultiCompositionTestBase.java @@ -27,39 +27,27 @@ static Stream interruptible() { arguments( "AllCancelSelf", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf)), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf)), arguments( "AllCancelIncoming", InterruptionBehavior.kCancelIncoming, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), arguments( "TwoCancelSelfOneIncoming", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming)), arguments( "TwoCancelIncomingOneSelf", InterruptionBehavior.kCancelSelf, - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelIncoming), - Commands.idle() - .withInterruptBehavior(InterruptionBehavior.kCancelSelf))); + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelIncoming), + Commands.idle().withInterruptBehavior(InterruptionBehavior.kCancelSelf))); } @MethodSource diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java index 68299d86726..875b2e5ea9b 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/ScheduleCommandTest.java @@ -32,8 +32,7 @@ void scheduleCommandDuringRunTest() { try (CommandScheduler scheduler = CommandScheduler.getInstance()) { Command toSchedule = Commands.none(); ScheduleCommand scheduleCommand = new ScheduleCommand(toSchedule); - Command group = - Commands.sequence(Commands.none(), scheduleCommand); + Command group = Commands.sequence(Commands.none(), scheduleCommand); scheduler.schedule(group); scheduler.schedule(Commands.idle()); diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java index 4980a3c6c1a..06f4023f6b8 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SchedulingRecursionTest.java @@ -402,8 +402,7 @@ void scheduleInitializeFromDefaultCommand(InterruptionBehavior interruptionBehav try (CommandScheduler scheduler = new CommandScheduler()) { AtomicInteger counter = new AtomicInteger(); Subsystem requirement = new SubsystemBase() {}; - Command other = - requirement.runOnce(() -> {}).withInterruptBehavior(interruptionBehavior); + Command other = requirement.runOnce(() -> {}).withInterruptBehavior(interruptionBehavior); FunctionalCommand defaultCommand = new FunctionalCommand( () -> { diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java index ce4ef549bed..5f6fe9e8616 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/SingleCompositionTestBase.java @@ -18,17 +18,14 @@ public abstract class SingleCompositionTestBase extends Comma @EnumSource(Command.InterruptionBehavior.class) @ParameterizedTest void interruptible(Command.InterruptionBehavior interruptionBehavior) { - var command = - composeSingle( - Commands.idle().withInterruptBehavior(interruptionBehavior)); + var command = composeSingle(Commands.idle().withInterruptBehavior(interruptionBehavior)); assertEquals(interruptionBehavior, command.getInterruptionBehavior()); } @ValueSource(booleans = {true, false}) @ParameterizedTest void runWhenDisabled(boolean runsWhenDisabled) { - var command = - composeSingle(Commands.idle().ignoringDisable(runsWhenDisabled)); + var command = composeSingle(Commands.idle().ignoringDisable(runsWhenDisabled)); assertEquals(runsWhenDisabled, command.runsWhenDisabled()); } From 717b66fd0172b0742ce508b669883aeb6f6c295c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 13 Sep 2024 23:05:41 -0500 Subject: [PATCH 17/45] Start work on CommandDecoratorTest --- .../cpp/frc2/command/CommandDecoratorTest.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index a5059b16e11..7bf1eed3fec 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -7,6 +7,7 @@ #include "CommandTestBase.h" #include "frc2/command/FunctionalCommand.h" #include "frc2/command/InstantCommand.h" +#include "frc2/command/Commands.h" #include "frc2/command/RunCommand.h" #include "frc2/command/WaitUntilCommand.h" @@ -18,7 +19,7 @@ TEST_F(CommandDecoratorTest, WithTimeout) { frc::sim::PauseTiming(); - auto command = RunCommand([] {}, {}).WithTimeout(100_ms); + auto command = cmd::Idle().WithTimeout(100_ms); scheduler.Schedule(command); scheduler.Run(); @@ -39,7 +40,7 @@ TEST_F(CommandDecoratorTest, Until) { bool finish = false; - auto command = RunCommand([] {}, {}).Until([&finish] { return finish; }); + auto command = cmd::Idle().Until([&finish] { return finish; }); scheduler.Schedule(command); scheduler.Run(); @@ -82,7 +83,7 @@ TEST_F(CommandDecoratorTest, OnlyWhile) { bool run = true; - auto command = RunCommand([] {}, {}).OnlyWhile([&run] { return run; }); + auto command = cmd::Idle().OnlyWhile([&run] { return run; }); scheduler.Schedule(command); scheduler.Run(); @@ -123,7 +124,7 @@ TEST_F(CommandDecoratorTest, OnlyWhileOrder) { TEST_F(CommandDecoratorTest, IgnoringDisable) { CommandScheduler scheduler = GetScheduler(); - auto command = RunCommand([] {}, {}).IgnoringDisable(true); + auto command = cmd::Idle().IgnoringDisable(true); SetDSEnabled(false); @@ -138,7 +139,7 @@ TEST_F(CommandDecoratorTest, BeforeStarting) { bool finished = false; - auto command = InstantCommand([] {}, {}).BeforeStarting( + auto command = cmd::None().BeforeStarting( [&finished] { finished = true; }); scheduler.Schedule(command); @@ -160,7 +161,7 @@ TEST_F(CommandDecoratorTest, AndThenLambda) { bool finished = false; auto command = - InstantCommand([] {}, {}).AndThen([&finished] { finished = true; }); + cmd::None().AndThen([&finished] { finished = true; }); scheduler.Schedule(command); From 497e3cc6efdd0b18397ca13ab5c980dd25edfffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 20 Sep 2024 11:20:58 -0500 Subject: [PATCH 18/45] CommandDecoratorTest done --- .../cpp/frc2/command/CommandDecoratorTest.cpp | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 7bf1eed3fec..5cc1bb99afb 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -181,9 +181,9 @@ TEST_F(CommandDecoratorTest, AndThen) { bool finished = false; - auto command1 = InstantCommand(); - auto command2 = InstantCommand([&finished] { finished = true; }); - auto group = std::move(command1).AndThen(std::move(command2).ToPtr()); + auto command1 = cmd::None(); + auto command2 = cmd::RunOnce([&finished] { finished = true; }); + auto group = std::move(command1).AndThen(std::move(command2)); scheduler.Schedule(group); @@ -203,10 +203,10 @@ TEST_F(CommandDecoratorTest, DeadlineFor) { bool finish = false; - auto dictator = WaitUntilCommand([&finish] { return finish; }); - auto endsAfter = WaitUntilCommand([] { return false; }); + auto dictator = cmd::WaitUntil([&finish] { return finish; }); + auto endsAfter = cmd::Idle(); - auto group = std::move(dictator).DeadlineFor(std::move(endsAfter).ToPtr()); + auto group = std::move(dictator).DeadlineFor(std::move(endsAfter)); scheduler.Schedule(group); scheduler.Run(); @@ -224,10 +224,10 @@ TEST_F(CommandDecoratorTest, AlongWith) { bool finish = false; - auto command1 = WaitUntilCommand([&finish] { return finish; }); - auto command2 = InstantCommand(); + auto command1 = cmd::WaitUntil([&finish] { return finish; }); + auto command2 = cmd::None(); - auto group = std::move(command1).AlongWith(std::move(command2).ToPtr()); + auto group = std::move(command1).AlongWith(std::move(command2)); scheduler.Schedule(group); scheduler.Run(); @@ -243,10 +243,10 @@ TEST_F(CommandDecoratorTest, AlongWith) { TEST_F(CommandDecoratorTest, RaceWith) { CommandScheduler scheduler = GetScheduler(); - auto command1 = WaitUntilCommand([] { return false; }); - auto command2 = InstantCommand(); + auto command1 = cmd::Idle(); + auto command2 = cmd::None(); - auto group = std::move(command1).RaceWith(std::move(command2).ToPtr()); + auto group = std::move(command1).RaceWith(std::move(command2)); scheduler.Schedule(group); scheduler.Run(); @@ -267,12 +267,12 @@ TEST_F(CommandDecoratorTest, DeadlineForOrder) { dictatorWasPolled = true; return true; }); - auto other = RunCommand([&dictatorHasRun, &dictatorWasPolled] { + auto other = cmd::Run([&dictatorHasRun, &dictatorWasPolled] { EXPECT_TRUE(dictatorHasRun); EXPECT_TRUE(dictatorWasPolled); }); - auto group = std::move(dictator).DeadlineFor(std::move(other).ToPtr()); + auto group = std::move(dictator).DeadlineFor(std::move(other)); scheduler.Schedule(group); scheduler.Run(); @@ -293,12 +293,12 @@ TEST_F(CommandDecoratorTest, AlongWithOrder) { firstWasPolled = true; return true; }); - auto command2 = RunCommand([&firstHasRun, &firstWasPolled] { + auto command2 = cmd::Run([&firstHasRun, &firstWasPolled] { EXPECT_TRUE(firstHasRun); EXPECT_TRUE(firstWasPolled); }); - auto group = std::move(command1).AlongWith(std::move(command2).ToPtr()); + auto group = std::move(command1).AlongWith(std::move(command2)); scheduler.Schedule(group); scheduler.Run(); @@ -319,12 +319,12 @@ TEST_F(CommandDecoratorTest, RaceWithOrder) { firstWasPolled = true; return true; }); - auto command2 = RunCommand([&firstHasRun, &firstWasPolled] { + auto command2 = cmd::Run([&firstHasRun, &firstWasPolled] { EXPECT_TRUE(firstHasRun); EXPECT_TRUE(firstWasPolled); }); - auto group = std::move(command1).RaceWith(std::move(command2).ToPtr()); + auto group = std::move(command1).RaceWith(std::move(command2)); scheduler.Schedule(group); scheduler.Run(); @@ -339,7 +339,7 @@ TEST_F(CommandDecoratorTest, Unless) { bool hasRun = false; bool unlessCondition = true; - auto command = InstantCommand([&hasRun] { hasRun = true; }, {}) + auto command = cmd::RunOnce([&hasRun] { hasRun = true; }, {}) .Unless([&unlessCondition] { return unlessCondition; }); scheduler.Schedule(command); From 1d115a47ef153b64431117bf9c08bc34fd39c494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 27 Oct 2024 12:08:06 -0500 Subject: [PATCH 19/45] Do CommandDecoratorTest --- .../src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 85dd3dc5126..63025780f0a 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -361,8 +361,8 @@ TEST_F(CommandDecoratorTest, OnlyIf) { bool hasRun = false; bool onlyIfCondition = false; - auto command = InstantCommand([&hasRun] { hasRun = true; }, {}) - .OnlyIf([&onlyIfCondition] { return onlyIfCondition; }); + auto command = cmd::RunOnce([&hasRun] {hasRun = true;}, {}) + .OnlyIf([&onlyIfCondition] { return onlyIfCondition; }); scheduler.Schedule(command); scheduler.Run(); From a6898a9dbdf47be1c449efe119add23f8ad9e4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 27 Oct 2024 13:05:15 -0500 Subject: [PATCH 20/45] Do ConditionalCommandTest --- .../frc2/command/ConditionalCommandTest.cpp | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp index 7896a1aa326..25aefd6309b 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp @@ -57,32 +57,32 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) { TEST_F(ConditionalCommandTest, AllTrue) { CommandPtr command = - cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), + cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), + cmd::Run([] {}, {}).IgnoringDisable(true), [] { return true; }); EXPECT_EQ(true, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllFalse) { CommandPtr command = - cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), + cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), + cmd::Run([] {}, {}).IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, OneTrueOneFalse) { CommandPtr command = - cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), + cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), + cmd::Run([] {}, {}).IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { CommandPtr command = - cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), + cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), + cmd::Run([] {}, {}).IgnoringDisable(true), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } @@ -102,12 +102,8 @@ TEST_F(ConditionalCommandTest, AllCancelSelf) { TEST_F(ConditionalCommandTest, AllCancelIncoming) { CommandPtr command = cmd::Either( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming, command.get()->GetInterruptionBehavior()); @@ -115,12 +111,8 @@ TEST_F(ConditionalCommandTest, AllCancelIncoming) { TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { CommandPtr command = cmd::Either( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); @@ -128,12 +120,8 @@ TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { TEST_F(ConditionalCommandTest, OneCancelIncomingOneSelf) { CommandPtr command = cmd::Either( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); From 739b76cf2d24a5196830cd942821892059337b29 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Oct 2024 18:36:00 +0000 Subject: [PATCH 21/45] Formatting fixes --- .../cpp/frc2/command/CommandDecoratorTest.cpp | 20 ++++--- .../frc2/command/ConditionalCommandTest.cpp | 58 ++++++++++--------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 63025780f0a..e7e5971b4f8 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -8,9 +8,9 @@ #include #include "CommandTestBase.h" +#include "frc2/command/Commands.h" #include "frc2/command/FunctionalCommand.h" #include "frc2/command/InstantCommand.h" -#include "frc2/command/Commands.h" #include "frc2/command/RunCommand.h" #include "frc2/command/WaitUntilCommand.h" @@ -142,8 +142,7 @@ TEST_F(CommandDecoratorTest, BeforeStarting) { bool finished = false; - auto command = cmd::None().BeforeStarting( - [&finished] { finished = true; }); + auto command = cmd::None().BeforeStarting([&finished] { finished = true; }); scheduler.Schedule(command); @@ -163,8 +162,7 @@ TEST_F(CommandDecoratorTest, AndThenLambda) { bool finished = false; - auto command = - cmd::None().AndThen([&finished] { finished = true; }); + auto command = cmd::None().AndThen([&finished] { finished = true; }); scheduler.Schedule(command); @@ -342,8 +340,10 @@ TEST_F(CommandDecoratorTest, Unless) { bool hasRun = false; bool unlessCondition = true; - auto command = cmd::RunOnce([&hasRun] { hasRun = true; }, {}) - .Unless([&unlessCondition] { return unlessCondition; }); + auto command = + cmd::RunOnce([&hasRun] { hasRun = true; }, {}).Unless([&unlessCondition] { + return unlessCondition; + }); scheduler.Schedule(command); scheduler.Run(); @@ -361,8 +361,10 @@ TEST_F(CommandDecoratorTest, OnlyIf) { bool hasRun = false; bool onlyIfCondition = false; - auto command = cmd::RunOnce([&hasRun] {hasRun = true;}, {}) - .OnlyIf([&onlyIfCondition] { return onlyIfCondition; }); + auto command = + cmd::RunOnce([&hasRun] { hasRun = true; }, {}).OnlyIf([&onlyIfCondition] { + return onlyIfCondition; + }); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp index 25aefd6309b..90fb4adcf4e 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp @@ -56,34 +56,30 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) { } TEST_F(ConditionalCommandTest, AllTrue) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), - cmd::Run([] {}, {}).IgnoringDisable(true), - [] { return true; }); + CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), + cmd::Run([] {}, {}).IgnoringDisable(true), + [] { return true; }); EXPECT_EQ(true, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllFalse) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), - cmd::Run([] {}, {}).IgnoringDisable(false), - [] { return true; }); + CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), + cmd::Run([] {}, {}).IgnoringDisable(false), + [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, OneTrueOneFalse) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), - cmd::Run([] {}, {}).IgnoringDisable(false), - [] { return true; }); + CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), + cmd::Run([] {}, {}).IgnoringDisable(false), + [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), - cmd::Run([] {}, {}).IgnoringDisable(true), - [] { return true; }); + CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), + cmd::Run([] {}, {}).IgnoringDisable(true), + [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } @@ -101,28 +97,34 @@ TEST_F(ConditionalCommandTest, AllCancelSelf) { } TEST_F(ConditionalCommandTest, AllCancelIncoming) { - CommandPtr command = cmd::Either( - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - [] { return false; }); + CommandPtr command = + cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming, command.get()->GetInterruptionBehavior()); } TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { - CommandPtr command = cmd::Either( - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - [] { return false; }); + CommandPtr command = + cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); } TEST_F(ConditionalCommandTest, OneCancelIncomingOneSelf) { - CommandPtr command = cmd::Either( - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::Run([] {}, {}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - [] { return false; }); + CommandPtr command = + cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Run([] {}, {}).WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); } From 20b92501438e69f50b852d3776a373bd2c3681dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 6 Dec 2024 20:28:21 -0600 Subject: [PATCH 22/45] Do CommandDecoratorTest.cpp --- .../src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index e7e5971b4f8..709b38a2a4c 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -436,8 +436,8 @@ TEST_F(CommandDecoratorTest, HandleInterrupt) { } TEST_F(CommandDecoratorTest, WithName) { - InstantCommand command; + auto command = frc2::cmd::None(); std::string name{"Named"}; - CommandPtr named = std::move(command).WithName(name); + auto named = std::move(command).WithName(name); EXPECT_EQ(name, named.get()->GetName()); } From 4e1449153d0f7feb0187feb3bdec93f933253027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 6 Dec 2024 20:28:30 -0600 Subject: [PATCH 23/45] Do ParallelDeadlineGroupTest --- .../frc2/command/ParallelDeadlineGroupTest.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp index d36b97ad6c6..22aaa1a835a 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp @@ -124,17 +124,17 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - InstantCommand command1([] {}, {&requirement1, &requirement2}); - InstantCommand command2([] {}, {&requirement3}); - InstantCommand command3([] {}, {&requirement3, &requirement4}); + auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); + auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); - ParallelDeadlineGroup group(std::move(command1), std::move(command2)); + auto group = frc2::cmd::Deadline(std::move(command1), std::move(command2)); - scheduler.Schedule(&group); - scheduler.Schedule(&command3); + scheduler.Schedule(group); + scheduler.Schedule(command3); - EXPECT_TRUE(scheduler.IsScheduled(&command3)); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(command3)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } class TestableDeadlineCommand : public ParallelDeadlineGroup { From c2557a2cf58d8494d3d0d5e074855bda12a00725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 6 Dec 2024 20:41:33 -0600 Subject: [PATCH 24/45] Do ParallelCommandGroupTest & ParallelDeadlineGroupTest --- .../frc2/command/ParallelCommandGroupTest.cpp | 30 +++++++++---------- .../command/ParallelDeadlineGroupTest.cpp | 14 ++++----- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp index 21457d024cd..ab8866317a2 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp @@ -78,9 +78,9 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupInterrupt) { TEST_F(ParallelCommandGroupTest, ParallelGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - ParallelCommandGroup group((InstantCommand(), InstantCommand())); + auto group = frc2::cmd::Parallel(frc2::cmd::None(), frc2::cmd::None()); - EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(&group)); + EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } TEST_F(ParallelCommandGroupTest, ParallelGroupCopy) { @@ -88,15 +88,15 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupCopy) { bool finished = false; - WaitUntilCommand command([&finished] { return finished; }); + auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); - ParallelCommandGroup group(command); - scheduler.Schedule(&group); + auto group = frc2::cmd::Parallel(std::move(command)); + scheduler.Schedule(group); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(group)); finished = true; scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } TEST_F(ParallelCommandGroupTest, ParallelGroupRequirement) { @@ -107,17 +107,17 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - InstantCommand command1([] {}, {&requirement1, &requirement2}); - InstantCommand command2([] {}, {&requirement3}); - InstantCommand command3([] {}, {&requirement3, &requirement4}); + auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); + auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); - ParallelCommandGroup group(std::move(command1), std::move(command2)); + auto group = frc2::cmd::Parallel(std::move(command1), std::move(command2)); - scheduler.Schedule(&group); - scheduler.Schedule(&command3); + scheduler.Schedule(group); + scheduler.Schedule(command3); - EXPECT_TRUE(scheduler.IsScheduled(&command3)); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(command3)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } INSTANTIATE_MULTI_COMMAND_COMPOSITION_TEST_SUITE(ParallelCommandGroupTest, diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp index 22aaa1a835a..d7213eb8fcb 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp @@ -95,9 +95,9 @@ TEST_F(ParallelDeadlineGroupTest, SequentialGroupInterrupt) { TEST_F(ParallelDeadlineGroupTest, DeadlineGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - ParallelDeadlineGroup group{InstantCommand(), InstantCommand()}; + auto group = frc2::cmd::Deadline(frc2::cmd::None(), frc2::cmd::None()); - EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(&group)); + EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineCopy) { @@ -105,15 +105,15 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineCopy) { bool finished = false; - WaitUntilCommand command([&finished] { return finished; }); + auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); - ParallelDeadlineGroup group(command); - scheduler.Schedule(&group); + auto group = frc2::cmd::Deadline(std::move(command)); + scheduler.Schedule(group); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(group)); finished = true; scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineRequirement) { From c9bed3cb3fa8d11219ab9bfa0fe49d8f63635cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 6 Dec 2024 20:49:36 -0600 Subject: [PATCH 25/45] Do ParallelRaceGroupTest --- .../frc2/command/ParallelRaceGroupTest.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp index 032c3c1dd33..3e9260d5130 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp @@ -90,9 +90,9 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceInterrupt) { TEST_F(ParallelRaceGroupTest, ParallelRaceNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - ParallelRaceGroup group{InstantCommand(), InstantCommand()}; + auto group = frc2::cmd::Race(frc2::cmd::None(), frc2::cmd::None()); - EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(&group)); + EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } TEST_F(ParallelRaceGroupTest, ParallelRaceCopy) { @@ -119,17 +119,17 @@ TEST_F(ParallelRaceGroupTest, RaceGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - InstantCommand command1([] {}, {&requirement1, &requirement2}); - InstantCommand command2([] {}, {&requirement3}); - InstantCommand command3([] {}, {&requirement3, &requirement4}); + auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); + auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); - ParallelRaceGroup group(std::move(command1), std::move(command2)); + auto group = frc2::cmd::Race(std::move(command1), std::move(command2)); - scheduler.Schedule(&group); - scheduler.Schedule(&command3); + scheduler.Schedule(group); + scheduler.Schedule(command3); - EXPECT_TRUE(scheduler.IsScheduled(&command3)); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(command3)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } TEST_F(ParallelRaceGroupTest, ParallelRaceOnlyCallsEndOnce) { @@ -139,21 +139,21 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceOnlyCallsEndOnce) { bool finished2 = false; bool finished3 = false; - WaitUntilCommand command1([&finished1] { return finished1; }); - WaitUntilCommand command2([&finished2] { return finished2; }); - WaitUntilCommand command3([&finished3] { return finished3; }); + auto command1 = frc2::cmd::WaitUntil([&finished1] {return finished1;}); + auto command2 = frc2::cmd::WaitUntil([&finished2] {return finished2;}); + auto command3 = frc2::cmd::WaitUntil([&finished3] {return finished3;}); - SequentialCommandGroup group1(command1, command2); - ParallelRaceGroup group2(std::move(group1), command3); + auto group1 = frc2::cmd::Sequence(std::move(command1), std::move(command2)); + auto group2 = frc2::cmd::Race(std::move(group1), std::move(command3)); - scheduler.Schedule(&group2); + scheduler.Schedule(group2); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&group2)); + EXPECT_TRUE(scheduler.IsScheduled(group2)); finished1 = true; scheduler.Run(); finished2 = true; EXPECT_NO_FATAL_FAILURE(scheduler.Run()); - EXPECT_FALSE(scheduler.IsScheduled(&group2)); + EXPECT_FALSE(scheduler.IsScheduled(group2)); } TEST_F(ParallelRaceGroupTest, ParallelRaceScheduleTwice) { From deea284c4f27a10fbca99587873c3408e50b834d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Fri, 6 Dec 2024 20:53:39 -0600 Subject: [PATCH 26/45] Do CommandDecoratorTest.java --- .../command/CommandDecoratorTest.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index d6448da09ff..2926b3b90cb 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -256,11 +256,10 @@ void deadlineForOrderTest() { return true; }); Command other = - new RunCommand( - () -> - assertAll( - () -> assertTrue(dictatorHasRun.get()), - () -> assertTrue(dictatorWasPolled.get()))); + Commands.run(() -> + assertAll( + () -> assertTrue(dictatorHasRun.get()), + () -> assertTrue(dictatorWasPolled.get()))); Command group = dictator.deadlineFor(other); @@ -309,10 +308,9 @@ void alongWithOrderTest() { return true; }); Command command2 = - new RunCommand( - () -> - assertAll( - () -> assertTrue(firstHasRun.get()), () -> assertTrue(firstWasPolled.get()))); + Commands.run(() -> + assertAll( + () -> assertTrue(firstHasRun.get()), () -> assertTrue(firstWasPolled.get()))); Command group = command1.alongWith(command2); @@ -354,11 +352,10 @@ void raceWithOrderTest() { return true; }); Command command2 = - new RunCommand( - () -> { - assertTrue(firstHasRun.get()); - assertTrue(firstWasPolled.get()); - }); + Commands.run(() -> { + assertTrue(firstHasRun.get()); + assertTrue(firstWasPolled.get()); + }); Command group = command1.raceWith(command2); From c132d57b2372a60782563e553824c9efd4bec903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 14:03:23 -0600 Subject: [PATCH 27/45] Do PrintCommandTest --- .../src/test/native/cpp/frc2/command/PrintCommandTest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp index 02575a30ccc..c6436207a78 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp @@ -6,6 +6,7 @@ #include "CommandTestBase.h" #include "frc2/command/PrintCommand.h" +#include using namespace frc2; class PrintCommandTest : public CommandTestBase {}; @@ -13,15 +14,15 @@ class PrintCommandTest : public CommandTestBase {}; TEST_F(PrintCommandTest, PrintCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - PrintCommand command("Test!"); + auto command = frc2::cmd::Print("Test!"); testing::internal::CaptureStdout(); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); EXPECT_TRUE(std::regex_search(testing::internal::GetCapturedStdout(), std::regex("Test!"))); - EXPECT_FALSE(scheduler.IsScheduled(&command)); + EXPECT_FALSE(scheduler.IsScheduled(command)); } From c6febfe61ac528994ae1eb3435c46a2908cd5493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 14:20:07 -0600 Subject: [PATCH 28/45] Do RunCommandTest --- .../src/test/native/cpp/frc2/command/RunCommandTest.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp index 11d4adac76b..b31ce3d3c9f 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp @@ -4,6 +4,7 @@ #include "CommandTestBase.h" #include "frc2/command/RunCommand.h" +#include using namespace frc2; class RunCommandTest : public CommandTestBase {}; @@ -13,9 +14,9 @@ TEST_F(RunCommandTest, RunCommandSchedule) { int counter = 0; - RunCommand command([&counter] { counter++; }, {}); + auto command = frc2::cmd::Run([&counter] {counter++;}); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); scheduler.Run(); scheduler.Run(); From 59f3d693a5b2a111c201ad11608a917e56a3baf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 14:30:52 -0600 Subject: [PATCH 29/45] Do ProxyCommandTest --- .../test/native/cpp/frc2/command/ProxyCommandTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp index 81ec9d14326..6a9aa092b9c 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp @@ -9,6 +9,7 @@ #include "frc2/command/InstantCommand.h" #include "frc2/command/ProxyCommand.h" #include "frc2/command/WaitUntilCommand.h" +#include using namespace frc2; class ProxyCommandTest : public CommandTestBase {}; @@ -52,8 +53,8 @@ TEST_F(ProxyCommandTest, OwningCommandSchedule) { bool scheduled = false; - CommandPtr command = - InstantCommand([&scheduled] { scheduled = true; }).AsProxy(); + auto command = + frc2::cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); @@ -66,8 +67,8 @@ TEST_F(ProxyCommandTest, OwningCommandEnd) { bool finished = false; - CommandPtr command = - WaitUntilCommand([&finished] { return finished; }).AsProxy(); + auto command = + frc2::cmd::WaitUntil([&finished] { return finished; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); From 8bbbe9c41513688ae49703ed85819a14bc5ce53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 14:50:47 -0600 Subject: [PATCH 30/45] Do SchedulerTest --- .../native/cpp/frc2/command/SchedulerTest.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp index bc4756cccc3..d4e88e41f12 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp @@ -8,6 +8,7 @@ #include "frc2/command/InstantCommand.h" #include "frc2/command/RunCommand.h" #include "frc2/command/StartEndCommand.h" +#include using namespace frc2; class SchedulerTest : public CommandTestBase {}; @@ -15,7 +16,7 @@ class SchedulerTest : public CommandTestBase {}; TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { CommandScheduler scheduler = GetScheduler(); - InstantCommand command; + auto command = frc2::cmd::None(); int counter = 0; @@ -23,7 +24,7 @@ TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { scheduler.OnCommandExecute([&counter](const Command&) { counter++; }); scheduler.OnCommandFinish([&counter](const Command&) { counter++; }); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); EXPECT_EQ(counter, 3); @@ -32,15 +33,15 @@ TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { TEST_F(SchedulerTest, SchedulerLambdaInterrupt) { CommandScheduler scheduler = GetScheduler(); - RunCommand command([] {}, {}); + auto command = frc2::cmd::Idle(); int counter = 0; scheduler.OnCommandInterrupt([&counter](const Command&) { counter++; }); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); - scheduler.Cancel(&command); + scheduler.Cancel(command); EXPECT_EQ(counter, 1); } @@ -56,10 +57,10 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptNoCause) { counter++; }); - RunCommand command([] {}); + auto command = frc2::cmd::Idle(); - scheduler.Schedule(&command); - scheduler.Cancel(&command); + scheduler.Schedule(command); + scheduler.Cancel(command); EXPECT_EQ(1, counter); } @@ -142,8 +143,8 @@ TEST_F(SchedulerTest, UnregisterSubsystem) { TEST_F(SchedulerTest, SchedulerCancelAll) { CommandScheduler scheduler = GetScheduler(); - RunCommand command([] {}, {}); - RunCommand command2([] {}, {}); + auto command1 = frc2::cmd::Idle(); + auto command2 = frc2::cmd::Idle(); int counter = 0; @@ -153,8 +154,8 @@ TEST_F(SchedulerTest, SchedulerCancelAll) { EXPECT_FALSE(interruptor); }); - scheduler.Schedule(&command); - scheduler.Schedule(&command2); + scheduler.Schedule(command1); + scheduler.Schedule(command2); scheduler.Run(); scheduler.CancelAll(); @@ -166,10 +167,10 @@ TEST_F(SchedulerTest, ScheduleScheduledNoOp) { int counter = 0; - StartEndCommand command([&counter] { counter++; }, [] {}); + auto command = frc2::cmd::StartEnd([&counter] {counter++;}, [] {}); - scheduler.Schedule(&command); - scheduler.Schedule(&command); + scheduler.Schedule(command); + scheduler.Schedule(command); EXPECT_EQ(counter, 1); } From a4310320c2c5d2c852f8c0d583dced9dddf83e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 14:56:26 -0600 Subject: [PATCH 31/45] Do SchedulingRecursionTest --- .../cpp/frc2/command/SchedulingRecursionTest.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp index 52436b97ac6..2cfb0e51fae 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp @@ -11,6 +11,7 @@ #include "frc2/command/CommandHelper.h" #include "frc2/command/FunctionalCommand.h" #include "frc2/command/RunCommand.h" +#include using namespace frc2; @@ -55,14 +56,14 @@ TEST_P(SchedulingRecursionTest, CancelFromInitialize) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - RunCommand other{[&hasOtherRun] { hasOtherRun = true; }, {&requirement}}; + auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.Schedule(&selfCancels); scheduler.Run(); - scheduler.Schedule(&other); + scheduler.Schedule(other); EXPECT_FALSE(scheduler.IsScheduled(&selfCancels)); - EXPECT_TRUE(scheduler.IsScheduled(&other)); + EXPECT_TRUE(scheduler.IsScheduled(other)); EXPECT_EQ(1, counter); scheduler.Run(); EXPECT_TRUE(hasOtherRun); @@ -78,16 +79,16 @@ TEST_F(SchedulingRecursionTest, CancelFromInitializeAction) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - RunCommand other{[&hasOtherRun] { hasOtherRun = true; }, {&requirement}}; + auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.OnCommandInitialize([&scheduler, &selfCancels](const Command&) { scheduler.Cancel(&selfCancels); }); scheduler.Schedule(&selfCancels); scheduler.Run(); - scheduler.Schedule(&other); + scheduler.Schedule(other); EXPECT_FALSE(scheduler.IsScheduled(&selfCancels)); - EXPECT_TRUE(scheduler.IsScheduled(&other)); + EXPECT_TRUE(scheduler.IsScheduled(other)); EXPECT_EQ(1, counter); scheduler.Run(); EXPECT_TRUE(hasOtherRun); @@ -101,7 +102,7 @@ TEST_P(SchedulingRecursionTest, TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - RunCommand other{[&hasOtherRun] { hasOtherRun = true; }, {&requirement}}; + auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.SetDefaultCommand(&requirement, std::move(other)); scheduler.Schedule(&selfCancels); @@ -202,6 +203,7 @@ TEST_F(SchedulingRecursionTest, CancelFromEndLoop) { TEST_F(SchedulingRecursionTest, CancelFromEndLoopWhileInRunLoop) { CommandScheduler scheduler = GetScheduler(); int counter = 0; + EndCommand dCancelsAll([&](bool) { counter++; scheduler.CancelAll(); From 4a1abdf401bf8b3c3bb737c53634fcd1aefea0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:18:56 -0600 Subject: [PATCH 32/45] Do SequentialCommandGroupTest --- .../command/SequentialCommandGroupTest.cpp | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp index b8920c733f9..3ec3a8a65ba 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp @@ -105,15 +105,15 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupCopy) { bool finished = false; - WaitUntilCommand command([&finished] { return finished; }); + auto command = frc2::cmd::WaitUntil([&finished] { return finished; }); - SequentialCommandGroup group(command); - scheduler.Schedule(&group); + auto group = frc2::cmd::Sequence(std::move(command)); + scheduler.Schedule(group); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(group)); finished = true; scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } TEST_F(SequentialCommandGroupTest, SequentialGroupRequirement) { @@ -124,17 +124,20 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - InstantCommand command1([] {}, {&requirement1, &requirement2}); - InstantCommand command2([] {}, {&requirement3}); - InstantCommand command3([] {}, {&requirement3, &requirement4}); + auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); + // InstantCommand command1([] {}, {&requirement1, &requirement2}); + auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); + auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); - SequentialCommandGroup group(std::move(command1), std::move(command2)); + // SequentialCommandGroup group(std::move(command1), std::move(command2)); + auto group = frc2::cmd::Sequence( + make_vector(std::move(command1), std::move(command2))); - scheduler.Schedule(&group); - scheduler.Schedule(&command3); + scheduler.Schedule(group); + scheduler.Schedule(command3); - EXPECT_TRUE(scheduler.IsScheduled(&command3)); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(command3)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } INSTANTIATE_MULTI_COMMAND_COMPOSITION_TEST_SUITE(SequentialCommandGroupTest, From 51de3fe79c133d73b1fe78d782aafc1ca735dd94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:22:09 -0600 Subject: [PATCH 33/45] Do StartEndCommandTest --- .../test/native/cpp/frc2/command/StartEndCommandTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp index 53a2df2a2ce..3ed5e9c53a2 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp @@ -4,6 +4,7 @@ #include "CommandTestBase.h" #include "frc2/command/StartEndCommand.h" +#include using namespace frc2; class StartEndCommandTest : public CommandTestBase {}; @@ -13,13 +14,12 @@ TEST_F(StartEndCommandTest, StartEndCommandSchedule) { int counter = 0; - StartEndCommand command([&counter] { counter++; }, [&counter] { counter++; }, - {}); + auto command = frc2::cmd::StartEnd([&counter] {counter++;}, [&counter] {counter++;}); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); scheduler.Run(); - scheduler.Cancel(&command); + scheduler.Cancel(command); EXPECT_EQ(2, counter); } From d58f052a43e6ec178e237b1ad8efded139ab2d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:25:17 -0600 Subject: [PATCH 34/45] Do WaitCommandTest --- .../src/test/native/cpp/frc2/command/WaitCommandTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp index 30eea6b4331..5996381509a 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp @@ -7,6 +7,7 @@ #include "CommandTestBase.h" #include "frc2/command/WaitCommand.h" #include "frc2/command/WaitUntilCommand.h" +#include using namespace frc2; class WaitCommandTest : public CommandTestBase {}; @@ -16,14 +17,14 @@ TEST_F(WaitCommandTest, WaitCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - WaitCommand command(100_ms); + auto command = frc2::cmd::Wait(100_ms); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&command)); + EXPECT_TRUE(scheduler.IsScheduled(command)); frc::sim::StepTiming(110_ms); scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&command)); + EXPECT_FALSE(scheduler.IsScheduled(command)); frc::sim::ResumeTiming(); } From 6dfa97cdf361bed5e5ce764fbd9c07dacc44dc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:28:23 -0600 Subject: [PATCH 35/45] Do WaitUntilCommandTest --- .../native/cpp/frc2/command/WaitUntilCommandTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp index 01acc390e17..8b40dd17810 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp @@ -4,6 +4,7 @@ #include "CommandTestBase.h" #include "frc2/command/WaitUntilCommand.h" +#include using namespace frc2; class WaitUntilCommandTest : public CommandTestBase {}; @@ -13,12 +14,12 @@ TEST_F(WaitUntilCommandTest, WaitUntilCommandSchedule) { bool finished = false; - WaitUntilCommand command([&finished] { return finished; }); + auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&command)); + EXPECT_TRUE(scheduler.IsScheduled(command)); finished = true; scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&command)); + EXPECT_FALSE(scheduler.IsScheduled(command)); } From 3f44144d292854472f36f0b93a6436455294a442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:36:37 -0600 Subject: [PATCH 36/45] Shorten command factory uses --- .../cpp/frc2/command/CommandDecoratorTest.cpp | 2 +- .../cpp/frc2/command/InstantCommandTest.cpp | 7 ++++--- .../frc2/command/ParallelCommandGroupTest.cpp | 14 ++++++------- .../command/ParallelDeadlineGroupTest.cpp | 14 ++++++------- .../frc2/command/ParallelRaceGroupTest.cpp | 20 +++++++++---------- .../cpp/frc2/command/PrintCommandTest.cpp | 2 +- .../cpp/frc2/command/ProxyCommandTest.cpp | 4 ++-- .../cpp/frc2/command/RunCommandTest.cpp | 2 +- .../native/cpp/frc2/command/SchedulerTest.cpp | 12 +++++------ .../frc2/command/SchedulingRecursionTest.cpp | 6 +++--- .../command/SequentialCommandGroupTest.cpp | 12 +++++------ .../cpp/frc2/command/StartEndCommandTest.cpp | 2 +- .../cpp/frc2/command/WaitCommandTest.cpp | 2 +- .../cpp/frc2/command/WaitUntilCommandTest.cpp | 2 +- 14 files changed, 51 insertions(+), 50 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 709b38a2a4c..5a63f784560 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -436,7 +436,7 @@ TEST_F(CommandDecoratorTest, HandleInterrupt) { } TEST_F(CommandDecoratorTest, WithName) { - auto command = frc2::cmd::None(); + auto command = cmd::None(); std::string name{"Named"}; auto named = std::move(command).WithName(name); EXPECT_EQ(name, named.get()->GetName()); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp index 90eab852231..e55d6438afb 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp @@ -4,6 +4,7 @@ #include "CommandTestBase.h" #include "frc2/command/InstantCommand.h" +#include "frc2/command/Commands.h" using namespace frc2; class InstantCommandTest : public CommandTestBase {}; @@ -13,10 +14,10 @@ TEST_F(InstantCommandTest, InstantCommandSchedule) { int counter = 0; - InstantCommand command([&counter] { counter++; }, {}); + auto command = cmd::RunOnce([&counter] {counter++;}); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&command)); + EXPECT_FALSE(scheduler.IsScheduled(command)); EXPECT_EQ(counter, 1); } diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp index ab8866317a2..25b68adf573 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp @@ -78,7 +78,7 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupInterrupt) { TEST_F(ParallelCommandGroupTest, ParallelGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = frc2::cmd::Parallel(frc2::cmd::None(), frc2::cmd::None()); + auto group = cmd::Parallel(cmd::None(), cmd::None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -88,9 +88,9 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupCopy) { bool finished = false; - auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] {return finished;}); - auto group = frc2::cmd::Parallel(std::move(command)); + auto group = cmd::Parallel(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -107,11 +107,11 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); - auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = cmd::RunOnce([] {}, {&requirement3}); + auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - auto group = frc2::cmd::Parallel(std::move(command1), std::move(command2)); + auto group = cmd::Parallel(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp index d7213eb8fcb..c6fcc9ea572 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp @@ -95,7 +95,7 @@ TEST_F(ParallelDeadlineGroupTest, SequentialGroupInterrupt) { TEST_F(ParallelDeadlineGroupTest, DeadlineGroupNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = frc2::cmd::Deadline(frc2::cmd::None(), frc2::cmd::None()); + auto group = cmd::Deadline(cmd::None(), cmd::None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -105,9 +105,9 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineCopy) { bool finished = false; - auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] {return finished;}); - auto group = frc2::cmd::Deadline(std::move(command)); + auto group = cmd::Deadline(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -124,11 +124,11 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); - auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = cmd::RunOnce([] {}, {&requirement3}); + auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - auto group = frc2::cmd::Deadline(std::move(command1), std::move(command2)); + auto group = cmd::Deadline(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp index 3e9260d5130..0bca6195f43 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp @@ -90,7 +90,7 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceInterrupt) { TEST_F(ParallelRaceGroupTest, ParallelRaceNotScheduledCancel) { CommandScheduler scheduler = GetScheduler(); - auto group = frc2::cmd::Race(frc2::cmd::None(), frc2::cmd::None()); + auto group = cmd::Race(cmd::None(), cmd::None()); EXPECT_NO_FATAL_FAILURE(scheduler.Cancel(group)); } @@ -119,11 +119,11 @@ TEST_F(ParallelRaceGroupTest, RaceGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); - auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); - auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = cmd::RunOnce([] {}, {&requirement3}); + auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - auto group = frc2::cmd::Race(std::move(command1), std::move(command2)); + auto group = cmd::Race(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); @@ -139,12 +139,12 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceOnlyCallsEndOnce) { bool finished2 = false; bool finished3 = false; - auto command1 = frc2::cmd::WaitUntil([&finished1] {return finished1;}); - auto command2 = frc2::cmd::WaitUntil([&finished2] {return finished2;}); - auto command3 = frc2::cmd::WaitUntil([&finished3] {return finished3;}); + auto command1 = cmd::WaitUntil([&finished1] {return finished1;}); + auto command2 = cmd::WaitUntil([&finished2] {return finished2;}); + auto command3 = cmd::WaitUntil([&finished3] {return finished3;}); - auto group1 = frc2::cmd::Sequence(std::move(command1), std::move(command2)); - auto group2 = frc2::cmd::Race(std::move(group1), std::move(command3)); + auto group1 = cmd::Sequence(std::move(command1), std::move(command2)); + auto group2 = cmd::Race(std::move(group1), std::move(command3)); scheduler.Schedule(group2); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp index c6436207a78..24fd5472c83 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp @@ -14,7 +14,7 @@ class PrintCommandTest : public CommandTestBase {}; TEST_F(PrintCommandTest, PrintCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - auto command = frc2::cmd::Print("Test!"); + auto command = cmd::Print("Test!"); testing::internal::CaptureStdout(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp index 6a9aa092b9c..7b6a73d96aa 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp @@ -54,7 +54,7 @@ TEST_F(ProxyCommandTest, OwningCommandSchedule) { bool scheduled = false; auto command = - frc2::cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); + cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); @@ -68,7 +68,7 @@ TEST_F(ProxyCommandTest, OwningCommandEnd) { bool finished = false; auto command = - frc2::cmd::WaitUntil([&finished] { return finished; }).AsProxy(); + cmd::WaitUntil([&finished] { return finished; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp index b31ce3d3c9f..96dda359332 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp @@ -14,7 +14,7 @@ TEST_F(RunCommandTest, RunCommandSchedule) { int counter = 0; - auto command = frc2::cmd::Run([&counter] {counter++;}); + auto command = cmd::Run([&counter] {counter++;}); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp index d4e88e41f12..71513605567 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp @@ -16,7 +16,7 @@ class SchedulerTest : public CommandTestBase {}; TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { CommandScheduler scheduler = GetScheduler(); - auto command = frc2::cmd::None(); + auto command = cmd::None(); int counter = 0; @@ -33,7 +33,7 @@ TEST_F(SchedulerTest, SchedulerLambdaTestNoInterrupt) { TEST_F(SchedulerTest, SchedulerLambdaInterrupt) { CommandScheduler scheduler = GetScheduler(); - auto command = frc2::cmd::Idle(); + auto command = cmd::Idle(); int counter = 0; @@ -57,7 +57,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptNoCause) { counter++; }); - auto command = frc2::cmd::Idle(); + auto command = cmd::Idle(); scheduler.Schedule(command); scheduler.Cancel(command); @@ -143,8 +143,8 @@ TEST_F(SchedulerTest, UnregisterSubsystem) { TEST_F(SchedulerTest, SchedulerCancelAll) { CommandScheduler scheduler = GetScheduler(); - auto command1 = frc2::cmd::Idle(); - auto command2 = frc2::cmd::Idle(); + auto command1 = cmd::Idle(); + auto command2 = cmd::Idle(); int counter = 0; @@ -167,7 +167,7 @@ TEST_F(SchedulerTest, ScheduleScheduledNoOp) { int counter = 0; - auto command = frc2::cmd::StartEnd([&counter] {counter++;}, [] {}); + auto command = cmd::StartEnd([&counter] {counter++;}, [] {}); scheduler.Schedule(command); scheduler.Schedule(command); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp index 2cfb0e51fae..cd24bf0e90a 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp @@ -56,7 +56,7 @@ TEST_P(SchedulingRecursionTest, CancelFromInitialize) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.Schedule(&selfCancels); scheduler.Run(); @@ -79,7 +79,7 @@ TEST_F(SchedulingRecursionTest, CancelFromInitializeAction) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.OnCommandInitialize([&scheduler, &selfCancels](const Command&) { scheduler.Cancel(&selfCancels); }); @@ -102,7 +102,7 @@ TEST_P(SchedulingRecursionTest, TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = frc2::cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); scheduler.SetDefaultCommand(&requirement, std::move(other)); scheduler.Schedule(&selfCancels); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp index 3ec3a8a65ba..dd3b54fed36 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp @@ -105,9 +105,9 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupCopy) { bool finished = false; - auto command = frc2::cmd::WaitUntil([&finished] { return finished; }); + auto command = cmd::WaitUntil([&finished] { return finished; }); - auto group = frc2::cmd::Sequence(std::move(command)); + auto group = cmd::Sequence(std::move(command)); scheduler.Schedule(group); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(group)); @@ -124,13 +124,13 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - auto command1 = frc2::cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); // InstantCommand command1([] {}, {&requirement1, &requirement2}); - auto command2 = frc2::cmd::RunOnce([] {}, {&requirement3}); - auto command3 = frc2::cmd::RunOnce([] {}, {&requirement3, &requirement4}); + auto command2 = cmd::RunOnce([] {}, {&requirement3}); + auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); // SequentialCommandGroup group(std::move(command1), std::move(command2)); - auto group = frc2::cmd::Sequence( + auto group = cmd::Sequence( make_vector(std::move(command1), std::move(command2))); scheduler.Schedule(group); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp index 3ed5e9c53a2..5bc161e2327 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp @@ -14,7 +14,7 @@ TEST_F(StartEndCommandTest, StartEndCommandSchedule) { int counter = 0; - auto command = frc2::cmd::StartEnd([&counter] {counter++;}, [&counter] {counter++;}); + auto command = cmd::StartEnd([&counter] {counter++;}, [&counter] {counter++;}); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp index 5996381509a..ca5855c5d40 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp @@ -17,7 +17,7 @@ TEST_F(WaitCommandTest, WaitCommandSchedule) { CommandScheduler scheduler = GetScheduler(); - auto command = frc2::cmd::Wait(100_ms); + auto command = cmd::Wait(100_ms); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp index 8b40dd17810..86d09cd5244 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp @@ -14,7 +14,7 @@ TEST_F(WaitUntilCommandTest, WaitUntilCommandSchedule) { bool finished = false; - auto command = frc2::cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] {return finished;}); scheduler.Schedule(command); scheduler.Run(); From aa15a53715893867137b1f7d3c661b69d7391b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 7 Dec 2024 16:49:16 -0600 Subject: [PATCH 37/45] Do DefaultCommandTest --- .../cpp/frc2/command/DefaultCommandTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp index a024a2f1955..650db1f9152 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp @@ -6,6 +6,7 @@ #include "CommandTestBase.h" #include "frc2/command/RunCommand.h" +#include "frc2/command/Commands.h" using namespace frc2; class DefaultCommandTest : public CommandTestBase {}; @@ -15,9 +16,9 @@ TEST_F(DefaultCommandTest, DefaultCommandSchedule) { TestSubsystem subsystem; - RunCommand command1([] {}, {&subsystem}); + auto command = cmd::Run([] {}, {&subsystem}); - scheduler.SetDefaultCommand(&subsystem, std::move(command1)); + scheduler.SetDefaultCommand(&subsystem, std::move(command)); auto handle = scheduler.GetDefaultCommand(&subsystem); scheduler.Run(); @@ -29,18 +30,18 @@ TEST_F(DefaultCommandTest, DefaultCommandInterruptResume) { TestSubsystem subsystem; - RunCommand command1([] {}, {&subsystem}); - RunCommand command2([] {}, {&subsystem}); + auto command1 = cmd::Run([] {}, {&subsystem}); + auto command2 = cmd::Run([] {}, {&subsystem}); scheduler.SetDefaultCommand(&subsystem, std::move(command1)); auto handle = scheduler.GetDefaultCommand(&subsystem); scheduler.Run(); - scheduler.Schedule(&command2); + scheduler.Schedule(command2); - EXPECT_TRUE(scheduler.IsScheduled(&command2)); + EXPECT_TRUE(scheduler.IsScheduled(command2)); EXPECT_FALSE(scheduler.IsScheduled(handle)); - scheduler.Cancel(&command2); + scheduler.Cancel(command2); scheduler.Run(); EXPECT_TRUE(scheduler.IsScheduled(handle)); From cb29447f53ce6a7957686b8fcb764375a56644ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 8 Dec 2024 19:09:42 -0600 Subject: [PATCH 38/45] Resolve requested changed --- .../frc2/command/ConditionalCommandTest.cpp | 36 +++++++++---------- .../cpp/frc2/command/DefaultCommandTest.cpp | 6 ++-- .../command/SequentialCommandGroupTest.cpp | 5 +-- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp index 90fb4adcf4e..f7545f813f4 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp @@ -56,35 +56,35 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) { } TEST_F(ConditionalCommandTest, AllTrue) { - CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), - cmd::Run([] {}, {}).IgnoringDisable(true), + auto command = cmd::Either(cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(true, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllFalse) { - CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), - cmd::Run([] {}, {}).IgnoringDisable(false), + auto command = cmd::Either(cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, OneTrueOneFalse) { - CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(true), - cmd::Run([] {}, {}).IgnoringDisable(false), + auto command = cmd::Either(cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { - CommandPtr command = cmd::Either(cmd::Run([] {}, {}).IgnoringDisable(false), - cmd::Run([] {}, {}).IgnoringDisable(true), + auto command = cmd::Either(cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllCancelSelf) { - CommandPtr command = cmd::Either( + auto command = cmd::Either( cmd::WaitUntil([] { return false; }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), @@ -97,10 +97,10 @@ TEST_F(ConditionalCommandTest, AllCancelSelf) { } TEST_F(ConditionalCommandTest, AllCancelIncoming) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + auto command = + cmd::Either(cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelIncoming), - cmd::Run([] {}, {}).WithInterruptBehavior( + cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelIncoming), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming, @@ -108,10 +108,10 @@ TEST_F(ConditionalCommandTest, AllCancelIncoming) { } TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + auto command = + cmd::Either(cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelSelf), - cmd::Run([] {}, {}).WithInterruptBehavior( + cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelIncoming), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, @@ -119,10 +119,10 @@ TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) { } TEST_F(ConditionalCommandTest, OneCancelIncomingOneSelf) { - CommandPtr command = - cmd::Either(cmd::Run([] {}, {}).WithInterruptBehavior( + auto command = + cmd::Either(cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelIncoming), - cmd::Run([] {}, {}).WithInterruptBehavior( + cmd::Idle().WithInterruptBehavior( Command::InterruptionBehavior::kCancelSelf), [] { return false; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp index 650db1f9152..bcf2aed5b68 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp @@ -16,7 +16,7 @@ TEST_F(DefaultCommandTest, DefaultCommandSchedule) { TestSubsystem subsystem; - auto command = cmd::Run([] {}, {&subsystem}); + auto command = cmd::Idle({&subsystem}); scheduler.SetDefaultCommand(&subsystem, std::move(command)); auto handle = scheduler.GetDefaultCommand(&subsystem); @@ -30,8 +30,8 @@ TEST_F(DefaultCommandTest, DefaultCommandInterruptResume) { TestSubsystem subsystem; - auto command1 = cmd::Run([] {}, {&subsystem}); - auto command2 = cmd::Run([] {}, {&subsystem}); + auto command1 = cmd::Idle({&subsystem}); + auto command2 = cmd::Idle({&subsystem}); scheduler.SetDefaultCommand(&subsystem, std::move(command1)); auto handle = scheduler.GetDefaultCommand(&subsystem); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp index dd3b54fed36..3781928ea64 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SequentialCommandGroupTest.cpp @@ -125,13 +125,10 @@ TEST_F(SequentialCommandGroupTest, SequentialGroupRequirement) { TestSubsystem requirement4; auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); - // InstantCommand command1([] {}, {&requirement1, &requirement2}); auto command2 = cmd::RunOnce([] {}, {&requirement3}); auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - // SequentialCommandGroup group(std::move(command1), std::move(command2)); - auto group = cmd::Sequence( - make_vector(std::move(command1), std::move(command2))); + auto group = cmd::Sequence(std::move(command1), std::move(command2)); scheduler.Schedule(group); scheduler.Schedule(command3); From 6659f585716aaba4a8f53f3339b10d9987fcb7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Thu, 12 Dec 2024 16:11:02 -0600 Subject: [PATCH 39/45] Do SchedulerTest --- .../test/native/cpp/frc2/command/SchedulerTest.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp index 71513605567..d73f86ab736 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp @@ -71,7 +71,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCause) { int counter = 0; TestSubsystem subsystem{}; - RunCommand command([] {}, {&subsystem}); + auto command = frc2::cmd::Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); scheduler.OnCommandInterrupt( @@ -81,7 +81,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCause) { counter++; }); - scheduler.Schedule(&command); + scheduler.Schedule(command); scheduler.Schedule(&interruptor); EXPECT_EQ(1, counter); @@ -93,11 +93,10 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCauseInRunLoop) { int counter = 0; TestSubsystem subsystem{}; - RunCommand command([] {}, {&subsystem}); + auto command = frc2::cmd::Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); // This command will schedule interruptor in execute() inside the run loop - InstantCommand interruptorScheduler( - [&] { scheduler.Schedule(&interruptor); }); + auto interruptorScheduler = frc2::cmd::RunOnce([&] { scheduler.Schedule(&interruptor);}); scheduler.OnCommandInterrupt( [&](const Command&, const std::optional& cause) { @@ -106,8 +105,8 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCauseInRunLoop) { counter++; }); - scheduler.Schedule(&command); - scheduler.Schedule(&interruptorScheduler); + scheduler.Schedule(command); + scheduler.Schedule(interruptorScheduler); scheduler.Run(); From 17247a741bde3371bc2995b31475e7c7f61bfc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Thu, 12 Dec 2024 16:33:57 -0600 Subject: [PATCH 40/45] Do SchedulingRecusionTest --- .../native/cpp/frc2/command/SchedulerTest.cpp | 6 ++--- .../frc2/command/SchedulingRecursionTest.cpp | 27 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp index d73f86ab736..82f0e88fb67 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp @@ -71,7 +71,7 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCause) { int counter = 0; TestSubsystem subsystem{}; - auto command = frc2::cmd::Idle({&subsystem}); + auto command = cmd::Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); scheduler.OnCommandInterrupt( @@ -93,10 +93,10 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCauseInRunLoop) { int counter = 0; TestSubsystem subsystem{}; - auto command = frc2::cmd::Idle({&subsystem}); + auto command = cmd::Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); // This command will schedule interruptor in execute() inside the run loop - auto interruptorScheduler = frc2::cmd::RunOnce([&] { scheduler.Schedule(&interruptor);}); + auto interruptorScheduler = cmd::RunOnce([&] { scheduler.Schedule(&interruptor);}); scheduler.OnCommandInterrupt( [&](const Command&, const std::optional& cause) { diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp index cd24bf0e90a..75e4694a39b 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp @@ -272,7 +272,6 @@ TEST_P(SchedulingRecursionTest, ScheduleFromEndCancel) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - RunCommand other{[] {}, {&requirement}}; scheduler.Schedule(&selfCancels); EXPECT_NO_THROW({ scheduler.Cancel(&selfCancels); }); @@ -286,30 +285,30 @@ TEST_P(SchedulingRecursionTest, ScheduleFromEndInterrupt) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - RunCommand other{[] {}, {&requirement}}; + auto other = cmd::Idle({&requirement}); scheduler.Schedule(&selfCancels); - EXPECT_NO_THROW({ scheduler.Schedule(&other); }); + EXPECT_NO_THROW({ scheduler.Schedule(other); }); EXPECT_EQ(1, counter); EXPECT_FALSE(scheduler.IsScheduled(&selfCancels)); - EXPECT_TRUE(scheduler.IsScheduled(&other)); + EXPECT_TRUE(scheduler.IsScheduled(other)); } TEST_F(SchedulingRecursionTest, ScheduleFromEndInterruptAction) { CommandScheduler scheduler = GetScheduler(); int counter = 0; TestSubsystem requirement; - RunCommand selfCancels{[] {}, {&requirement}}; - RunCommand other{[] {}, {&requirement}}; + auto selfCancels = cmd::Idle({&requirement}); + auto other = cmd::Idle({&requirement}); scheduler.OnCommandInterrupt([&](const Command&) { counter++; - scheduler.Schedule(&other); + scheduler.Schedule(other); }); - scheduler.Schedule(&selfCancels); - EXPECT_NO_THROW({ scheduler.Schedule(&other); }); + scheduler.Schedule(selfCancels); + EXPECT_NO_THROW({ scheduler.Schedule(other); }); EXPECT_EQ(1, counter); - EXPECT_FALSE(scheduler.IsScheduled(&selfCancels)); - EXPECT_TRUE(scheduler.IsScheduled(&other)); + EXPECT_FALSE(scheduler.IsScheduled(selfCancels)); + EXPECT_TRUE(scheduler.IsScheduled(other)); } TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) { @@ -321,11 +320,11 @@ TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - RunCommand other{[] {}, {&requirement}}; + auto other = cmd::Idle({&requirement}); FunctionalCommand cancelDefaultCommand{[] {}, [] {}, [&](bool) { counter++; - scheduler.Schedule(&other); + scheduler.Schedule(other); }, [] { return false; }}; @@ -338,7 +337,7 @@ TEST_F(SchedulingRecursionTest, CancelDefaultCommandFromEnd) { }); EXPECT_EQ(2, counter); EXPECT_FALSE(scheduler.IsScheduled(&defaultCommand)); - EXPECT_TRUE(scheduler.IsScheduled(&other)); + EXPECT_TRUE(scheduler.IsScheduled(other)); } INSTANTIATE_TEST_SUITE_P( From 5addac03ebb594d2136ec3030461d3496e744a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Thu, 12 Dec 2024 16:41:37 -0600 Subject: [PATCH 41/45] Do SelectCommandTest --- .../cpp/frc2/command/SelectCommandTest.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp index dc882a0ed17..f53c20cd2a8 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp @@ -48,18 +48,17 @@ TEST_F(SelectCommandTest, SelectCommandRequirement) { TestSubsystem requirement3; TestSubsystem requirement4; - InstantCommand command1([] {}, {&requirement1, &requirement2}); - InstantCommand command2([] {}, {&requirement3}); - InstantCommand command3([] {}, {&requirement3, &requirement4}); + auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2}); + auto command2 = cmd::RunOnce([] {}, {&requirement3}); + auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - SelectCommand select([] { return 1; }, std::pair(1, std::move(command1)), - std::pair(2, std::move(command2))); + auto select = cmd::Select([] { return 1; }, std::pair(1, std::move(command1)), std::pair(2, std::move(command2))); - scheduler.Schedule(&select); - scheduler.Schedule(&command3); + scheduler.Schedule(select); + scheduler.Schedule(command3); - EXPECT_TRUE(scheduler.IsScheduled(&command3)); - EXPECT_FALSE(scheduler.IsScheduled(&select)); + EXPECT_TRUE(scheduler.IsScheduled(command3)); + EXPECT_FALSE(scheduler.IsScheduled(select)); } class TestableSelectCommand : public SelectCommand { From ed02b24fcd9218f7bee20bfb4a33a30ed950ac8e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:01:00 +0000 Subject: [PATCH 42/45] Formatting fixes --- .../command/CommandDecoratorTest.java | 25 +++++++++++-------- .../frc2/command/ConditionalCommandTest.cpp | 24 +++++++++--------- .../cpp/frc2/command/DefaultCommandTest.cpp | 2 +- .../cpp/frc2/command/InstantCommandTest.cpp | 4 +-- .../frc2/command/ParallelCommandGroupTest.cpp | 2 +- .../command/ParallelDeadlineGroupTest.cpp | 2 +- .../frc2/command/ParallelRaceGroupTest.cpp | 6 ++--- .../cpp/frc2/command/PrintCommandTest.cpp | 3 ++- .../cpp/frc2/command/ProxyCommandTest.cpp | 9 +++---- .../cpp/frc2/command/RunCommandTest.cpp | 5 ++-- .../native/cpp/frc2/command/SchedulerTest.cpp | 8 +++--- .../frc2/command/SchedulingRecursionTest.cpp | 11 ++++---- .../cpp/frc2/command/SelectCommandTest.cpp | 4 ++- .../cpp/frc2/command/StartEndCommandTest.cpp | 6 +++-- .../cpp/frc2/command/WaitCommandTest.cpp | 3 ++- .../cpp/frc2/command/WaitUntilCommandTest.cpp | 5 ++-- 16 files changed, 66 insertions(+), 53 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index 2926b3b90cb..d6eed1a5f65 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -256,10 +256,11 @@ void deadlineForOrderTest() { return true; }); Command other = - Commands.run(() -> - assertAll( - () -> assertTrue(dictatorHasRun.get()), - () -> assertTrue(dictatorWasPolled.get()))); + Commands.run( + () -> + assertAll( + () -> assertTrue(dictatorHasRun.get()), + () -> assertTrue(dictatorWasPolled.get()))); Command group = dictator.deadlineFor(other); @@ -308,9 +309,10 @@ void alongWithOrderTest() { return true; }); Command command2 = - Commands.run(() -> - assertAll( - () -> assertTrue(firstHasRun.get()), () -> assertTrue(firstWasPolled.get()))); + Commands.run( + () -> + assertAll( + () -> assertTrue(firstHasRun.get()), () -> assertTrue(firstWasPolled.get()))); Command group = command1.alongWith(command2); @@ -352,10 +354,11 @@ void raceWithOrderTest() { return true; }); Command command2 = - Commands.run(() -> { - assertTrue(firstHasRun.get()); - assertTrue(firstWasPolled.get()); - }); + Commands.run( + () -> { + assertTrue(firstHasRun.get()); + assertTrue(firstWasPolled.get()); + }); Command group = command1.raceWith(command2); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp index f7545f813f4..355faf0e475 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp @@ -56,30 +56,30 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) { } TEST_F(ConditionalCommandTest, AllTrue) { - auto command = cmd::Either(cmd::Idle().IgnoringDisable(true), - cmd::Idle().IgnoringDisable(true), - [] { return true; }); + auto command = + cmd::Either(cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(true, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, AllFalse) { - auto command = cmd::Either(cmd::Idle().IgnoringDisable(false), - cmd::Idle().IgnoringDisable(false), - [] { return true; }); + auto command = + cmd::Either(cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, OneTrueOneFalse) { - auto command = cmd::Either(cmd::Idle().IgnoringDisable(true), - cmd::Idle().IgnoringDisable(false), - [] { return true; }); + auto command = + cmd::Either(cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(false), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { - auto command = cmd::Either(cmd::Idle().IgnoringDisable(false), - cmd::Idle().IgnoringDisable(true), - [] { return true; }); + auto command = + cmd::Either(cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(true), [] { return true; }); EXPECT_EQ(false, command.get()->RunsWhenDisabled()); } diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp index bcf2aed5b68..25acb7f979f 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/DefaultCommandTest.cpp @@ -5,8 +5,8 @@ #include #include "CommandTestBase.h" -#include "frc2/command/RunCommand.h" #include "frc2/command/Commands.h" +#include "frc2/command/RunCommand.h" using namespace frc2; class DefaultCommandTest : public CommandTestBase {}; diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp index e55d6438afb..9b01721e45a 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/InstantCommandTest.cpp @@ -3,8 +3,8 @@ // the WPILib BSD license file in the root directory of this project. #include "CommandTestBase.h" -#include "frc2/command/InstantCommand.h" #include "frc2/command/Commands.h" +#include "frc2/command/InstantCommand.h" using namespace frc2; class InstantCommandTest : public CommandTestBase {}; @@ -14,7 +14,7 @@ TEST_F(InstantCommandTest, InstantCommandSchedule) { int counter = 0; - auto command = cmd::RunOnce([&counter] {counter++;}); + auto command = cmd::RunOnce([&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp index 25b68adf573..2f22a30a1e4 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelCommandGroupTest.cpp @@ -88,7 +88,7 @@ TEST_F(ParallelCommandGroupTest, ParallelGroupCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] { return finished; }); auto group = cmd::Parallel(std::move(command)); scheduler.Schedule(group); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp index c6fcc9ea572..9da797ccadf 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelDeadlineGroupTest.cpp @@ -105,7 +105,7 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineCopy) { bool finished = false; - auto command = cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] { return finished; }); auto group = cmd::Deadline(std::move(command)); scheduler.Schedule(group); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp index 0bca6195f43..5e8e06c0195 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp @@ -139,9 +139,9 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceOnlyCallsEndOnce) { bool finished2 = false; bool finished3 = false; - auto command1 = cmd::WaitUntil([&finished1] {return finished1;}); - auto command2 = cmd::WaitUntil([&finished2] {return finished2;}); - auto command3 = cmd::WaitUntil([&finished3] {return finished3;}); + auto command1 = cmd::WaitUntil([&finished1] { return finished1; }); + auto command2 = cmd::WaitUntil([&finished2] { return finished2; }); + auto command3 = cmd::WaitUntil([&finished3] { return finished3; }); auto group1 = cmd::Sequence(std::move(command1), std::move(command2)); auto group2 = cmd::Race(std::move(group1), std::move(command3)); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp index 24fd5472c83..77906f1e611 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/PrintCommandTest.cpp @@ -2,11 +2,12 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include #include "CommandTestBase.h" #include "frc2/command/PrintCommand.h" -#include using namespace frc2; class PrintCommandTest : public CommandTestBase {}; diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp index 7b6a73d96aa..7abc56fa11e 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ProxyCommandTest.cpp @@ -2,6 +2,8 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include #include "CommandTestBase.h" @@ -9,7 +11,6 @@ #include "frc2/command/InstantCommand.h" #include "frc2/command/ProxyCommand.h" #include "frc2/command/WaitUntilCommand.h" -#include using namespace frc2; class ProxyCommandTest : public CommandTestBase {}; @@ -53,8 +54,7 @@ TEST_F(ProxyCommandTest, OwningCommandSchedule) { bool scheduled = false; - auto command = - cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); + auto command = cmd::RunOnce([&scheduled] { scheduled = true; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); @@ -67,8 +67,7 @@ TEST_F(ProxyCommandTest, OwningCommandEnd) { bool finished = false; - auto command = - cmd::WaitUntil([&finished] { return finished; }).AsProxy(); + auto command = cmd::WaitUntil([&finished] { return finished; }).AsProxy(); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp index 96dda359332..07eaaf54c51 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/RunCommandTest.cpp @@ -2,9 +2,10 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include "CommandTestBase.h" #include "frc2/command/RunCommand.h" -#include using namespace frc2; class RunCommandTest : public CommandTestBase {}; @@ -14,7 +15,7 @@ TEST_F(RunCommandTest, RunCommandSchedule) { int counter = 0; - auto command = cmd::Run([&counter] {counter++;}); + auto command = cmd::Run([&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp index 82f0e88fb67..24ca0ecd5e1 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulerTest.cpp @@ -2,13 +2,14 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include #include "CommandTestBase.h" #include "frc2/command/InstantCommand.h" #include "frc2/command/RunCommand.h" #include "frc2/command/StartEndCommand.h" -#include using namespace frc2; class SchedulerTest : public CommandTestBase {}; @@ -96,7 +97,8 @@ TEST_F(SchedulerTest, SchedulerLambdaInterruptCauseInRunLoop) { auto command = cmd::Idle({&subsystem}); InstantCommand interruptor([] {}, {&subsystem}); // This command will schedule interruptor in execute() inside the run loop - auto interruptorScheduler = cmd::RunOnce([&] { scheduler.Schedule(&interruptor);}); + auto interruptorScheduler = + cmd::RunOnce([&] { scheduler.Schedule(&interruptor); }); scheduler.OnCommandInterrupt( [&](const Command&, const std::optional& cause) { @@ -166,7 +168,7 @@ TEST_F(SchedulerTest, ScheduleScheduledNoOp) { int counter = 0; - auto command = cmd::StartEnd([&counter] {counter++;}, [] {}); + auto command = cmd::StartEnd([&counter] { counter++; }, [] {}); scheduler.Schedule(command); scheduler.Schedule(command); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp index 75e4694a39b..19ba06fbb8f 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SchedulingRecursionTest.cpp @@ -2,6 +2,8 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include #include @@ -11,7 +13,6 @@ #include "frc2/command/CommandHelper.h" #include "frc2/command/FunctionalCommand.h" #include "frc2/command/RunCommand.h" -#include using namespace frc2; @@ -56,7 +57,7 @@ TEST_P(SchedulingRecursionTest, CancelFromInitialize) { TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.Schedule(&selfCancels); scheduler.Run(); @@ -79,7 +80,7 @@ TEST_F(SchedulingRecursionTest, CancelFromInitializeAction) { [&counter](bool) { counter++; }, [] { return false; }, {&requirement}}; - auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.OnCommandInitialize([&scheduler, &selfCancels](const Command&) { scheduler.Cancel(&selfCancels); }); @@ -102,7 +103,7 @@ TEST_P(SchedulingRecursionTest, TestSubsystem requirement; SelfCancellingCommand selfCancels{&scheduler, counter, &requirement, GetParam()}; - auto other = cmd::Run([&hasOtherRun] {hasOtherRun = true;}, {&requirement}); + auto other = cmd::Run([&hasOtherRun] { hasOtherRun = true; }, {&requirement}); scheduler.SetDefaultCommand(&requirement, std::move(other)); scheduler.Schedule(&selfCancels); @@ -203,7 +204,7 @@ TEST_F(SchedulingRecursionTest, CancelFromEndLoop) { TEST_F(SchedulingRecursionTest, CancelFromEndLoopWhileInRunLoop) { CommandScheduler scheduler = GetScheduler(); int counter = 0; - + EndCommand dCancelsAll([&](bool) { counter++; scheduler.CancelAll(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp index f53c20cd2a8..76d9e88c2c5 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/SelectCommandTest.cpp @@ -52,7 +52,9 @@ TEST_F(SelectCommandTest, SelectCommandRequirement) { auto command2 = cmd::RunOnce([] {}, {&requirement3}); auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4}); - auto select = cmd::Select([] { return 1; }, std::pair(1, std::move(command1)), std::pair(2, std::move(command2))); + auto select = + cmd::Select([] { return 1; }, std::pair(1, std::move(command1)), + std::pair(2, std::move(command2))); scheduler.Schedule(select); scheduler.Schedule(command3); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp index 5bc161e2327..744646d3719 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/StartEndCommandTest.cpp @@ -2,9 +2,10 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include "CommandTestBase.h" #include "frc2/command/StartEndCommand.h" -#include using namespace frc2; class StartEndCommandTest : public CommandTestBase {}; @@ -14,7 +15,8 @@ TEST_F(StartEndCommandTest, StartEndCommandSchedule) { int counter = 0; - auto command = cmd::StartEnd([&counter] {counter++;}, [&counter] {counter++;}); + auto command = + cmd::StartEnd([&counter] { counter++; }, [&counter] { counter++; }); scheduler.Schedule(command); scheduler.Run(); diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp index ca5855c5d40..a575e656130 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitCommandTest.cpp @@ -2,12 +2,13 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include #include "CommandTestBase.h" #include "frc2/command/WaitCommand.h" #include "frc2/command/WaitUntilCommand.h" -#include using namespace frc2; class WaitCommandTest : public CommandTestBase {}; diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp index 86d09cd5244..10b36fe5010 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/WaitUntilCommandTest.cpp @@ -2,9 +2,10 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. +#include + #include "CommandTestBase.h" #include "frc2/command/WaitUntilCommand.h" -#include using namespace frc2; class WaitUntilCommandTest : public CommandTestBase {}; @@ -14,7 +15,7 @@ TEST_F(WaitUntilCommandTest, WaitUntilCommandSchedule) { bool finished = false; - auto command = cmd::WaitUntil([&finished] {return finished;}); + auto command = cmd::WaitUntil([&finished] { return finished; }); scheduler.Schedule(command); scheduler.Run(); From b8e6479b4fc32cedde1a45f2d315227f5f9fe46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sun, 15 Dec 2024 11:21:58 -0600 Subject: [PATCH 43/45] Do ParallelRaceGroupTest.ParallelRaceCopy --- .../native/cpp/frc2/command/ParallelRaceGroupTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp index 5e8e06c0195..491ba75acb9 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ParallelRaceGroupTest.cpp @@ -100,15 +100,15 @@ TEST_F(ParallelRaceGroupTest, ParallelRaceCopy) { bool finished = false; - WaitUntilCommand command([&finished] { return finished; }); + auto command = cmd::WaitUntil([&finished] { return finished; }); - ParallelRaceGroup group(command); - scheduler.Schedule(&group); + auto group = cmd::Race(std::move(command)); + scheduler.Schedule(group); scheduler.Run(); - EXPECT_TRUE(scheduler.IsScheduled(&group)); + EXPECT_TRUE(scheduler.IsScheduled(group)); finished = true; scheduler.Run(); - EXPECT_FALSE(scheduler.IsScheduled(&group)); + EXPECT_FALSE(scheduler.IsScheduled(group)); } TEST_F(ParallelRaceGroupTest, RaceGroupRequirement) { From d6e87caee8febcb7840f8ccbe9b9768e66e744b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 28 Dec 2024 15:00:15 -0600 Subject: [PATCH 44/45] Do CompositionTestBase --- .../cpp/frc2/command/CompositionTestBase.h | 108 +++++++----------- 1 file changed, 44 insertions(+), 64 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CompositionTestBase.h b/wpilibNewCommands/src/test/native/cpp/frc2/command/CompositionTestBase.h index 58fbcc393b3..4a641180fb9 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CompositionTestBase.h +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CompositionTestBase.h @@ -23,15 +23,13 @@ TYPED_TEST_SUITE_P(SingleCompositionRunsWhenDisabledTest); TYPED_TEST_P(SingleCompositionRunsWhenDisabledTest, True) { auto param = true; - TypeParam command = TypeParam( - cmd::WaitUntil([] { return false; }).IgnoringDisable(param).Unwrap()); + TypeParam command = TypeParam(cmd::Idle().IgnoringDisable(param).Unwrap()); EXPECT_EQ(param, command.RunsWhenDisabled()); } TYPED_TEST_P(SingleCompositionRunsWhenDisabledTest, False) { auto param = false; - TypeParam command = TypeParam( - cmd::WaitUntil([] { return false; }).IgnoringDisable(param).Unwrap()); + TypeParam command = TypeParam(cmd::Idle().IgnoringDisable(param).Unwrap()); EXPECT_EQ(param, command.RunsWhenDisabled()); } @@ -44,17 +42,15 @@ TYPED_TEST_SUITE_P(SingleCompositionInterruptibilityTest); TYPED_TEST_P(SingleCompositionInterruptibilityTest, CancelSelf) { auto param = Command::InterruptionBehavior::kCancelSelf; - TypeParam command = TypeParam(cmd::WaitUntil([] { return false; }) - .WithInterruptBehavior(param) - .Unwrap()); + TypeParam command = + TypeParam(cmd::Idle().WithInterruptBehavior(param).Unwrap()); EXPECT_EQ(param, command.GetInterruptionBehavior()); } TYPED_TEST_P(SingleCompositionInterruptibilityTest, CancelIncoming) { auto param = Command::InterruptionBehavior::kCancelIncoming; - TypeParam command = TypeParam(cmd::WaitUntil([] { return false; }) - .WithInterruptBehavior(param) - .Unwrap()); + TypeParam command = + TypeParam(cmd::Idle().WithInterruptBehavior(param).Unwrap()); EXPECT_EQ(param, command.GetInterruptionBehavior()); } @@ -77,47 +73,43 @@ TYPED_TEST_SUITE_P(MultiCompositionRunsWhenDisabledTest); TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, OneTrue) { auto param = true; - TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(param)))); + TypeParam command = TypeParam(CommandPtr::UnwrapVector( + cmd::impl::MakeVector(cmd::Idle().IgnoringDisable(param)))); EXPECT_EQ(param, command.RunsWhenDisabled()); } TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, OneFalse) { auto param = false; - TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(param)))); + TypeParam command = TypeParam(CommandPtr::UnwrapVector( + cmd::impl::MakeVector(cmd::Idle().IgnoringDisable(param)))); EXPECT_EQ(param, command.RunsWhenDisabled()); } TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, AllTrue) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true)))); + cmd::Idle().IgnoringDisable(true), cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(true)))); EXPECT_EQ(true, command.RunsWhenDisabled()); } TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, AllFalse) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false)))); + cmd::Idle().IgnoringDisable(false), cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(false)))); EXPECT_EQ(false, command.RunsWhenDisabled()); } TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, TwoTrueOneFalse) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false)))); + cmd::Idle().IgnoringDisable(true), cmd::Idle().IgnoringDisable(true), + cmd::Idle().IgnoringDisable(false)))); EXPECT_EQ(false, command.RunsWhenDisabled()); } TYPED_TEST_P(MultiCompositionRunsWhenDisabledTest, TwoFalseOneTrue) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(false), - cmd::WaitUntil([] { return false; }).IgnoringDisable(true)))); + cmd::Idle().IgnoringDisable(false), cmd::Idle().IgnoringDisable(false), + cmd::Idle().IgnoringDisable(true)))); EXPECT_EQ(false, command.RunsWhenDisabled()); } @@ -132,61 +124,49 @@ class MultiCompositionInterruptibilityTest TYPED_TEST_SUITE_P(MultiCompositionInterruptibilityTest); TYPED_TEST_P(MultiCompositionInterruptibilityTest, AllCancelSelf) { - TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf)))); + TypeParam command = TypeParam(CommandPtr::UnwrapVector( + cmd::impl::MakeVector(cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf)))); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.GetInterruptionBehavior()); } TYPED_TEST_P(MultiCompositionInterruptibilityTest, AllCancelIncoming) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { return false; }) - .WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming)))); + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming)))); EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming, command.GetInterruptionBehavior()); } TYPED_TEST_P(MultiCompositionInterruptibilityTest, TwoCancelSelfOneIncoming) { TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { return false; }) - .WithInterruptBehavior( - Command::InterruptionBehavior::kCancelIncoming)))); + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming)))); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.GetInterruptionBehavior()); } TYPED_TEST_P(MultiCompositionInterruptibilityTest, TwoCancelIncomingOneSelf) { - TypeParam command = TypeParam(CommandPtr::UnwrapVector(cmd::impl::MakeVector( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf)))); + TypeParam command = TypeParam(CommandPtr::UnwrapVector( + cmd::impl::MakeVector(cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelIncoming), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf)))); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.GetInterruptionBehavior()); } From 52102661c59feaea6aa56880e02d144baa878ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8F=E3=82=A4=E3=83=89=E3=83=A9=E3=83=B3=E3=83=88?= Date: Sat, 28 Dec 2024 15:08:06 -0600 Subject: [PATCH 45/45] Do ConditionalCommandTest.AllCancelSelf --- .../cpp/frc2/command/ConditionalCommandTest.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp index 355faf0e475..fefb75d0e70 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/ConditionalCommandTest.cpp @@ -84,14 +84,11 @@ TEST_F(ConditionalCommandTest, TwoFalseOneTrue) { } TEST_F(ConditionalCommandTest, AllCancelSelf) { - auto command = cmd::Either( - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - cmd::WaitUntil([] { - return false; - }).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf), - [] { return true; }); + auto command = cmd::Either(cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + cmd::Idle().WithInterruptBehavior( + Command::InterruptionBehavior::kCancelSelf), + [] { return true; }); EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf, command.get()->GetInterruptionBehavior()); }