diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index c85c26f..0f548ad 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -41,7 +41,8 @@ protected function setUp() { public function testNumberDecimalField() { // Create a field with settings to validate. $field_name = Unicode::strtolower($this->randomMachineName()); - // precision=10 scale=4 => 6 numbers before the decimal point and 4 after. + // Having precision = 10 and scale = 4 means 6 numbers before the decimal + // point and 4 after. FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', @@ -80,10 +81,10 @@ public function testNumberDecimalField() { '-1234.5678', '19999.0000', '99999.0000', - // '909888.96', This fails! + '909888.96', '909888.99', '988999.0096', - // '988999.0099', This fails! + '988999.0099', ]; foreach ($valid_entries as $valid_entry) { diff --git a/core/tests/Drupal/Tests/Component/Utility/NumberTest.php b/core/tests/Drupal/Tests/Component/Utility/NumberTest.php index b494fac..ffe0b9f 100644 --- a/core/tests/Drupal/Tests/Component/Utility/NumberTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/NumberTest.php @@ -75,6 +75,7 @@ public static function providerTestValidStep() { [1000, -10, TRUE], // Valid and very small float steps. + [1936.5, 3e-8, TRUE], [1000.12345, 1e-10, TRUE], [3.9999999999999, 1e-13, TRUE], @@ -88,14 +89,13 @@ public static function providerTestValidStep() { // Step mismatches very close to being valid. [70 + 9e-7, 10 + 9e-7, FALSE], - [1936.5, 3e-8, FALSE], // These floats are valid, but might trigger FP math idiosyncrasies. // @see https://www.drupal.org/node/2230909 - [9990009888.96, 0.01, FALSE], + [9990009888.96, 0.01, TRUE], [9990009888.99, 0.01, TRUE], [990088999.0096, 0.0001, TRUE], - [990088999.0099, 0.0001, FALSE], + [990088999.0099, 0.0001, TRUE], ]; }