Properly implement tests.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-07-01 20:07:06 +02:00
parent 376b9510a9
commit c94de60c29
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 11 additions and 9 deletions

View File

@ -54,14 +54,16 @@ class Base32 {
string $x = ''; string $x = '';
if(!in_array($input[$i], Base32::$map)) if(!in_array($input[$i], Base32::$map))
return false; return false;
for(int $j = 0; $j < 8; $j++) { for(int $j = 0; $j < 8; $j++) {
if(array_key_exists($input[$i + $j], Base32::$flippedMap)) {
$x += str_pad(base_convert(Base32::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); $x += str_pad(base_convert(Base32::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
} }
string[] $eightBits = str_split($x, 8); }
for(int $z = 0; $z < sizeof($eightBits); $z++) { string[] $eightBits = str_split($x, 8);
char $y; for(int $z = 0; $z < sizeof($eightBits); $z++) {
$binaryString += (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : ''; char $y;
} $binaryString += (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : '';
}
} }
return $binaryString; return $binaryString;
} }

View File

@ -22,7 +22,7 @@ class Brainfuck {
} }
private void interpret(string $command) { private void interpret(string $command) {
if(!$this->cells[$this->pointer]) { if(!array_key_exists($this->pointer, $this->cells)) {
$this->cells[$this->pointer] = 0; $this->cells[$this->pointer] = 0;
} }
switch ($command) { switch ($command) {

View File

@ -56,7 +56,7 @@ class Test {
goto cIterator; goto cIterator;
} }
cIteratorExit: { cIteratorExit: {
if($headers[++$pos]) { if(array_key_exists(++$pos, $headers)) {
goto hIterator; goto hIterator;
} }
} }

View File

@ -2,7 +2,7 @@ class Program {
private string cycle(char $a, char $b, int $i = 0) { private string cycle(char $a, char $b, int $i = 0) {
static bool[] $switches; static bool[] $switches;
if($switches[$i]) if(array_key_exists($i, $switches))
$switches[$i] = !$switches[$i]; $switches[$i] = !$switches[$i];
else else
!($switches[$i] = true); !($switches[$i] = true);