-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from m3m0r7/fix-printing-methods
Fix printing methods
- Loading branch information
Showing
8 changed files
with
191 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\RubyVM\Version\RubyVM\Call\Method; | ||
|
||
use RubyVM\VM\Core\Runtime\Executor\ExecutedStatus; | ||
use Tests\RubyVM\Helper\TestApplication; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
class PrintTest extends TestApplication | ||
{ | ||
public function testPrint(): void | ||
{ | ||
$rubyVMManager = $this->createRubyVMFromCode( | ||
<<< '_' | ||
print "Hello World!" | ||
print "\n" | ||
print "Hello World!".chars | ||
print "\n" | ||
print [1, 2, 3, 4, 5, 6] | ||
print "\n" | ||
print true | ||
print "\n" | ||
print false | ||
print "\n" | ||
print nil | ||
print "\n" | ||
print({ key1: "Hello!", key2: "World!"}) | ||
_, | ||
); | ||
|
||
$executor = $rubyVMManager | ||
->rubyVM | ||
->disassemble(); | ||
|
||
$this->assertSame(ExecutedStatus::SUCCESS, $executor->execute()->executedStatus); | ||
$this->assertSame(<<<'_' | ||
Hello World! | ||
["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d", "!"] | ||
[1, 2, 3, 4, 5, 6] | ||
true | ||
false | ||
{:key1=>"Hello!", :key2=>"World!"} | ||
_, $rubyVMManager->stdOut->readAll()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\RubyVM\Version\RubyVM\Call\Method; | ||
|
||
use RubyVM\VM\Core\Runtime\Executor\ExecutedStatus; | ||
use Tests\RubyVM\Helper\TestApplication; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
class PutsTest extends TestApplication | ||
{ | ||
public function testPuts(): void | ||
{ | ||
$rubyVMManager = $this->createRubyVMFromCode( | ||
<<< '_' | ||
puts "Hello World!" | ||
puts "Hello World!".chars | ||
puts [1, 2, 3, 4, 5, 6] | ||
puts true | ||
puts false | ||
puts nil | ||
puts({ key1: "Hello!", key2: "World!"}) | ||
_, | ||
); | ||
|
||
$executor = $rubyVMManager | ||
->rubyVM | ||
->disassemble(); | ||
|
||
// NOTE: The IDE will be deleted one space, here is hack add one space. | ||
$space = ' '; | ||
$this->assertSame(ExecutedStatus::SUCCESS, $executor->execute()->executedStatus); | ||
$this->assertSame(<<<_ | ||
Hello World! | ||
H | ||
e | ||
l | ||
l | ||
o | ||
{$space} | ||
W | ||
o | ||
r | ||
l | ||
d | ||
! | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
true | ||
false | ||
{:key1=>"Hello!", :key2=>"World!"} | ||
_, $rubyVMManager->stdOut->readAll()); | ||
} | ||
} |