You are here

public function TwigConvertTest::providerTestFloatValues in Twig Tools 8

Provides test data for testFloatValue.

Return value

array An array of test data and their float equivalents.

File

tests/src/Unit/TwigConvertTest.php, line 128

Class

TwigConvertTest
Tests to ensure conversions filters work correctly.

Namespace

Drupal\Tests\twig_tools\Unit

Code

public function providerTestFloatValues() {
  return [
    [
      "{{ 42|float }}",
      '42',
    ],
    [
      "{{ 4.2|float }}",
      '4.2',
    ],
    [
      "{{ 0.42|float }}",
      '0.42',
    ],
    [
      "{{ 42000000.00|float }}",
      '42000000',
    ],
    [
      "{{ 42.0000000|float }}",
      '42',
    ],
    [
      "{{ -42.0000000|float }}",
      '-42',
    ],
    [
      "{{ +42.0000000|float }}",
      '42',
    ],
    [
      "{{ 42.00000001|float }}",
      '42.00000001',
    ],
    [
      "{{ 0000042.00000001|float }}",
      '42.00000001',
    ],
    [
      "{{ '42.00000001The'|float }}",
      '42.00000001',
    ],
    [
      "{{ 'The42.00000001'|float }}",
      '0',
    ],
    [
      "{{ '42'|float }}",
      '42',
    ],
    [
      "{{ '+42'|float }}",
      '42',
    ],
    [
      "{{ '-42'|float }}",
      '-42',
    ],
    [
      "{{ 042|float }}",
      '42',
    ],
    [
      "{{ '042'|float }}",
      '42',
    ],
    [
      "{{ 42000000|float }}",
      '42000000',
    ],
    [
      "{{ []|float }}",
      '0',
    ],
    [
      "{{ ['foo', 'bar']|float }}",
      '1',
    ],
    [
      "{{ FALSE|float }}",
      '0',
    ],
    [
      "{{ TRUE|float }}",
      '1',
    ],
    [
      "{{ NULL|float }}",
      '0',
    ],
    [
      "{{ 0|float }}",
      '0',
    ],
    [
      "{{ 1|float }}",
      '1',
    ],
    [
      "{{ 0.0|float }}",
      '0',
    ],
    [
      "{{ 1.0|float }}",
      '1',
    ],
  ];
}