mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Enforce leading/trailing zeros in Java numeric constants (#2105)
Enforce that integer literals must not have leading zeros and that floating point literals must have leading or trailing zeros in Java.
This commit is contained in:
committed by
Peter Johnson
parent
fa85fbfc1c
commit
4ebae17123
@@ -137,7 +137,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
|
||||
// Delay until the interrupt is complete
|
||||
while (!function.m_interruptComplete.get()) {
|
||||
Timer.delay(.005);
|
||||
Timer.delay(0.005);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
setInterruptHigh();
|
||||
// Wait for the interrupt to complete before moving on
|
||||
while (!function.m_interruptComplete.getAndSet(false)) {
|
||||
Timer.delay(.005);
|
||||
Timer.delay(0.005);
|
||||
}
|
||||
}
|
||||
// Then
|
||||
@@ -194,7 +194,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
// Given
|
||||
getInterruptable().requestInterrupts();
|
||||
|
||||
final double synchronousDelay = synchronousTimeout / 2.;
|
||||
final double synchronousDelay = synchronousTimeout / 2.0;
|
||||
final Runnable runnable = () -> {
|
||||
Timer.delay(synchronousDelay);
|
||||
setInterruptLow();
|
||||
@@ -215,7 +215,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
// The test will not have timed out and:
|
||||
final double interruptRunTime = (stopTimeStamp - startTimeStamp) * 1e-6;
|
||||
assertEquals("The interrupt did not run for the expected amount of time (units in seconds)",
|
||||
synchronousDelay, interruptRunTime, .1);
|
||||
synchronousDelay, interruptRunTime, 0.1);
|
||||
}
|
||||
|
||||
@Test(timeout = (long) (synchronousTimeout * 1e3))
|
||||
@@ -236,7 +236,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
// Given
|
||||
getInterruptable().requestInterrupts();
|
||||
|
||||
final double synchronousDelay = synchronousTimeout / 2.;
|
||||
final double synchronousDelay = synchronousTimeout / 2.0;
|
||||
final Runnable runnable = () -> {
|
||||
Timer.delay(synchronousDelay);
|
||||
setInterruptLow();
|
||||
@@ -258,7 +258,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
getInterruptable().requestInterrupts();
|
||||
getInterruptable().setUpSourceEdge(false, true);
|
||||
|
||||
final double synchronousDelay = synchronousTimeout / 2.;
|
||||
final double synchronousDelay = synchronousTimeout / 2.0;
|
||||
final Runnable runnable = () -> {
|
||||
Timer.delay(synchronousDelay);
|
||||
setInterruptHigh();
|
||||
@@ -290,7 +290,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
setInterruptHigh();
|
||||
// Wait for the interrupt to complete before moving on
|
||||
while (!function.m_interruptComplete.getAndSet(false)) {
|
||||
Timer.delay(.005);
|
||||
Timer.delay(0.005);
|
||||
}
|
||||
}
|
||||
getInterruptable().disableInterrupts();
|
||||
@@ -300,7 +300,7 @@ public abstract class AbstractInterruptTest extends AbstractComsSetup {
|
||||
setInterruptLow();
|
||||
setInterruptHigh();
|
||||
// Just wait because the interrupt should not fire
|
||||
Timer.delay(.005);
|
||||
Timer.delay(0.005);
|
||||
}
|
||||
|
||||
// Then
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AnalogPotentiometerTest extends AbstractComsSetup {
|
||||
for (double i = 0.0; i < 360.0; i = i + 1.0) {
|
||||
m_potSource.setAngle(i);
|
||||
m_potSource.setMaxVoltage(RobotController.getVoltage5V());
|
||||
Timer.delay(.02);
|
||||
Timer.delay(0.02);
|
||||
assertEquals(i, m_pot.get(), DOUBLE_COMPARISON_DELTA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DIOCrossConnectTest extends AbstractInterruptTest {
|
||||
public void testSetHigh() {
|
||||
dio.getOutput().set(true);
|
||||
assertTrue("DIO Not High after no delay", dio.getInput().get());
|
||||
Timer.delay(.02);
|
||||
Timer.delay(0.02);
|
||||
assertTrue("DIO Not High after .05s delay", dio.getInput().get());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class DIOCrossConnectTest extends AbstractInterruptTest {
|
||||
public void testSetLow() {
|
||||
dio.getOutput().set(false);
|
||||
assertFalse("DIO Not Low after no delay", dio.getInput().get());
|
||||
Timer.delay(.02);
|
||||
Timer.delay(0.02);
|
||||
assertFalse("DIO Not Low after .05s delay", dio.getInput().get());
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GyroTest extends AbstractComsSetup {
|
||||
|
||||
public void testInitial(AnalogGyro gyro) {
|
||||
double angle = gyro.getAngle();
|
||||
assertEquals(errorMessage(angle, 0), 0, angle, .5);
|
||||
assertEquals(errorMessage(angle, 0), 0, angle, 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public class GyroTest extends AbstractComsSetup {
|
||||
// Set angle
|
||||
for (int i = 0; i < 5; i++) {
|
||||
m_tpcam.getPan().set(0);
|
||||
Timer.delay(.1);
|
||||
Timer.delay(0.1);
|
||||
}
|
||||
|
||||
Timer.delay(0.5);
|
||||
@@ -99,7 +99,7 @@ public class GyroTest extends AbstractComsSetup {
|
||||
gyro.reset();
|
||||
Timer.delay(0.25);
|
||||
double angle = gyro.getAngle();
|
||||
assertEquals(errorMessage(angle, 0), 0, angle, .5);
|
||||
assertEquals(errorMessage(angle, 0), 0, angle, 0.5);
|
||||
Timer.delay(5);
|
||||
angle = gyro.getAngle();
|
||||
assertEquals("After 5 seconds " + errorMessage(angle, 0), 0, angle, 2.0);
|
||||
|
||||
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
|
||||
public class MotorEncoderTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(MotorEncoderTest.class.getName());
|
||||
|
||||
private static final double MOTOR_RUNTIME = .25;
|
||||
private static final double MOTOR_RUNTIME = 0.25;
|
||||
|
||||
// private static final List<MotorEncoderFixture> pairs = new
|
||||
// ArrayList<MotorEncoderFixture>();
|
||||
@@ -108,7 +108,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
public void testIncrement() {
|
||||
int startValue = me.getEncoder().get();
|
||||
|
||||
me.getMotor().set(.2);
|
||||
me.getMotor().set(0.2);
|
||||
Timer.delay(MOTOR_RUNTIME);
|
||||
int currentValue = me.getEncoder().get();
|
||||
assertTrue(me.getType() + " Encoder not incremented: start: " + startValue + "; current: "
|
||||
@@ -124,7 +124,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
public void testDecrement() {
|
||||
int startValue = me.getEncoder().get();
|
||||
|
||||
me.getMotor().set(-.2);
|
||||
me.getMotor().set(-0.2);
|
||||
Timer.delay(MOTOR_RUNTIME);
|
||||
int currentValue = me.getEncoder().get();
|
||||
assertTrue(me.getType() + " Encoder not decremented: start: " + startValue + "; current: "
|
||||
@@ -139,7 +139,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
final int counter1Start = me.getCounters()[0].get();
|
||||
final int counter2Start = me.getCounters()[1].get();
|
||||
|
||||
me.getMotor().set(.75);
|
||||
me.getMotor().set(0.75);
|
||||
Timer.delay(MOTOR_RUNTIME);
|
||||
int counter1End = me.getCounters()[0].get();
|
||||
int counter2End = me.getCounters()[1].get();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -107,7 +107,7 @@ public class FakeCounterSource implements AutoCloseable {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_task = new EncoderThread(this);
|
||||
Timer.delay(.01);
|
||||
Timer.delay(0.01);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -131,7 +131,7 @@ public class FakeEncoderSource implements AutoCloseable {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_task = new QuadEncoderThread(this);
|
||||
Timer.delay(.01);
|
||||
Timer.delay(0.01);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -232,14 +232,14 @@ public abstract class AbstractComsSetup {
|
||||
// reached then continue to run this loop
|
||||
for (timeoutIndex = 0; timeoutIndex < (timeout * 100) && !correctState.getAsBoolean();
|
||||
timeoutIndex++) {
|
||||
Timer.delay(.01);
|
||||
Timer.delay(0.01);
|
||||
}
|
||||
if (correctState.getAsBoolean()) {
|
||||
simpleLog(level, message + " took " + (timeoutIndex * .01) + " seconds");
|
||||
simpleLog(level, message + " took " + (timeoutIndex * 0.01) + " seconds");
|
||||
} else {
|
||||
simpleLog(level, message + " timed out after " + (timeoutIndex * .01) + " seconds");
|
||||
simpleLog(level, message + " timed out after " + (timeoutIndex * 0.01) + " seconds");
|
||||
}
|
||||
return timeoutIndex * .01;
|
||||
return timeoutIndex * 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user