function NumberTest::providerTestValidStep

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/NumberTest.php \Drupal\Tests\Component\Utility\NumberTest::providerTestValidStep()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/NumberTest.php \Drupal\Tests\Component\Utility\NumberTest::providerTestValidStep()
  3. 10 core/tests/Drupal/Tests/Component/Utility/NumberTest.php \Drupal\Tests\Component\Utility\NumberTest::providerTestValidStep()

Provides data for self::testNumberStep().

See also

\Drupal\Tests\Component\Utility\Number::testValidStep

File

core/tests/Drupal/Tests/Component/Utility/NumberTest.php, line 64

Class

NumberTest
Tests number manipulation utilities.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerTestValidStep() {
    return [
        // Value and step equal.
[
            10.3,
            10.3,
            TRUE,
        ],
        // Valid integer steps.
[
            42,
            21,
            TRUE,
        ],
        [
            42,
            3,
            TRUE,
        ],
        // Valid float steps.
[
            42,
            10.5,
            TRUE,
        ],
        [
            1,
            1 / 3,
            TRUE,
        ],
        [
            -100,
            100 / 7,
            TRUE,
        ],
        [
            1000,
            -10,
            TRUE,
        ],
        // Valid and very small float steps.
[
            1000.12345,
            1.0E-10,
            TRUE,
        ],
        [
            3.9999999999999,
            1.0E-13,
            TRUE,
        ],
        // Invalid integer steps.
[
            100,
            30,
            FALSE,
        ],
        [
            -10,
            4,
            FALSE,
        ],
        // Invalid float steps.
[
            6,
            5 / 7,
            FALSE,
        ],
        [
            10.3,
            10.25,
            FALSE,
        ],
        // Step mismatches very close to being valid.
[
            70 + 9.0E-7,
            10 + 9.0E-7,
            FALSE,
        ],
        [
            1936.5,
            3.0E-8,
            FALSE,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.