]> granicus.if.org Git - php/commitdiff
add new tests
authorAntony Dovgal <tony2001@php.net>
Fri, 27 Apr 2007 21:32:40 +0000 (21:32 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 27 Apr 2007 21:32:40 +0000 (21:32 +0000)
14 files changed:
Zend/tests/cast_to_array.phpt [new file with mode: 0644]
Zend/tests/cast_to_bool.phpt [new file with mode: 0644]
Zend/tests/cast_to_double.phpt [new file with mode: 0644]
Zend/tests/cast_to_int.phpt [new file with mode: 0644]
Zend/tests/cast_to_object.phpt [new file with mode: 0644]
Zend/tests/cast_to_string.phpt [new file with mode: 0644]
Zend/tests/settype_array.phpt [new file with mode: 0644]
Zend/tests/settype_bool.phpt [new file with mode: 0644]
Zend/tests/settype_double.phpt [new file with mode: 0644]
Zend/tests/settype_int.phpt [new file with mode: 0644]
Zend/tests/settype_null.phpt [new file with mode: 0644]
Zend/tests/settype_object.phpt [new file with mode: 0644]
Zend/tests/settype_resource.phpt [new file with mode: 0644]
Zend/tests/settype_string.phpt [new file with mode: 0644]

diff --git a/Zend/tests/cast_to_array.phpt b/Zend/tests/cast_to_array.phpt
new file mode 100644 (file)
index 0000000..5c59d91
Binary files /dev/null and b/Zend/tests/cast_to_array.phpt differ
diff --git a/Zend/tests/cast_to_bool.phpt b/Zend/tests/cast_to_bool.phpt
new file mode 100644 (file)
index 0000000..75ab09d
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+casting different variables to boolean
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       $tmp = (bool)$var;
+       var_dump($tmp);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+Done
diff --git a/Zend/tests/cast_to_double.phpt b/Zend/tests/cast_to_double.phpt
new file mode 100644 (file)
index 0000000..7afc270
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+casting different variables to double 
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       $tmp = (double)$var;
+       var_dump($tmp);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+float(0)
+float(8754456)
+float(0)
+float(0)
+float(9876545)
+float(0.1)
+float(0)
+float(1)
+float(0)
+float(1)
+float(0)
+float(%d)
+
+Notice: Object of class test could not be converted to double in %s on line %d
+float(1)
+Done
diff --git a/Zend/tests/cast_to_int.phpt b/Zend/tests/cast_to_int.phpt
new file mode 100644 (file)
index 0000000..28c57dd
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+casting different variables to integer
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       $tmp = (int)$var;
+       var_dump($tmp);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+int(0)
+int(8754456)
+int(0)
+int(0)
+int(9876545)
+int(0)
+int(0)
+int(1)
+int(0)
+int(1)
+int(0)
+int(%d)
+
+Notice: Object of class test could not be converted to int in %s on line %d
+int(1)
+Done
diff --git a/Zend/tests/cast_to_object.phpt b/Zend/tests/cast_to_object.phpt
new file mode 100644 (file)
index 0000000..586b76a
Binary files /dev/null and b/Zend/tests/cast_to_object.phpt differ
diff --git a/Zend/tests/cast_to_string.phpt b/Zend/tests/cast_to_string.phpt
new file mode 100644 (file)
index 0000000..4d2ccb8
Binary files /dev/null and b/Zend/tests/cast_to_string.phpt differ
diff --git a/Zend/tests/settype_array.phpt b/Zend/tests/settype_array.phpt
new file mode 100644 (file)
index 0000000..98c3b87
Binary files /dev/null and b/Zend/tests/settype_array.phpt differ
diff --git a/Zend/tests/settype_bool.phpt b/Zend/tests/settype_bool.phpt
new file mode 100644 (file)
index 0000000..cf59200
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+casting different variables to boolean using settype()
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       settype($var, "bool");
+       var_dump($var);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+Done
diff --git a/Zend/tests/settype_double.phpt b/Zend/tests/settype_double.phpt
new file mode 100644 (file)
index 0000000..931a3d9
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+casting different variables to double using settype() 
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       settype($var, "double");
+       var_dump($var);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+float(0)
+float(8754456)
+float(0)
+float(0)
+float(9876545)
+float(0.1)
+float(0)
+float(1)
+float(0)
+float(1)
+float(0)
+float(%d)
+
+Notice: Object of class test could not be converted to double in %s on line %d
+float(1)
+Done
diff --git a/Zend/tests/settype_int.phpt b/Zend/tests/settype_int.phpt
new file mode 100644 (file)
index 0000000..7b96cd5
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+casting different variables to integer using settype()
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       settype($var, "int");
+       var_dump($var);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+int(0)
+int(8754456)
+int(0)
+int(0)
+int(9876545)
+int(0)
+int(0)
+int(1)
+int(0)
+int(1)
+int(0)
+int(%d)
+
+Notice: Object of class test could not be converted to int in %s on line %d
+int(1)
+Done
diff --git a/Zend/tests/settype_null.phpt b/Zend/tests/settype_null.phpt
new file mode 100644 (file)
index 0000000..0abf2f9
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+casting different variables to null using settype() 
+--FILE--
+<?php
+
+$r = fopen(__FILE__, "r");
+
+class test {
+       function  __toString() {
+               return "10";
+       }
+}
+
+$o = new test;
+
+$vars = array(
+       "string",
+       "8754456",
+       "",
+       "\0",
+       9876545,
+       0.10,
+       array(),
+       array(1,2,3),
+       false,
+       true,
+       NULL,
+       $r,
+       $o
+);
+
+foreach ($vars as $var) {
+       settype($var, "null");
+       var_dump($var);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--    
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+Done
diff --git a/Zend/tests/settype_object.phpt b/Zend/tests/settype_object.phpt
new file mode 100644 (file)
index 0000000..a3a433c
Binary files /dev/null and b/Zend/tests/settype_object.phpt differ
diff --git a/Zend/tests/settype_resource.phpt b/Zend/tests/settype_resource.phpt
new file mode 100644 (file)
index 0000000..7210613
Binary files /dev/null and b/Zend/tests/settype_resource.phpt differ
diff --git a/Zend/tests/settype_string.phpt b/Zend/tests/settype_string.phpt
new file mode 100644 (file)
index 0000000..e8e5ff1
Binary files /dev/null and b/Zend/tests/settype_string.phpt differ