Skip to content

Commit

Permalink
money where the mouth is, make damn sure it works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moros1138 committed May 28, 2024
1 parent c69c8fb commit df0a418
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/Feature/ProcessCodeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Tests\Feature;

use PGEtinker\Compiler;
use Tests\TestCase;

class ProcessCodeTest extends TestCase
{

public function test_passthru_non_macros(): void
{
$compiler = new Compiler();

$code = "I can write anything wheeeee!#define OLC_PGE_APPLICATION\n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code == $compiler->getCode());

$code = "#define OLC_PGE_APPLICATIONYEAAAAAAA\n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code == $compiler->getCode());

$code = "I can write anything wheeeee!#define OLC_PGE_APPLICATIONYEAAAAAAA\n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code == $compiler->getCode());
}

public function test_valid_white_space_macros(): void
{
$compiler = new Compiler();

$code = "\t #define OLC_PGE_APPLICATION\n";
$compiler->setCode($code);
$compiler->processCode();
print_r($code);
print_r($compiler->getCode());
$this->assertTrue($code != $compiler->getCode());

$code = "# define OLC_PGE_APPLICATION\n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code != $compiler->getCode());

$code = "#define OLC_PGE_APPLICATION\n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code != $compiler->getCode());

$code = "#define OLC_PGE_APPLICATION \n";
$compiler->setCode($code);
$compiler->processCode();
$this->assertTrue($code != $compiler->getCode());
}

// public function test_process_code_fails_on_bad_macro(): void
// {
// $compiler = new Compiler();

// $code = "I can write anything wheeeee!#define OLC_PGE_APPLICATIONYEAAAAAAA\n";
// $compiler->setCode($code);
// $compiler->processCode();

// $this->assertTrue($code == $compiler->getCode());
// }

}

0 comments on commit df0a418

Please sign in to comment.