Browse Source

Properly implement tests.

tags/v0.1.0
Rafal Kupiec 1 year ago
parent
commit
c94de60c29
Signed by: belliash <belliash@codingworkshop.eu.org> GPG Key ID: 4E829243E0CFE6B4
4 changed files with 11 additions and 9 deletions
  1. +8
    -6
      tests/base32_test.aer
  2. +1
    -1
      tests/brainfuck_interpreter.aer
  3. +1
    -1
      tests/goto_statement.aer
  4. +1
    -1
      tests/static_var.aer

+ 8
- 6
tests/base32_test.aer View File

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


+ 1
- 1
tests/brainfuck_interpreter.aer View File

@@ -22,7 +22,7 @@ class Brainfuck {
}

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


+ 1
- 1
tests/goto_statement.aer View File

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


+ 1
- 1
tests/static_var.aer View File

@@ -2,7 +2,7 @@ class Program {

private string cycle(char $a, char $b, int $i = 0) {
static bool[] $switches;
if($switches[$i])
if(array_key_exists($i, $switches))
$switches[$i] = !$switches[$i];
else
!($switches[$i] = true);


Loading…
Cancel
Save