]> granicus.if.org Git - php/commitdiff
add new tests
authorAntony Dovgal <tony2001@php.net>
Sat, 28 Apr 2007 11:59:08 +0000 (11:59 +0000)
committerAntony Dovgal <tony2001@php.net>
Sat, 28 Apr 2007 11:59:08 +0000 (11:59 +0000)
22 files changed:
Zend/tests/add_001.phpt [new file with mode: 0644]
Zend/tests/add_002.phpt [new file with mode: 0644]
Zend/tests/add_003.phpt [new file with mode: 0644]
Zend/tests/add_004.phpt [new file with mode: 0644]
Zend/tests/add_005.phpt [new file with mode: 0644]
Zend/tests/add_006.phpt [new file with mode: 0644]
Zend/tests/add_007.phpt [new file with mode: 0644]
Zend/tests/and_001.phpt [new file with mode: 0644]
Zend/tests/concat_001.phpt [new file with mode: 0644]
Zend/tests/div_001.phpt [new file with mode: 0644]
Zend/tests/div_002.phpt [new file with mode: 0644]
Zend/tests/mod_001.phpt [new file with mode: 0644]
Zend/tests/mul_001.phpt [new file with mode: 0644]
Zend/tests/not_001.phpt [new file with mode: 0644]
Zend/tests/not_002.phpt [new file with mode: 0644]
Zend/tests/or_001.phpt [new file with mode: 0644]
Zend/tests/shift_001.phpt [new file with mode: 0644]
Zend/tests/shift_002.phpt [new file with mode: 0644]
Zend/tests/sub_001.phpt [new file with mode: 0644]
Zend/tests/xor_001.phpt [new file with mode: 0644]
Zend/tests/xor_002.phpt [new file with mode: 0644]
Zend/tests/xor_003.phpt [new file with mode: 0644]

diff --git a/Zend/tests/add_001.phpt b/Zend/tests/add_001.phpt
new file mode 100644 (file)
index 0000000..8d12aea
--- /dev/null
@@ -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 (file)
index 0000000..437ac91
--- /dev/null
@@ -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 (file)
index 0000000..4223af3
--- /dev/null
@@ -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 (file)
index 0000000..492ff31
--- /dev/null
@@ -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 (file)
index 0000000..7e9bc25
--- /dev/null
@@ -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 (file)
index 0000000..c3f127e
--- /dev/null
@@ -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 (file)
index 0000000..b2f1559
--- /dev/null
@@ -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 (file)
index 0000000..109b2ce
--- /dev/null
@@ -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 (file)
index 0000000..be12976
--- /dev/null
@@ -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 (file)
index 0000000..5fa264a
--- /dev/null
@@ -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 (file)
index 0000000..6ade1d9
--- /dev/null
@@ -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 (file)
index 0000000..88596f3
--- /dev/null
@@ -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 (file)
index 0000000..4c5a75e
--- /dev/null
@@ -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 (file)
index 0000000..6eb0f00
--- /dev/null
@@ -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 (file)
index 0000000..df27772
--- /dev/null
@@ -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 (file)
index 0000000..1e4e513
--- /dev/null
@@ -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) "wo\7fu"
+string(4) "wo\7fu"
+Done
diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt
new file mode 100644 (file)
index 0000000..aeb3994
--- /dev/null
@@ -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 (file)
index 0000000..4d8421a
--- /dev/null
@@ -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 (file)
index 0000000..2a8b3cd
--- /dev/null
@@ -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 (file)
index 0000000..e1a521d
--- /dev/null
@@ -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 (file)
index 0000000..0cf4054
--- /dev/null
@@ -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 (file)
index 0000000..8aa1c63
--- /dev/null
@@ -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