diff --git a/tests/load_module.aer b/tests/load_module.aer new file mode 100644 index 0000000..e86be05 --- /dev/null +++ b/tests/load_module.aer @@ -0,0 +1,9 @@ +final class Main { + function __construct() { + var_dump(function_exists('dummy_function')); + var_dump(import('dummy')); + var_dump(function_exists('dummy_function')); + } +} + +new Main(); diff --git a/tests/load_module.exp b/tests/load_module.exp new file mode 100644 index 0000000..b551b69 --- /dev/null +++ b/tests/load_module.exp @@ -0,0 +1,3 @@ +bool(FALSE) +bool(TRUE) +bool(TRUE) diff --git a/tests/singleton_test.aer b/tests/singleton_test.aer new file mode 100644 index 0000000..3c9da40 --- /dev/null +++ b/tests/singleton_test.aer @@ -0,0 +1,34 @@ +final class Test { + private $value; + + private function __construct() { + } + + /* This is singleton */ + public function getInstance() { + static $instance; + if(!$instance) { + $instance = new Test(); + } + return $instance; + } + + public function get() { + return $this->value; + } + + public function set($value = 0) { + $this->value = $value; + } +} + +final class Main { + public function __construct() { + $testA = Test::getInstance(); + $testA->set(5); + $testB = Test::getInstance(); + var_dump($testB->get()); + } +} /* class */ + +new Main(); diff --git a/tests/singleton_test.exp b/tests/singleton_test.exp new file mode 100644 index 0000000..a3b0315 --- /dev/null +++ b/tests/singleton_test.exp @@ -0,0 +1 @@ +int(5)