单元测试

pull/1/head
韩天峰 8 months ago
parent 765eb75869
commit 257cc2d796
  1. 18
      src/Php/Translator.php
  2. 17
      tests/core/lang/constants/PHP_INT_32bit.phpt
  3. 17
      tests/core/lang/constants/PHP_INT_64bit.phpt
  4. 3
      tests/core/lang/include_files/echo.inc
  5. 3
      tests/core/lang/include_files/eval.inc
  6. 3
      tests/core/lang/include_files/function.inc
  7. 82
      tests/core/lang/integer_literals/binary_32bit.phpt
  8. 82
      tests/core/lang/integer_literals/binary_64bit.phpt
  9. 82
      tests/core/lang/integer_literals/hexadecimal_32bit.phpt
  10. 83
      tests/core/lang/integer_literals/hexadecimal_64bit.phpt
  11. 118
      tests/core/lang/integer_literals/octal_32bit.phpt
  12. 133
      tests/core/lang/integer_literals/octal_64bit.phpt
  13. 19
      tests/core/lang/string/unicode_escape.phpt
  14. 11
      tests/core/lang/string/unicode_escape_incomplete.phpt

@ -21,6 +21,9 @@ class Translator extends \PhpAot\Core\Translator
const string TYPE_ARRAY = 'php::Array';
const string TYPE_STR = 'php::Str';
const string VALUE_NAN = 'std::numeric_limits<double>::quiet_NaN()';
const string VALUE_INF = 'std::numeric_limits<double>::infinity()';
private string $phpxDir = '~/workspace/projects/phpx';
protected string $lang = 'PHP';
private array $scope = [];
@ -231,9 +234,9 @@ class Translator extends \PhpAot\Core\Translator
case 'Expr_Variable':
return $expr->name;
case 'Scalar_Int':
return $expr->value;
return $expr->value . 'L';
case 'Scalar_Float':
return $expr->getAttribute('rawValue');
return $this->parseScalarFloat($expr);
case 'Scalar_String':
return '"' . $this->escapeString($expr->value) . '"';
case 'Expr_ConstFetch':
@ -1522,4 +1525,15 @@ class Translator extends \PhpAot\Core\Translator
}
return 'break;';
}
private function parseScalarFloat(Node $expr): string
{
if (is_nan($expr->value)) {
return self::VALUE_NAN;
} elseif (is_infinite($expr->value)) {
return $expr->value > 0 ? self::VALUE_INF : '-' . self::VALUE_INF;
} else {
return number_format($expr->value, 1, '.', '');
}
}
}

@ -0,0 +1,17 @@
--TEST--
Test PHP_INT_MIN, PHP_INT_MAX and PHP_INT_SIZE (32-bit)
--SKIPIF--
<?php if (PHP_INT_SIZE !== 4)
die("skip this test is for 32-bit platforms only"); ?>
--FILE--
<?php
var_dump(PHP_INT_MIN);
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_SIZE);
?>
--EXPECT--
int(-2147483648)
int(2147483647)
int(4)

@ -0,0 +1,17 @@
--TEST--
Test PHP_INT_MIN, PHP_INT_MAX and PHP_INT_SIZE (64-bit)
--SKIPIF--
<?php if (PHP_INT_SIZE !== 8)
die("skip this test is for 64-bit platforms only"); ?>
--FILE--
<?php
var_dump(PHP_INT_MIN);
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_SIZE);
?>
--EXPECT--
int(-9223372036854775808)
int(9223372036854775807)
int(8)

@ -0,0 +1,3 @@
<?php
echo "Included!\n";
?>

@ -0,0 +1,3 @@
<?php
eval("require_once 'echo.inc';");
?>

@ -0,0 +1,3 @@
<?php
function test() { require_once 'echo.inc'; }
?>

@ -0,0 +1,82 @@
--TEST--
Binary integer strings (32bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
/* Using binary prefix notation lowercase */
/* Maximum value representable as integer */
$binary = 0b1111111111111111111111111111111;
var_dump($binary);
var_dump(PHP_INT_MAX);
/* Floating number */
$binary = 0b111111010000101010101010101010111111111111111111111111111111111111111111111111111111;
var_dump($binary);
/* Integer */
$binary = 0b1010110;
var_dump($binary);
/* underscore separator */
$binary = 0b1_010110;
var_dump($binary);
/* Ignore leading 0 and _ */
$binary = 0b0_01010110;
var_dump($binary);
$binary = 0b0_1010110;
var_dump($binary);
/* Overflow to infinity */
$binary = 0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary);
/* Using binary prefix notation uppercase */
/* Maximum value representable as integer */
$binary = 0B1111111111111111111111111111111;
var_dump($binary);
var_dump(PHP_INT_MAX);
/* Floating number */
$binary = 0B111111010000101010101010101010111111111111111111111111111111111111111111111111111111;
var_dump($binary);
/* Integer */
$binary = 0B1010110;
var_dump($binary);
/* underscore separator */
$binary = 0B1_010110;
var_dump($binary);
/* Ignore leading 0 and _ */
$binary = 0B0_01010110;
var_dump($binary);
$binary = 0B0_1010110;
var_dump($binary);
/* Overflow to infinity */
$binary = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary);
?>
--EXPECT--
int(2147483647)
int(2147483647)
float(1.9119287772983036E+25)
int(86)
int(86)
int(86)
int(86)
float(INF)
int(2147483647)
int(2147483647)
float(1.9119287772983036E+25)
int(86)
int(86)
int(86)
int(86)
float(INF)

@ -0,0 +1,82 @@
--TEST--
Binary integer strings (64bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
/* Using binary prefix notation lowercase */
/* Maximum value representable as integer */
$binary = 0b111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary);
var_dump(PHP_INT_MAX);
/* Floating number */
$binary2 = 0b111111010000101010101010101010111111111111111111111111111111111111111111111111111111;
var_dump($binary2);
/* Integer */
$binary3 = 0b1010110;
var_dump($binary3);
/* underscore separator */
$binary = 0b1_010110;
var_dump($binary);
/* Ignore leading 0 and _ */
$binary = 0b0_01010110;
var_dump($binary);
$binary = 0b0_1010110;
var_dump($binary);
/* Overflow to infinity */
$binary4 = 0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary4);
/* Using binary prefix notation uppercase */
/* Maximum value representable as integer */
$binary = 0B111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary);
var_dump(PHP_INT_MAX);
/* Floating number */
$binary5 = 0B111111010000101010101010101010111111111111111111111111111111111111111111111111111111;
var_dump($binary5);
/* Integer */
$binary = 0B1010110;
var_dump($binary);
/* underscore separator */
$binary = 0B1_010110;
var_dump($binary);
/* Ignore leading 0 and _ */
$binary = 0B0_01010110;
var_dump($binary);
$binary = 0B0_1010110;
var_dump($binary);
/* Overflow to infinity */
$binary7 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111;
var_dump($binary7);
?>
--EXPECT--
int(9223372036854775807)
int(9223372036854775807)
float(1.9119287772983036E+25)
int(86)
int(86)
int(86)
int(86)
float(INF)
int(9223372036854775807)
int(9223372036854775807)
float(1.9119287772983036E+25)
int(86)
int(86)
int(86)
int(86)
float(INF)

@ -0,0 +1,82 @@
--TEST--
Hexadecimal integer strings (32bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
/* Using hexadecimal prefix notation lowercase */
/* Maximum value representable as integer */
$hex = 0x7FFFFFFF;
var_dump($hex);
var_dump(PHP_INT_MAX);
/* Floating number */
$hex = 0x45FFFABCDE0000000;
var_dump($hex);
/* Integer */
$hex = 0x1C;
var_dump($hex);
/* underscore separator */
$hex = 0x1_C;
var_dump($hex);
/* Ignore leading 0 and _ */
$hex = 0x0_01C;
var_dump($hex);
$hex = 0x0_1C;
var_dump($hex);
/* Overflow to infinity */
$hex = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
var_dump($hex);
/* Using hexadecimal prefix notation uppercase */
/* Maximum value representable as integer */
$hex = 0X7FFFFFFF;
var_dump($hex);
var_dump(PHP_INT_MAX);
/* Floating number */
$hex = 0X45FFFABCDE0000000;
var_dump($hex);
/* Integer */
$hex = 0X1C;
var_dump($hex);
/* underscore separator */
$hex = 0X1_C;
var_dump($hex);
/* Ignore leading 0 and _ */
$hex = 0X0_01C;
var_dump($hex);
$hex = 0X0_1C;
var_dump($hex);
/* Overflow to infinity */
$hex = 0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
var_dump($hex);
?>
--EXPECT--
int(2147483647)
int(2147483647)
float(8.070441274821732E+19)
int(28)
int(28)
int(28)
int(28)
float(INF)
int(2147483647)
int(2147483647)
float(8.070441274821732E+19)
int(28)
int(28)
int(28)
int(28)
float(INF)

@ -0,0 +1,83 @@
--TEST--
Hexadecimal integer strings (64bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
/* Using hexadecimal prefix notation lowercase */
/* Maximum value representable as integer */
$hex = 0x7FFFFFFFFFFFFFFF;
var_dump($hex);
var_dump(PHP_INT_MAX);
/* Floating number */
$hex2 = 0x45FFFABCDE0000000;
var_dump($hex2);
/* Integer */
$hex = 0x1C;
var_dump($hex);
/* underscore separator */
$hex = 0x1_C;
var_dump($hex);
/* Ignore leading 0 and _ */
$hex = 0x0_01C;
var_dump($hex);
$hex = 0x0_1C;
var_dump($hex);
/* Overflow to infinity */
$hex6 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
var_dump($hex6);
/* Using hexadecimal prefix notation uppercase */
/* Maximum value representable as integer */
$hex = 0X7FFFFFFFFFFFFFFF;
var_dump($hex);
var_dump(PHP_INT_MAX);
/* Floating number */
$hex11 = 0X45FFFABCDE0000000;
var_dump($hex11);
/* Integer */
$hex = 0X1C;
var_dump($hex);
/* underscore separator */
$hex = 0X1_C;
var_dump($hex);
/* Ignore leading 0 and _ */
$hex = 0X0_01C;
var_dump($hex);
$hex = 0X0_1C;
var_dump($hex);
/* Overflow to infinity */
$hex11 = 0XFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
var_dump($hex11);
?>
--EXPECT--
int(9223372036854775807)
int(9223372036854775807)
float(8.070441274821732E+19)
int(28)
int(28)
int(28)
int(28)
float(INF)
int(9223372036854775807)
int(9223372036854775807)
float(8.070441274821732E+19)
int(28)
int(28)
int(28)
int(28)
float(INF)

@ -0,0 +1,118 @@
--TEST--
Octal integer strings (32bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
?>
--FILE--
<?php
/* Using octal prefix notation lowercase */
/* Maximum value representable as integer */
$octal = 0o17777777777;
var_dump($octal);
var_dump(PHP_INT_MAX);
/* Floating number */
$octal = 0o45734321536435450000000000;
var_dump($octal);
/* Integer */
$octal = 0o16;
var_dump($octal);
/* underscore separator */
$octal = 0o1_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 0o0_016;
var_dump($octal);
$octal = 0o0_16;
var_dump($octal);
/* Overflow to infinity */
$octal = 0o77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal);
/* Using octal prefix notation uppercase */
/* Maximum value representable as integer */
$octal = 0O17777777777;
var_dump($octal);
var_dump(PHP_INT_MAX);
/* Floating number */
$octal = 0O45734321536435450000000000;
var_dump($octal);
/* Integer */
$octal = 0O16;
var_dump($octal);
/* underscore separator */
$octal = 0O1_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 0O0_016;
var_dump($octal);
$octal = 0O0_16;
var_dump($octal);
/* Overflow to infinity */
$octal = 0O77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal);
/* Using no dedicated prefix */
/* Maximum value representable as integer */
$octal = 017777777777;
var_dump($octal);
var_dump(PHP_INT_MAX);
/* Floating number */
$octal = 045734321536435450000000000;
var_dump($octal);
/* Integer */
$octal = 016;
var_dump($octal);
/* underscore separator */
$octal = 01_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 00_016;
var_dump($octal);
$octal = 0_16;
var_dump($octal);
/* Overflow to infinity */
$octal = 077777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal);
?>
--EXPECT--
int(2147483647)
int(2147483647)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)
int(2147483647)
int(2147483647)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)
int(2147483647)
int(2147483647)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)

@ -0,0 +1,133 @@
--TEST--
Octal integer strings (64bit)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
<?php
/* Using octal prefix notation lowercase */
/* Maximum value representable as integer */
$octal0 = 0o777777777777777777777;
var_dump($octal0);
var_dump(PHP_INT_MAX);
/* *technically* this should work but treat this as a degenerate case */
$octal2 = 0o1000000000000000000000;
var_dump($octal2);
/* Floating number */
$octal3 = 0o45734321536435450000000000;
var_dump($octal3);
/* Integer */
$octal = 0o16;
var_dump($octal);
/* underscore separator */
$octal = 0o1_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 0o0_016;
var_dump($octal);
$octal = 0o0_16;
var_dump($octal);
/* Overflow to infinity */
$octal8 = 0o77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal8);
/* Using octal prefix notation uppercase */
/* Maximum value representable as integer */
$octal9 = 0O777777777777777777777;
var_dump($octal9);
var_dump(PHP_INT_MAX);
/* *technically* this should work but treat this as a degenerate case */
$octal12 = 0O1000000000000000000000;
var_dump($octal12);
/* Floating number */
$octal11 = 0O45734321536435450000000000;
var_dump($octal11);
/* Integer */
$octal = 0O16;
var_dump($octal);
/* underscore separator */
$octal = 0O1_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 0O0_016;
var_dump($octal);
$octal = 0O0_16;
var_dump($octal);
/* Overflow to infinity */
$octal17 = 0O77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal17);
/* Using no dedicated prefix */
/* Maximum value representable as integer */
$octal22 = 0777777777777777777777;
var_dump($octal22);
var_dump(PHP_INT_MAX);
/* *technically* this should work but treat this as a degenerate case */
$octal23 = 01000000000000000000000;
var_dump($octal23);
/* Floating number */
$octal21 = 045734321536435450000000000;
var_dump($octal21);
/* Integer */
$octal = 016;
var_dump($octal);
/* underscore separator */
$octal = 01_6;
var_dump($octal);
/* Ignore leading 0 and _ */
$octal = 00_016;
var_dump($octal);
$octal = 0_16;
var_dump($octal);
/* Overflow to infinity */
$octal102 = 077777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777;
var_dump($octal102);
?>
--EXPECT--
int(9223372036854775807)
int(9223372036854775807)
float(9.223372036854776E+18)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)
int(9223372036854775807)
int(9223372036854775807)
float(9.223372036854776E+18)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)
int(9223372036854775807)
int(9223372036854775807)
float(9.223372036854776E+18)
float(1.7912166229916324E+23)
int(14)
int(14)
int(14)
int(14)
float(INF)

@ -0,0 +1,19 @@
--TEST--
Valid Unicode escape sequences
--FILE--
<?php
var_dump("\u{61}"); // ASCII "a" - characters below U+007F just encode as ASCII, as it's UTF-8
var_dump("\u{FF}"); // y with diaeresis
var_dump("\u{ff}"); // case-insensitive
var_dump("\u{2603}"); // Unicode snowman
var_dump("\u{1F602}"); // FACE WITH TEARS OF JOY emoji
var_dump("\u{0000001F602}"); // Leading zeroes permitted
?>
--EXPECT--
string(1) "a"
string(2) "ÿ"
string(2) "ÿ"
string(3) "☃"
string(4) "😂"
string(4) "😂"

@ -0,0 +1,11 @@
--TEST--
Invalid Unicode escape sequence: Incomplete
--SKIPIF--
<?php die("skip");?>
--FILE--
<?php
var_dump("\u{blah");
?>
--EXPECTF--
Parse error: Invalid UTF-8 codepoint escape sequence in %s on line %d
Loading…
Cancel
Save