cvs: pecl /operator/tests binary_assign.phpt binary_assign_objdim.phpt incdec_obj.phpt
| From: | Sara Golemon | Date: | Thu, 19 Jan 2006 03:38:34 +0000 |
| Subject: | cvs: pecl /operator/tests binary_assign.phpt binary_assign_objdim.phpt incdec_obj.phpt | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-4986@lists.php.net to get a copy of this message | ||
pollita Thu Jan 19 03:38:34 2006 UTC
Added files:
/pecl/operator/tests binary_assign.phpt binary_assign_objdim.phpt
incdec_obj.phpt
Log:
Additional tests
http://cvs.php.net/viewcvs.cgi/pecl/operator/tests/binary_assign.phpt?view=markup&rev=1.1
Index: pecl/operator/tests/binary_assign.phpt
+++ pecl/operator/tests/binary_assign.phpt
--TEST--
Basic binary assign ops
--SKIPIF--
<?php if(!extension_loaded("operator")) print "skip"; ?>
--FILE--
<?php
class foo {
private $value;
function __assign_add($val) {
return $this->value += $val;
}
function __assign_sub($val) {
return $this->value -= $val;
}
function __assign_mul($val) {
return $this->value *= $val;
}
function __assign_div($val) {
return $this->value /= $val;
}
function __assign_mod($val) {
return $this->value %= $val;
}
function __assign_sl($val) {
return $this->value <<= $val;
}
function __assign_sr($val) {
return $this->value >>= $val;
}
function __assign_concat($val) {
return $this->value .= $val;
}
function __assign_bw_or($val) {
return $this->value |= $val;
}
function __assign_bw_and($val) {
return $this->value &= $val;
}
function __assign_bw_xor($val) {
return $this->value ^= $val;
}
function __construct($init) {
$this->value = $init;
}
}
$c = new foo(4);
var_dump($c += 3);
var_dump($c -= 3);
var_dump($c *= 3);
var_dump($c /= 2);
var_dump($c %= 3);
$d = new foo(14);
var_dump($d <<= 2);
var_dump($d >>= 2);
$e = new foo('PHP');
var_dump($e .= ' with');
var_dump($e .= ' overloading');
$f = new foo(0x5A);
var_dump($f |= 0xAA);
var_dump($f &= 0xAA);
var_dump($f ^= 0xAA);
--EXPECT--
int(7)
int(4)
int(12)
int(6)
int(0)
int(56)
int(14)
string(8) "PHP with"
string(20) "PHP with overloading"
int(250)
int(170)
int(0)
http://cvs.php.net/viewcvs.cgi/pecl/operator/tests/binary_assign_objdim.phpt?view=markup&rev=1.1
Index: pecl/operator/tests/binary_assign_objdim.phpt
+++ pecl/operator/tests/binary_assign_objdim.phpt
--TEST--
binary assign obj/dim ops
--SKIPIF--
<?php if(!extension_loaded("operator")) print "skip"; ?>
--FILE--
<?php
class foo {
private $value;
function __assign_add($val) {
return $this->value += $val;
}
function __construct($init) {
$this->value = $init;
}
}
class bar implements arrayaccess {
public $baz;
function offsetget($ofs) {
return $this->{$ofs};
}
function offsetset($ofs,$val) { echo "argh"; }
function offsetunset($ofs) { echo "oof"; }
function offsetexists($ofs) { echo "ick"; return true; }
}
$a = new foo(4);
$b = new bar;
$b->baz = $a;
var_dump($b->baz += 10);
var_dump($b->baz += 5);
var_dump($b['baz'] += 10);
var_dump($b['baz'] += 5);
--EXPECT--
int(14)
int(19)
int(29)
int(34)
http://cvs.php.net/viewcvs.cgi/pecl/operator/tests/incdec_obj.phpt?view=markup&rev=1.1
Index: pecl/operator/tests/incdec_obj.phpt
+++ pecl/operator/tests/incdec_obj.phpt
--TEST--
Inc/Dec obj ops
--SKIPIF--
<?php if(!extension_loaded("operator")) print "skip"; ?>
--FILE--
<?php
class foo {
private $value;
function __post_inc() {
return $this->value++;
}
function __post_dec() {
return $this->value--;
}
function __pre_inc() {
$this->value++;
return $this->value;
}
function __pre_dec() {
$this->value--;
return $this->value;
}
function __construct($init) {
$this->value = $init;
}
}
class bar {
public $baz;
}
$c = new foo(7);
$d = new bar;
$d->baz = $c;
for($i = 0; $i < 3; $i++) {
var_dump($d->baz++);
}
for($i = 0; $i < 3; $i++) {
var_dump($d->baz--);
}
for($i = 0; $i < 3; $i++) {
var_dump(++$d->baz);
}
for($i = 0; $i < 3; $i++) {
var_dump(--$d->baz);
}
--EXPECT--
int(7)
int(8)
int(9)
int(10)
int(9)
int(8)
int(8)
int(9)
int(10)
int(9)
int(8)
int(7)