summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-04-27 21:33:02 +0000
committerAntony Dovgal <tony2001@php.net>2007-04-27 21:33:02 +0000
commit70e6d3d042538cac68f17539bdc337244e92edee (patch)
treee3b70a6c9b373e46601d342be40dffd0febdcc4f /Zend
parent9b1de77959c4d24ccb8e52ac166d22013d4aab4d (diff)
downloadphp-git-70e6d3d042538cac68f17539bdc337244e92edee.tar.gz
add new tests
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/cast_to_array.phptbin0 -> 986 bytes
-rw-r--r--Zend/tests/cast_to_bool.phpt53
-rw-r--r--Zend/tests/cast_to_double.phpt55
-rw-r--r--Zend/tests/cast_to_int.phpt55
-rw-r--r--Zend/tests/cast_to_object.phptbin0 -> 1106 bytes
-rw-r--r--Zend/tests/cast_to_string.phptbin0 -> 621 bytes
-rw-r--r--Zend/tests/settype_array.phptbin0 -> 1006 bytes
-rw-r--r--Zend/tests/settype_bool.phpt53
-rw-r--r--Zend/tests/settype_double.phpt55
-rw-r--r--Zend/tests/settype_int.phpt55
-rw-r--r--Zend/tests/settype_null.phpt53
-rw-r--r--Zend/tests/settype_object.phptbin0 -> 1126 bytes
-rw-r--r--Zend/tests/settype_resource.phptbin0 -> 1581 bytes
-rw-r--r--Zend/tests/settype_string.phptbin0 -> 747 bytes
14 files changed, 379 insertions, 0 deletions
diff --git a/Zend/tests/cast_to_array.phpt b/Zend/tests/cast_to_array.phpt
new file mode 100644
index 0000000000..5e351052bb
--- /dev/null
+++ b/Zend/tests/cast_to_array.phpt
Binary files differ
diff --git a/Zend/tests/cast_to_bool.phpt b/Zend/tests/cast_to_bool.phpt
new file mode 100644
index 0000000000..75ab09d1b5
--- /dev/null
+++ b/Zend/tests/cast_to_bool.phpt
@@ -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
index 0000000000..7afc2708be
--- /dev/null
+++ b/Zend/tests/cast_to_double.phpt
@@ -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
index 0000000000..28c57ddf63
--- /dev/null
+++ b/Zend/tests/cast_to_int.phpt
@@ -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
index 0000000000..f8d4878475
--- /dev/null
+++ b/Zend/tests/cast_to_object.phpt
Binary files differ
diff --git a/Zend/tests/cast_to_string.phpt b/Zend/tests/cast_to_string.phpt
new file mode 100644
index 0000000000..d06daa2e7c
--- /dev/null
+++ b/Zend/tests/cast_to_string.phpt
Binary files differ
diff --git a/Zend/tests/settype_array.phpt b/Zend/tests/settype_array.phpt
new file mode 100644
index 0000000000..5da023205e
--- /dev/null
+++ b/Zend/tests/settype_array.phpt
Binary files differ
diff --git a/Zend/tests/settype_bool.phpt b/Zend/tests/settype_bool.phpt
new file mode 100644
index 0000000000..cf59200b81
--- /dev/null
+++ b/Zend/tests/settype_bool.phpt
@@ -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
index 0000000000..931a3d9dff
--- /dev/null
+++ b/Zend/tests/settype_double.phpt
@@ -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
index 0000000000..7b96cd594e
--- /dev/null
+++ b/Zend/tests/settype_int.phpt
@@ -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
index 0000000000..0abf2f9810
--- /dev/null
+++ b/Zend/tests/settype_null.phpt
@@ -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
index 0000000000..d619dce7e3
--- /dev/null
+++ b/Zend/tests/settype_object.phpt
Binary files differ
diff --git a/Zend/tests/settype_resource.phpt b/Zend/tests/settype_resource.phpt
new file mode 100644
index 0000000000..cc8cde34fd
--- /dev/null
+++ b/Zend/tests/settype_resource.phpt
Binary files differ
diff --git a/Zend/tests/settype_string.phpt b/Zend/tests/settype_string.phpt
new file mode 100644
index 0000000000..d3beb54cb7
--- /dev/null
+++ b/Zend/tests/settype_string.phpt
Binary files differ