parent
3252f54615
commit
5d9ccf9c65
9
tests/load_module.aer
Normal file
9
tests/load_module.aer
Normal file
@ -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();
|
3
tests/load_module.exp
Normal file
3
tests/load_module.exp
Normal file
@ -0,0 +1,3 @@
|
||||
bool(FALSE)
|
||||
bool(TRUE)
|
||||
bool(TRUE)
|
34
tests/singleton_test.aer
Normal file
34
tests/singleton_test.aer
Normal file
@ -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();
|
1
tests/singleton_test.exp
Normal file
1
tests/singleton_test.exp
Normal file
@ -0,0 +1 @@
|
||||
int(5)
|
Loading…
Reference in New Issue
Block a user