diff options
author | Antony Dovgal <tony2001@php.net> | 2007-04-28 11:59:08 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2007-04-28 11:59:08 +0000 |
commit | c3b9d939e045e77095c4f4f69e12e0c6f9e5cb1f (patch) | |
tree | 14b9eb7d201e58ce0189d03a76402a35430d08d6 | |
parent | 70e6d3d042538cac68f17539bdc337244e92edee (diff) | |
download | php-git-c3b9d939e045e77095c4f4f69e12e0c6f9e5cb1f.tar.gz |
add new tests
-rw-r--r-- | Zend/tests/add_001.phpt | 73 | ||||
-rw-r--r-- | Zend/tests/add_002.phpt | 19 | ||||
-rw-r--r-- | Zend/tests/add_003.phpt | 19 | ||||
-rw-r--r-- | Zend/tests/add_004.phpt | 14 | ||||
-rw-r--r-- | Zend/tests/add_005.phpt | 22 | ||||
-rw-r--r-- | Zend/tests/add_006.phpt | 47 | ||||
-rw-r--r-- | Zend/tests/add_007.phpt | 16 | ||||
-rw-r--r-- | Zend/tests/and_001.phpt | 39 | ||||
-rw-r--r-- | Zend/tests/concat_001.phpt | 78 | ||||
-rw-r--r-- | Zend/tests/div_001.phpt | 32 | ||||
-rw-r--r-- | Zend/tests/div_002.phpt | 15 | ||||
-rw-r--r-- | Zend/tests/mod_001.phpt | 17 | ||||
-rw-r--r-- | Zend/tests/mul_001.phpt | 15 | ||||
-rw-r--r-- | Zend/tests/not_001.phpt | 22 | ||||
-rw-r--r-- | Zend/tests/not_002.phpt | 15 | ||||
-rw-r--r-- | Zend/tests/or_001.phpt | 29 | ||||
-rw-r--r-- | Zend/tests/shift_001.phpt | 25 | ||||
-rw-r--r-- | Zend/tests/shift_002.phpt | 25 | ||||
-rw-r--r-- | Zend/tests/sub_001.phpt | 15 | ||||
-rw-r--r-- | Zend/tests/xor_001.phpt | 16 | ||||
-rw-r--r-- | Zend/tests/xor_002.phpt | 39 | ||||
-rw-r--r-- | Zend/tests/xor_003.phpt | 19 |
22 files changed, 611 insertions, 0 deletions
diff --git a/Zend/tests/add_001.phpt b/Zend/tests/add_001.phpt new file mode 100644 index 0000000000..8d12aea11d --- /dev/null +++ b/Zend/tests/add_001.phpt @@ -0,0 +1,73 @@ +--TEST-- +adding arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array("str", "here"); + +$c = $a + $b; +var_dump($c); + +$a = array(1,2,3); +$b = array(1,2,4); + +$c = $a + $b; +var_dump($c); + +$a = array("a"=>"aaa",2,3); +$b = array(1,2,"a"=>"bbbbbb"); + +$c = $a + $b; +var_dump($c); + +$a += $b; +var_dump($c); + +$a += $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +Done diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt new file mode 100644 index 0000000000..437ac9113a --- /dev/null +++ b/Zend/tests/add_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding objects to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $a + $o; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_003.phpt b/Zend/tests/add_003.phpt new file mode 100644 index 0000000000..4223af3f19 --- /dev/null +++ b/Zend/tests/add_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding arrays to objects +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $o + $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_004.phpt b/Zend/tests/add_004.phpt new file mode 100644 index 0000000000..492ff31ba3 --- /dev/null +++ b/Zend/tests/add_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +adding numbers to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$c = $a + 5; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_005.phpt b/Zend/tests/add_005.phpt new file mode 100644 index 0000000000..7e9bc25d8f --- /dev/null +++ b/Zend/tests/add_005.phpt @@ -0,0 +1,22 @@ +--TEST-- +adding integers to doubles +--INI-- +precision=14 +--FILE-- +<?php + +$i = 75636; +$d = 2834681123.123123; + +$c = $i + $d; +var_dump($c); + +$c = $d + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(2834756759.1231) +float(2834756759.1231) +Done diff --git a/Zend/tests/add_006.phpt b/Zend/tests/add_006.phpt new file mode 100644 index 0000000000..c3f127e9cf --- /dev/null +++ b/Zend/tests/add_006.phpt @@ -0,0 +1,47 @@ +--TEST-- +adding numbers to strings +--FILE-- +<?php + +$i = 75636; +$s1 = "this is a string"; +$s2 = "876222numeric"; +$s3 = "48474874"; +$s4 = "25.68"; + +$c = $i + $s1; +var_dump($c); + +$c = $i + $s2; +var_dump($c); + +$c = $i + $s3; +var_dump($c); + +$c = $i + $s4; +var_dump($c); + +$c = $s1 + $i; +var_dump($c); + +$c = $s2 + $i; +var_dump($c); + +$c = $s3 + $i; +var_dump($c); + +$c = $s4 + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(75636) +int(951858) +int(48550510) +float(75661.68) +int(75636) +int(951858) +int(48550510) +float(75661.68) +Done diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt new file mode 100644 index 0000000000..b2f1559b7a --- /dev/null +++ b/Zend/tests/add_007.phpt @@ -0,0 +1,16 @@ +--TEST-- +adding strings to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$s1 = "some string"; + +$c = $a + $s1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/and_001.phpt b/Zend/tests/and_001.phpt new file mode 100644 index 0000000000..109b2ce995 --- /dev/null +++ b/Zend/tests/and_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +bitwise AND and strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test long"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some long"; + +var_dump($s & $s1); + +$s = "test"; +$s &= "some long"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(3) "020" +string(4) "pead" +string(4) "pead" +string(4) "pead" +string(4) "pead" +Done diff --git a/Zend/tests/concat_001.phpt b/Zend/tests/concat_001.phpt new file mode 100644 index 0000000000..be1297655d --- /dev/null +++ b/Zend/tests/concat_001.phpt @@ -0,0 +1,78 @@ +--TEST-- +concat difffent types +--INI-- +precision=14 +--FILE-- +<?php + +class test { + function __toString() { + return "this is test object"; + } +} + +$a = array(1,2,3); +$o = new test; +$s = "some string"; +$i = 222; +$d = 2323.444; + +var_dump($a.$o); +var_dump($a.$s); +var_dump($a.$i); +var_dump($a.$d); +var_dump($a.$a); + +var_dump($o.$a); +var_dump($o.$s); +var_dump($o.$i); +var_dump($o.$d); +var_dump($o.$o); + +var_dump($s.$o); +var_dump($s.$a); +var_dump($s.$i); +var_dump($s.$d); +var_dump($s.$s); + +var_dump($i.$a); +var_dump($i.$o); +var_dump($i.$s); +var_dump($i.$d); +var_dump($i.$i); + +var_dump($d.$a); +var_dump($d.$o); +var_dump($d.$s); +var_dump($d.$i); +var_dump($d.$d); + +echo "Done\n"; +?> +--EXPECTF-- +string(24) "Arraythis is test object" +string(16) "Arraysome string" +string(8) "Array222" +string(13) "Array2323.444" +string(10) "ArrayArray" +string(24) "this is test objectArray" +string(30) "this is test objectsome string" +string(22) "this is test object222" +string(27) "this is test object2323.444" +string(38) "this is test objectthis is test object" +string(30) "some stringthis is test object" +string(16) "some stringArray" +string(14) "some string222" +string(19) "some string2323.444" +string(22) "some stringsome string" +string(8) "222Array" +string(22) "222this is test object" +string(14) "222some string" +string(11) "2222323.444" +string(6) "222222" +string(13) "2323.444Array" +string(27) "2323.444this is test object" +string(19) "2323.444some string" +string(11) "2323.444222" +string(16) "2323.4442323.444" +Done diff --git a/Zend/tests/div_001.phpt b/Zend/tests/div_001.phpt new file mode 100644 index 0000000000..5fa264a11e --- /dev/null +++ b/Zend/tests/div_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +dividing doubles +--INI-- +precision=14 +--FILE-- +<?php + +$d1 = 1.1; +$d2 = 434234.234; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = 1.1; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = "1.1"; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(394758.39454545) +float(394758.39454545) +float(394758.39454545) +Done diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt new file mode 100644 index 0000000000..6ade1d9f51 --- /dev/null +++ b/Zend/tests/div_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +dividing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a / $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt new file mode 100644 index 0000000000..88596f3d5f --- /dev/null +++ b/Zend/tests/mod_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +modulus by zero +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a % $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Division by zero in %s on line %d +bool(false) +Done diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt new file mode 100644 index 0000000000..4c5a75e7d1 --- /dev/null +++ b/Zend/tests/mul_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +multiplying arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a * $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt new file mode 100644 index 0000000000..6eb0f000c9 --- /dev/null +++ b/Zend/tests/not_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +bitwise NOT, doubles and strings +--FILE-- +<?php + +$d = 23.67; +$s = "48484.22"; +$s1 = "test"; +$s2 = "some"; + +$s = ~$d; +var_dump($s); + +$s1 = ~$s2; +var_dump(bin2hex($s1)); + +echo "Done\n"; +?> +--EXPECTF-- +int(-24) +string(8) "8c90929a" +Done diff --git a/Zend/tests/not_002.phpt b/Zend/tests/not_002.phpt new file mode 100644 index 0000000000..df27772a73 --- /dev/null +++ b/Zend/tests/not_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +bitwise NOT and arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1,2); + +$a = ~$b; +var_dump($a); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/or_001.phpt b/Zend/tests/or_001.phpt new file mode 100644 index 0000000000..1e4e5131a5 --- /dev/null +++ b/Zend/tests/or_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +bitwise OR and strings +--FILE-- +<?php + +$s = "323423"; +$s1 = "2323.555"; + +var_dump($s | $s1); +var_dump($s1 | $s); + +$s = "some"; +$s1 = "test"; + +var_dump($s | $s1); + +$s = "some"; +$s |= "test"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(8) "3337>755" +string(8) "3337>755" +string(4) "wou" +string(4) "wou" +Done diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt new file mode 100644 index 0000000000..aeb399452d --- /dev/null +++ b/Zend/tests/shift_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings left +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s <<= 2; +var_dump($s); + +$s1 <<= 1; +var_dump($s1); + +$s2 <<= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(492) +int(0) +int(362760) +Done diff --git a/Zend/tests/shift_002.phpt b/Zend/tests/shift_002.phpt new file mode 100644 index 0000000000..4d8421a566 --- /dev/null +++ b/Zend/tests/shift_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings right +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s >>= 2; +var_dump($s); + +$s1 >>= 1; +var_dump($s1); + +$s2 >>= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(30) +int(0) +int(5668) +Done diff --git a/Zend/tests/sub_001.phpt b/Zend/tests/sub_001.phpt new file mode 100644 index 0000000000..2a8b3cdffd --- /dev/null +++ b/Zend/tests/sub_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +subtracting arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a - $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/xor_001.phpt b/Zend/tests/xor_001.phpt new file mode 100644 index 0000000000..e1a521dff9 --- /dev/null +++ b/Zend/tests/xor_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +XORing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a ^ $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +Done diff --git a/Zend/tests/xor_002.phpt b/Zend/tests/xor_002.phpt new file mode 100644 index 0000000000..0cf4054fa4 --- /dev/null +++ b/Zend/tests/xor_002.phpt @@ -0,0 +1,39 @@ +--TEST-- +XORing strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "1235"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some long"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test long"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s ^= "test long"; +var_dump(bin2hex($s)); + +echo "Done\n"; +?> +--EXPECTF-- +string(6) "030107" +string(6) "030107" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +Done diff --git a/Zend/tests/xor_003.phpt b/Zend/tests/xor_003.phpt new file mode 100644 index 0000000000..8aa1c636b7 --- /dev/null +++ b/Zend/tests/xor_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +XORing booleans +--FILE-- +<?php + +$t = true; +$f = false; + +var_dump($t ^ $f); +var_dump($t ^ $t); +var_dump($f ^ $f); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(0) +int(0) +Done |