Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 9, 2022
1 parent 954dd2f commit 133e020
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/PhpParser/Node/Scalar/DNumber.php
Expand Up @@ -10,7 +10,7 @@ class DNumber extends Scalar
public $value;

/** @var float|string */
private $rawValue;
public $rawValue;

/**
* Constructs a float number scalar node.
Expand Down
27 changes: 27 additions & 0 deletions test/PhpParser/Node/Scalar/DNumberTest.php
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);

namespace PhpParser\Node\Scalar;

use PhpParser\Node\Stmt\Echo_;
use PhpParser\ParserFactory;

class DNumberTest extends \PHPUnit\Framework\TestCase
{
public function testRawValue()
{
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
$nodes = $parser->parse('<?php echo 1_234.56;');

$echo = $nodes[0];
$this->assertInstanceOf(Echo_::class, $echo);

/** @var Echo_ $echo */
$lLumber = $echo->exprs[0];
$this->assertInstanceOf(DNumber::class, $lLumber);

/** @var DNumber $dnumber */
$this->assertSame(1234.56, $lLumber->value);
$this->assertSame('1_234.56', $lLumber->rawValue);
}
}
4 changes: 3 additions & 1 deletion test/PhpParser/NodeAbstractTest.php
Expand Up @@ -271,6 +271,7 @@ function functionName(&$a = 0, $b = 1.0) {
"default": {
"nodeType": "Scalar_DNumber",
"value": 1,
"rawValue": "1.0",
"attributes": {
"startLine": 4,
"endLine": 4
Expand Down Expand Up @@ -428,7 +429,8 @@ function functionName(&$a = 0, $b = 1.0) {
"startLine": 4,
"endLine": 4
},
"value": 1
"value": 1,
"value": "1.0"
},
"flags": 0,
"attrGroups": []
Expand Down

0 comments on commit 133e020

Please sign in to comment.