[enhancement] 支持Float类型

This commit is contained in:
VampireAchao 2023-03-14 11:06:28 +08:00
parent 4db9c44d18
commit 4ccb44ee26
2 changed files with 5 additions and 1 deletions

View File

@ -18,7 +18,7 @@ public class BooleanUtil {
/** 表示为假的字符串 */
private static final Set<String> FALSE_SET = SetUtil.of("false", "no", "n", "f", "0", "off", "", "", "", "", "×");
/** js中表示假值Falsy的部分值 false、0、-0、0n、""、null、undefined 和 NaN */
public static final Set<Object> FALSY_SET = SetUtil.of(false, 0, -0, 0L, 0.0D, -0.0D, "", null);
public static final Set<Object> FALSY_SET = SetUtil.of(false, 0, -0, 0L, 0.0D, -0.0D, 0.0F, -0.0F, "", null);
/**
* 取相反值

View File

@ -105,6 +105,9 @@ public class BooleanUtilTest {
Assert.assertTrue(BooleanUtil.isJsFalsy(0.0D));
Assert.assertTrue(BooleanUtil.isJsFalsy(0.00D));
Assert.assertTrue(BooleanUtil.isJsFalsy(-0.00D));
Assert.assertTrue(BooleanUtil.isJsFalsy(0.0F));
Assert.assertTrue(BooleanUtil.isJsFalsy(0.00F));
Assert.assertTrue(BooleanUtil.isJsFalsy(-0.00F));
Assert.assertTrue(BooleanUtil.isJsFalsy(""));
Assert.assertTrue(BooleanUtil.isJsFalsy(null));
}
@ -120,5 +123,6 @@ public class BooleanUtilTest {
Assert.assertTrue(BooleanUtil.isJsTruthy(1L));
Assert.assertTrue(BooleanUtil.isJsTruthy(0.1D));
Assert.assertTrue(BooleanUtil.isJsTruthy(-0.01D));
Assert.assertTrue(BooleanUtil.isJsTruthy(-0.01F));
}
}