Skip to content

Commit

Permalink
Delete test.php
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 8, 2023
1 parent d7ffc52 commit 682e318
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 90 deletions.
11 changes: 0 additions & 11 deletions test.php

This file was deleted.

163 changes: 84 additions & 79 deletions tests/PHPStan/Analyser/data/pow.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,9 @@ function ($a, $b): void {
assertType('(float|int)', $a ** $b);
};

/**
* @param numeric-string $numericS
*/
function doFoo(int $intA, int $intB, string $s, bool $bool, $numericS, float $float, array $arr): void {
assertType('(float|int)', pow($intA, $intB));
assertType('(float|int)', $intA ** $intB);

assertType('(float|int)', pow($intA, $numericS));
assertType('(float|int)', $intA ** $numericS);
assertType('(float|int)', $numericS ** $numericS);
assertType('(float|int)', pow($intA, "123"));
assertType('(float|int)', $intA ** "123");
assertType('int', pow($intA, 1));
assertType('int', $intA ** '1');

assertType('(float|int)', pow($intA, $s));
assertType('(float|int)', $intA ** $s);

assertType('(float|int)', pow($intA, $bool)); // could be int
assertType('(float|int)', $intA ** $bool); // could be int
assertType('int', pow($intA, true));
assertType('int', $intA ** true);

assertType('*ERROR*', pow($bool, $arr));
assertType('*ERROR*', pow($bool, []));

assertType('0|1', pow(null, "123"));
assertType('0|1', pow(null, $intA));
assertType('1', "123" ** null);
assertType('1', $intA ** null);
assertType('1.0', $float ** null);

assertType('*ERROR*', "123" ** $arr);
assertType('*ERROR*', "123" ** []);

assertType('625', pow('5', '4'));
assertType('625', '5' ** '4');

assertType('(float|int)', pow($intA, $bool)); // could be float
assertType('(float|int)', $intA ** $bool); // could be float
assertType('*ERROR*', $intA ** $arr);
assertType('*ERROR*', $intA ** []);

assertType('1', pow($intA, 0));
assertType('1', $intA ** '0');
assertType('1', $intA ** false);
assertType('int', $intA ** true);

assertType('1.0', pow($float, 0));
assertType('1.0', $float ** '0');
assertType('1.0', $float ** false);
assertType('float', pow($float, 1));
assertType('float', $float ** '1');
assertType('*ERROR*', $float ** $arr);
assertType('*ERROR*', $float ** []);

assertType('1.0', pow(1.1, 0));
assertType('1.0', 1.1 ** '0');
assertType('1.0', 1.1 ** false);
assertType('*ERROR*', 1.1 ** $arr);
assertType('*ERROR*', 1.1 ** []);

assertType('NAN', pow(-1,5.5));

assertType('1', pow($s, 0));
assertType('1', $s ** '0');
assertType('1', $s ** false);
assertType('(float|int)', pow($s, 1));
assertType('(float|int)', $s ** '1');
assertType('*ERROR*', $s ** $arr);
assertType('*ERROR*', $s ** []);

assertType('1', pow($bool, 0));
assertType('1', $bool ** '0');
assertType('1', $bool ** false);
assertType('(float|int)', pow($bool, 1));
assertType('(float|int)', $bool ** '1');
assertType('*ERROR*', $bool ** $arr);
assertType('*ERROR*', $bool ** []);
function (int $a, int $b): void {
assertType('(float|int)', pow($a, $b));
assertType('(float|int)', $a ** $b);
};

function (\GMP $a, \GMP $b): void {
Expand Down Expand Up @@ -172,3 +96,84 @@ function foo($positiveInt, $range2, $unionRange1, $unionRange2): void {
assertType('0|1', pow(null, $unionRange2));
assertType('0|1', null ** $unionRange2);
}

/**
* @param numeric-string $numericS
*/
function doFoo(int $intA, int $intB, string $s, bool $bool, $numericS, float $float, array $arr): void {
assertType('(float|int)', pow($intA, $intB));
assertType('(float|int)', $intA ** $intB);

assertType('(float|int)', pow($intA, $numericS));
assertType('(float|int)', $intA ** $numericS);
assertType('(float|int)', $numericS ** $numericS);
assertType('(float|int)', pow($intA, "123"));
assertType('(float|int)', $intA ** "123");
assertType('int', pow($intA, 1));
assertType('int', $intA ** '1');

assertType('(float|int)', pow($intA, $s));
assertType('(float|int)', $intA ** $s);

assertType('(float|int)', pow($intA, $bool)); // could be int
assertType('(float|int)', $intA ** $bool); // could be int
assertType('int', pow($intA, true));
assertType('int', $intA ** true);

assertType('*ERROR*', pow($bool, $arr));
assertType('*ERROR*', pow($bool, []));

assertType('0|1', pow(null, "123"));
assertType('0|1', pow(null, $intA));
assertType('1', "123" ** null);
assertType('1', $intA ** null);
assertType('1.0', $float ** null);

assertType('*ERROR*', "123" ** $arr);
assertType('*ERROR*', "123" ** []);

assertType('625', pow('5', '4'));
assertType('625', '5' ** '4');

assertType('(float|int)', pow($intA, $bool)); // could be float
assertType('(float|int)', $intA ** $bool); // could be float
assertType('*ERROR*', $intA ** $arr);
assertType('*ERROR*', $intA ** []);

assertType('1', pow($intA, 0));
assertType('1', $intA ** '0');
assertType('1', $intA ** false);
assertType('int', $intA ** true);

assertType('1.0', pow($float, 0));
assertType('1.0', $float ** '0');
assertType('1.0', $float ** false);
assertType('float', pow($float, 1));
assertType('float', $float ** '1');
assertType('*ERROR*', $float ** $arr);
assertType('*ERROR*', $float ** []);

assertType('1.0', pow(1.1, 0));
assertType('1.0', 1.1 ** '0');
assertType('1.0', 1.1 ** false);
assertType('*ERROR*', 1.1 ** $arr);
assertType('*ERROR*', 1.1 ** []);

assertType('NAN', pow(-1,5.5));

assertType('1', pow($s, 0));
assertType('1', $s ** '0');
assertType('1', $s ** false);
assertType('(float|int)', pow($s, 1));
assertType('(float|int)', $s ** '1');
assertType('*ERROR*', $s ** $arr);
assertType('*ERROR*', $s ** []);

assertType('1', pow($bool, 0));
assertType('1', $bool ** '0');
assertType('1', $bool ** false);
assertType('(float|int)', pow($bool, 1));
assertType('(float|int)', $bool ** '1');
assertType('*ERROR*', $bool ** $arr);
assertType('*ERROR*', $bool ** []);
};

0 comments on commit 682e318

Please sign in to comment.