]> granicus.if.org Git - php/commitdiff
New lang tests.
authorandy wharmby <wharmby@php.net>
Sun, 21 Jun 2009 17:42:16 +0000 (17:42 +0000)
committerandy wharmby <wharmby@php.net>
Sun, 21 Jun 2009 17:42:16 +0000 (17:42 +0000)
tests/lang/passByReference_012.phpt [new file with mode: 0644]
tests/lang/string_decimals_001.phpt [new file with mode: 0644]
tests/lang/this_assignment.phpt [new file with mode: 0644]

diff --git a/tests/lang/passByReference_012.phpt b/tests/lang/passByReference_012.phpt
new file mode 100644 (file)
index 0000000..3f80799
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Test pass by reference semantics
+--FILE--
+<?php
+error_reporting(E_ALL | E_STRICT | E_NOTICE);
+
+// Simplified array_shift_variation5.phpt
+// Showing warning:
+// "Only variables should be passed by reference in %s on line %d"
+$stack = array ( array ( 'two' ));
+var_dump(array_shift(array_shift($stack)));
+
+// This should show the identical warning 
+$original = array ( array ( 'one' ));
+$stack = $original;
+var_dump(array_shift(array_shift($stack)));
+?>
+===DONE===
+--EXPECTF--
+Strict Standards: Only variables should be passed by reference in %s on line %d
+string(3) "two"
+
+Strict Standards: Only variables should be passed by reference in %s on line %d
+string(3) "one"
+===DONE===
+       
\ No newline at end of file
diff --git a/tests/lang/string_decimals_001.phpt b/tests/lang/string_decimals_001.phpt
new file mode 100644 (file)
index 0000000..3a509b2
--- /dev/null
@@ -0,0 +1,45 @@
+--TEST--
+String conversion with multiple decimal points
+--FILE--
+<?php
+function test($str) {
+  echo "\n--> Testing $str:\n";
+  var_dump((int)$str);
+  var_dump((float)$str);
+  var_dump($str > 0);
+}
+
+test("..9");
+test(".9.");
+test("9..");
+test("9.9.");
+test("9.9.9");
+?>
+===DONE===
+--EXPECTF--
+
+--> Testing ..9:
+int(0)
+float(0)
+bool(false)
+
+--> Testing .9.:
+int(0)
+float(0.9)
+bool(true)
+
+--> Testing 9..:
+int(9)
+float(9)
+bool(true)
+
+--> Testing 9.9.:
+int(9)
+float(9.9)
+bool(true)
+
+--> Testing 9.9.9:
+int(9)
+float(9.9)
+bool(true)
+===DONE===
\ No newline at end of file
diff --git a/tests/lang/this_assignment.phpt b/tests/lang/this_assignment.phpt
new file mode 100644 (file)
index 0000000..7158a34
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Test to catch early assignment of $this
+--FILE--
+<?php
+class first {
+
+   function me() { echo "first"; }
+
+   function who() { 
+     global $a,$b;
+     $this->me();
+     $a->me();
+     $b->me();
+     $b = new second();
+     $this->me();
+     $a->me();
+     $b->me();
+   }
+}
+
+class second {
+
+   function who() { 
+      global $a,$b;
+      $this->me();
+      $a->me();
+      $b->me();
+   }
+   function me() { echo "second"; }
+}
+
+$a = new first();
+$b = &$a;
+
+$a->who();
+$b->who();
+
+echo "\n";
+?>
+===DONE===
+--EXPECT--
+firstfirstfirstfirstsecondsecondsecondsecondsecond
+===DONE===
\ No newline at end of file