Source

pecl-ev / tests / 02_ev_construct_variation.phpt

Full commit
Ruslan Osmanov 5bd526d 




Ruslan Osmanov eb0ded1 




Ruslan Osmanov 5bd526d 



Ruslan Osmanov 27dbb77 
Ruslan Osmanov 5bd526d 













Ruslan Osmanov eb0ded1 


Ruslan Osmanov 5bd526d 
Ruslan Osmanov e15198b 


Ruslan Osmanov 5bd526d 

Ruslan Osmanov e15198b 
Ruslan Osmanov 5bd526d 

Ruslan Osmanov e8ed0da 
Ruslan Osmanov 5bd526d 

Ruslan Osmanov eb0ded1 
Ruslan Osmanov 5bd526d 





Ruslan Osmanov eb0ded1 

Ruslan Osmanov 5bd526d 
Ruslan Osmanov eb0ded1 
--TEST--
Check for constructor and factory methods' behaviour
--FILE--
<?php

class _A {
	function __destruct() { echo __METHOD__, PHP_EOL; }
}
$obj = new _A();

$prev_data = "prev_data";
$third_data = "new_data";

// Passing data var to constructor
$loop = new EvLoop(0, $prev_data);
var_dump($loop->data);

// data property read/write
$loop->data = "new data";
var_dump($loop->data);

// rewrite data property with string literal
$loop->data = "new new data";
var_dump($loop->data);

// rewrite data property with a variable
$loop->data = $third_data;
var_dump($loop->data);

$loop->data = &$obj;
var_dump($loop->data);

// Multiple attempts to create the default loop
$loop2 = EvLoop::defaultLoop();
$loop2 = EvLoop::defaultLoop();
$loop2 = EvLoop::defaultLoop();

// Overwriting previously created loop with the default loop
$loop = EvLoop::defaultLoop();

// Overwriting previously created default loop with new loop
$loop = new EvLoop(Ev::FLAG_AUTO);
// Should be NULL
var_dump($loop->data);
$obj = NULL;
?>
--EXPECTF--
string(9) "prev_data"
string(8) "new data"
string(12) "new new data"
string(8) "new_data"
object(_A)#1 (0) {
}
NULL
_A::__destruct