diff options
author | Nikita Popov <nikic@php.net> | 2016-11-20 21:24:51 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-11-20 22:31:24 +0100 |
commit | 45f7b2bcc8f95e793c1a9bb60da0848860c060fb (patch) | |
tree | 2a5b25e11e63b1d5f8dad9d1cbd8601364709996 /tests/lang | |
parent | 563a341df7c7a74de706d62ab5e4a8a0c2e9152f (diff) | |
download | php-git-45f7b2bcc8f95e793c1a9bb60da0848860c060fb.tar.gz |
Fix CRLF line-endings in tests
Also fix a single instance of CRLF in ibase_query.c.
Diffstat (limited to 'tests/lang')
72 files changed, 6419 insertions, 6419 deletions
diff --git a/tests/lang/foreachLoop.001.phpt b/tests/lang/foreachLoop.001.phpt index d35f26116d..a7ec701fd1 100644 --- a/tests/lang/foreachLoop.001.phpt +++ b/tests/lang/foreachLoop.001.phpt @@ -1,64 +1,64 @@ ---TEST--
-Foreach loop tests - basic loop with just value and key => value.
---FILE--
-<?php
-
-$a = array("a","b","c");
-
-foreach ($a as $v) {
- var_dump($v);
-}
-foreach ($a as $k => $v) {
- var_dump($k, $v);
-}
-//check key and value after the loop.
-var_dump($k, $v);
-
-echo "\n";
-//Dynamic array
-foreach (array("d","e","f") as $v) {
- var_dump($v);
-}
-foreach (array("d","e","f") as $k => $v) {
- var_dump($k, $v);
-}
-//check key and value after the loop.
-var_dump($k, $v);
-
-echo "\n";
-//Ensure counter is advanced during loop
-$a=array("a","b","c");
-foreach ($a as $v);
-var_dump(current($a));
-$a=array("a","b","c");
-foreach ($a as &$v);
-var_dump(current($a));
-
-?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-int(0)
-string(1) "a"
-int(1)
-string(1) "b"
-int(2)
-string(1) "c"
-int(2)
-string(1) "c"
-
-string(1) "d"
-string(1) "e"
-string(1) "f"
-int(0)
-string(1) "d"
-int(1)
-string(1) "e"
-int(2)
-string(1) "f"
-int(2)
-string(1) "f"
-
-string(1) "a"
+--TEST-- +Foreach loop tests - basic loop with just value and key => value. +--FILE-- +<?php + +$a = array("a","b","c"); + +foreach ($a as $v) { + var_dump($v); +} +foreach ($a as $k => $v) { + var_dump($k, $v); +} +//check key and value after the loop. +var_dump($k, $v); + +echo "\n"; +//Dynamic array +foreach (array("d","e","f") as $v) { + var_dump($v); +} +foreach (array("d","e","f") as $k => $v) { + var_dump($k, $v); +} +//check key and value after the loop. +var_dump($k, $v); + +echo "\n"; +//Ensure counter is advanced during loop +$a=array("a","b","c"); +foreach ($a as $v); +var_dump(current($a)); +$a=array("a","b","c"); +foreach ($a as &$v); +var_dump(current($a)); + +?> +--EXPECT-- +string(1) "a" +string(1) "b" +string(1) "c" +int(0) +string(1) "a" +int(1) +string(1) "b" +int(2) +string(1) "c" +int(2) +string(1) "c" + +string(1) "d" +string(1) "e" +string(1) "f" +int(0) +string(1) "d" +int(1) +string(1) "e" +int(2) +string(1) "f" +int(2) +string(1) "f" + +string(1) "a" string(1) "a" diff --git a/tests/lang/foreachLoop.002.phpt b/tests/lang/foreachLoop.002.phpt index 5896124f40..31492953a4 100644 --- a/tests/lang/foreachLoop.002.phpt +++ b/tests/lang/foreachLoop.002.phpt @@ -1,173 +1,173 @@ ---TEST--
-Foreach loop tests - modifying the array during the loop.
---FILE--
-<?php
-
-echo "\nDirectly changing array values.\n";
-$a = array("original.1","original.2","original.3");
-foreach ($a as $k=>$v) {
- $a[$k]="changed.$k";
- var_dump($v);
-}
-var_dump($a);
-
-echo "\nModifying the foreach \$value.\n";
-$a = array("original.1","original.2","original.3");
-foreach ($a as $k=>$v) {
- $v="changed.$k";
-}
-var_dump($a);
-
-
-echo "\nModifying the foreach &\$value.\n";
-$a = array("original.1","original.2","original.3");
-foreach ($a as $k=>&$v) {
- $v="changed.$k";
-}
-var_dump($a);
-
-echo "\nPushing elements onto an unreferenced array.\n";
-$a = array("original.1","original.2","original.3");
-$counter=0;
-foreach ($a as $v) {
- array_push($a, "new.$counter");
-
- //avoid infinite loop if test is failing
- if ($counter++>10) {
- echo "Loop detected\n";
- break;
- }
-}
-var_dump($a);
-
-echo "\nPushing elements onto an unreferenced array, using &\$value.\n";
-$a = array("original.1","original.2","original.3");
-$counter=0;
-foreach ($a as &$v) {
- array_push($a, "new.$counter");
-
- //avoid infinite loop if test is failing
- if ($counter++>10) {
- echo "Loop detected\n";
- break;
- }
-}
-var_dump($a);
-
-echo "\nPopping elements off an unreferenced array.\n";
-$a = array("original.1","original.2","original.3");
-foreach ($a as $v) {
- array_pop($a);
- var_dump($v);
-}
-var_dump($a);
-
-echo "\nPopping elements off an unreferenced array, using &\$value.\n";
-$a = array("original.1","original.2","original.3");
-foreach ($a as &$v) {
- array_pop($a);
- var_dump($v);
-}
-var_dump($a);
-
-?>
---EXPECT--
-
-Directly changing array values.
-string(10) "original.1"
-string(10) "original.2"
-string(10) "original.3"
-array(3) {
- [0]=>
- string(9) "changed.0"
- [1]=>
- string(9) "changed.1"
- [2]=>
- string(9) "changed.2"
-}
-
-Modifying the foreach $value.
-array(3) {
- [0]=>
- string(10) "original.1"
- [1]=>
- string(10) "original.2"
- [2]=>
- string(10) "original.3"
-}
-
-Modifying the foreach &$value.
-array(3) {
- [0]=>
- string(9) "changed.0"
- [1]=>
- string(9) "changed.1"
- [2]=>
- &string(9) "changed.2"
-}
-
-Pushing elements onto an unreferenced array.
-array(6) {
- [0]=>
- string(10) "original.1"
- [1]=>
- string(10) "original.2"
- [2]=>
- string(10) "original.3"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- string(5) "new.2"
-}
-
-Pushing elements onto an unreferenced array, using &$value.
-Loop detected
-array(15) {
- [0]=>
- string(10) "original.1"
- [1]=>
- string(10) "original.2"
- [2]=>
- string(10) "original.3"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- string(5) "new.2"
- [6]=>
- string(5) "new.3"
- [7]=>
- string(5) "new.4"
- [8]=>
- string(5) "new.5"
- [9]=>
- string(5) "new.6"
- [10]=>
- string(5) "new.7"
- [11]=>
- &string(5) "new.8"
- [12]=>
- string(5) "new.9"
- [13]=>
- string(6) "new.10"
- [14]=>
- string(6) "new.11"
-}
-
-Popping elements off an unreferenced array.
-string(10) "original.1"
-string(10) "original.2"
-string(10) "original.3"
-array(0) {
-}
-
-Popping elements off an unreferenced array, using &$value.
-string(10) "original.1"
-string(10) "original.2"
-array(1) {
- [0]=>
- string(10) "original.1"
+--TEST-- +Foreach loop tests - modifying the array during the loop. +--FILE-- +<?php + +echo "\nDirectly changing array values.\n"; +$a = array("original.1","original.2","original.3"); +foreach ($a as $k=>$v) { + $a[$k]="changed.$k"; + var_dump($v); +} +var_dump($a); + +echo "\nModifying the foreach \$value.\n"; +$a = array("original.1","original.2","original.3"); +foreach ($a as $k=>$v) { + $v="changed.$k"; +} +var_dump($a); + + +echo "\nModifying the foreach &\$value.\n"; +$a = array("original.1","original.2","original.3"); +foreach ($a as $k=>&$v) { + $v="changed.$k"; +} +var_dump($a); + +echo "\nPushing elements onto an unreferenced array.\n"; +$a = array("original.1","original.2","original.3"); +$counter=0; +foreach ($a as $v) { + array_push($a, "new.$counter"); + + //avoid infinite loop if test is failing + if ($counter++>10) { + echo "Loop detected\n"; + break; + } +} +var_dump($a); + +echo "\nPushing elements onto an unreferenced array, using &\$value.\n"; +$a = array("original.1","original.2","original.3"); +$counter=0; +foreach ($a as &$v) { + array_push($a, "new.$counter"); + + //avoid infinite loop if test is failing + if ($counter++>10) { + echo "Loop detected\n"; + break; + } +} +var_dump($a); + +echo "\nPopping elements off an unreferenced array.\n"; +$a = array("original.1","original.2","original.3"); +foreach ($a as $v) { + array_pop($a); + var_dump($v); +} +var_dump($a); + +echo "\nPopping elements off an unreferenced array, using &\$value.\n"; +$a = array("original.1","original.2","original.3"); +foreach ($a as &$v) { + array_pop($a); + var_dump($v); +} +var_dump($a); + +?> +--EXPECT-- + +Directly changing array values. +string(10) "original.1" +string(10) "original.2" +string(10) "original.3" +array(3) { + [0]=> + string(9) "changed.0" + [1]=> + string(9) "changed.1" + [2]=> + string(9) "changed.2" +} + +Modifying the foreach $value. +array(3) { + [0]=> + string(10) "original.1" + [1]=> + string(10) "original.2" + [2]=> + string(10) "original.3" +} + +Modifying the foreach &$value. +array(3) { + [0]=> + string(9) "changed.0" + [1]=> + string(9) "changed.1" + [2]=> + &string(9) "changed.2" +} + +Pushing elements onto an unreferenced array. +array(6) { + [0]=> + string(10) "original.1" + [1]=> + string(10) "original.2" + [2]=> + string(10) "original.3" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + string(5) "new.2" +} + +Pushing elements onto an unreferenced array, using &$value. +Loop detected +array(15) { + [0]=> + string(10) "original.1" + [1]=> + string(10) "original.2" + [2]=> + string(10) "original.3" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + string(5) "new.2" + [6]=> + string(5) "new.3" + [7]=> + string(5) "new.4" + [8]=> + string(5) "new.5" + [9]=> + string(5) "new.6" + [10]=> + string(5) "new.7" + [11]=> + &string(5) "new.8" + [12]=> + string(5) "new.9" + [13]=> + string(6) "new.10" + [14]=> + string(6) "new.11" +} + +Popping elements off an unreferenced array. +string(10) "original.1" +string(10) "original.2" +string(10) "original.3" +array(0) { +} + +Popping elements off an unreferenced array, using &$value. +string(10) "original.1" +string(10) "original.2" +array(1) { + [0]=> + string(10) "original.1" } diff --git a/tests/lang/foreachLoop.003.phpt b/tests/lang/foreachLoop.003.phpt index d554d0d87f..a62d5dbb3b 100644 --- a/tests/lang/foreachLoop.003.phpt +++ b/tests/lang/foreachLoop.003.phpt @@ -1,46 +1,46 @@ ---TEST--
-Foreach loop tests - error case: not an array.
---FILE--
-<?php
-echo "\nNot an array.\n";
-$a = TRUE;
-foreach ($a as $v) {
- var_dump($v);
-}
-
-$a = null;
-foreach ($a as $v) {
- var_dump($v);
-}
-
-$a = 1;
-foreach ($a as $v) {
- var_dump($v);
-}
-
-$a = 1.5;
-foreach ($a as $v) {
- var_dump($v);
-}
-
-$a = "hello";
-foreach ($a as $v) {
- var_dump($v);
-}
-
-echo "done.\n";
-?>
---EXPECTF--
-
-Not an array.
-
-Warning: Invalid argument supplied for foreach() in %s on line 4
-
-Warning: Invalid argument supplied for foreach() in %s on line 9
-
-Warning: Invalid argument supplied for foreach() in %s on line 14
-
-Warning: Invalid argument supplied for foreach() in %s on line 19
-
-Warning: Invalid argument supplied for foreach() in %s on line 24
-done.
+--TEST-- +Foreach loop tests - error case: not an array. +--FILE-- +<?php +echo "\nNot an array.\n"; +$a = TRUE; +foreach ($a as $v) { + var_dump($v); +} + +$a = null; +foreach ($a as $v) { + var_dump($v); +} + +$a = 1; +foreach ($a as $v) { + var_dump($v); +} + +$a = 1.5; +foreach ($a as $v) { + var_dump($v); +} + +$a = "hello"; +foreach ($a as $v) { + var_dump($v); +} + +echo "done.\n"; +?> +--EXPECTF-- + +Not an array. + +Warning: Invalid argument supplied for foreach() in %s on line 4 + +Warning: Invalid argument supplied for foreach() in %s on line 9 + +Warning: Invalid argument supplied for foreach() in %s on line 14 + +Warning: Invalid argument supplied for foreach() in %s on line 19 + +Warning: Invalid argument supplied for foreach() in %s on line 24 +done. diff --git a/tests/lang/foreachLoop.004.phpt b/tests/lang/foreachLoop.004.phpt index 178cad0981..3cc1960ca1 100644 --- a/tests/lang/foreachLoop.004.phpt +++ b/tests/lang/foreachLoop.004.phpt @@ -1,76 +1,76 @@ ---TEST--
-Foreach loop tests - using an array element as the $value
---FILE--
-<?php
-
-$a=array("a", "b", "c");
-$v=array();
-foreach($a as $v[0]) {
- var_dump($v);
-}
-var_dump($a);
-var_dump($v);
-
-echo "\n";
-$a=array("a", "b", "c");
-$v=array();
-foreach($a as $k=>$v[0]) {
- var_dump($k, $v);
-}
-var_dump($a);
-var_dump($k, $v);
-?>
---EXPECT--
-array(1) {
- [0]=>
- string(1) "a"
-}
-array(1) {
- [0]=>
- string(1) "b"
-}
-array(1) {
- [0]=>
- string(1) "c"
-}
-array(3) {
- [0]=>
- string(1) "a"
- [1]=>
- string(1) "b"
- [2]=>
- string(1) "c"
-}
-array(1) {
- [0]=>
- string(1) "c"
-}
-
-int(0)
-array(1) {
- [0]=>
- string(1) "a"
-}
-int(1)
-array(1) {
- [0]=>
- string(1) "b"
-}
-int(2)
-array(1) {
- [0]=>
- string(1) "c"
-}
-array(3) {
- [0]=>
- string(1) "a"
- [1]=>
- string(1) "b"
- [2]=>
- string(1) "c"
-}
-int(2)
-array(1) {
- [0]=>
- string(1) "c"
+--TEST-- +Foreach loop tests - using an array element as the $value +--FILE-- +<?php + +$a=array("a", "b", "c"); +$v=array(); +foreach($a as $v[0]) { + var_dump($v); +} +var_dump($a); +var_dump($v); + +echo "\n"; +$a=array("a", "b", "c"); +$v=array(); +foreach($a as $k=>$v[0]) { + var_dump($k, $v); +} +var_dump($a); +var_dump($k, $v); +?> +--EXPECT-- +array(1) { + [0]=> + string(1) "a" +} +array(1) { + [0]=> + string(1) "b" +} +array(1) { + [0]=> + string(1) "c" +} +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" +} +array(1) { + [0]=> + string(1) "c" +} + +int(0) +array(1) { + [0]=> + string(1) "a" +} +int(1) +array(1) { + [0]=> + string(1) "b" +} +int(2) +array(1) { + [0]=> + string(1) "c" +} +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "b" + [2]=> + string(1) "c" +} +int(2) +array(1) { + [0]=> + string(1) "c" } diff --git a/tests/lang/foreachLoop.005.phpt b/tests/lang/foreachLoop.005.phpt index ae6ed3aa28..c7e4ceb8e7 100644 --- a/tests/lang/foreachLoop.005.phpt +++ b/tests/lang/foreachLoop.005.phpt @@ -1,23 +1,23 @@ ---TEST--
-Foreach loop tests - modifying the array during the loop: special case. Behaviour is good since php 5.2.2.
---FILE--
-<?php
-$a = array("original.0","original.1","original.2");
-foreach ($a as $k=>&$v){
- $a[$k] = "changed.$k";
- echo "After changing \$a directly, \$v@$k is: $v\n";
-}
-//--- Expected output:
-//After changing $a directly, $v@0 is: changed.0
-//After changing $a directly, $v@1 is: changed.1
-//After changing $a directly, $v@2 is: changed.2
-//--- Actual output from php.net before 5.2.2:
-//After changing $a directly, $v@0 is: changed.0
-//After changing $a directly, $v@1 is: original.1
-//After changing $a directly, $v@2 is: original.2
-
-?>
---EXPECT--
-After changing $a directly, $v@0 is: changed.0
-After changing $a directly, $v@1 is: changed.1
-After changing $a directly, $v@2 is: changed.2
+--TEST-- +Foreach loop tests - modifying the array during the loop: special case. Behaviour is good since php 5.2.2. +--FILE-- +<?php +$a = array("original.0","original.1","original.2"); +foreach ($a as $k=>&$v){ + $a[$k] = "changed.$k"; + echo "After changing \$a directly, \$v@$k is: $v\n"; +} +//--- Expected output: +//After changing $a directly, $v@0 is: changed.0 +//After changing $a directly, $v@1 is: changed.1 +//After changing $a directly, $v@2 is: changed.2 +//--- Actual output from php.net before 5.2.2: +//After changing $a directly, $v@0 is: changed.0 +//After changing $a directly, $v@1 is: original.1 +//After changing $a directly, $v@2 is: original.2 + +?> +--EXPECT-- +After changing $a directly, $v@0 is: changed.0 +After changing $a directly, $v@1 is: changed.1 +After changing $a directly, $v@2 is: changed.2 diff --git a/tests/lang/foreachLoop.006.phpt b/tests/lang/foreachLoop.006.phpt index d31ea64563..f7563dccd0 100644 --- a/tests/lang/foreachLoop.006.phpt +++ b/tests/lang/foreachLoop.006.phpt @@ -1,11 +1,11 @@ ---TEST--
-Foreach loop tests - error case: key is a reference.
---FILE--
-<?php
-$a = array("a","b","c");
-foreach ($a as &$k=>$v) {
- var_dump($v);
-}
-?>
---EXPECTF--
+--TEST-- +Foreach loop tests - error case: key is a reference. +--FILE-- +<?php +$a = array("a","b","c"); +foreach ($a as &$k=>$v) { + var_dump($v); +} +?> +--EXPECTF-- Fatal error: Key element cannot be a reference in %s on line 3 diff --git a/tests/lang/foreachLoop.009.phpt b/tests/lang/foreachLoop.009.phpt index df51fd6be4..90aa33953b 100644 --- a/tests/lang/foreachLoop.009.phpt +++ b/tests/lang/foreachLoop.009.phpt @@ -1,78 +1,78 @@ ---TEST--
-Foreach loop tests - foreach operates on the original array if the array is referenced outside the loop.
---FILE--
-<?php
-// From php.net/foreach:
-// "Unless the array is referenced, foreach operates on a copy of the specified array."
-
-echo "\nRemove elements from a referenced array during loop\n";
-$refedArray=array("original.0", "original.1", "original.2");
-$ref=&$refedArray;
-foreach ($refedArray as $k=>$v1) {
- array_pop($refedArray);
- echo "key: $k; value: $v1\n";
-}
-
-echo "\nRemove elements from a referenced array during loop, using &\$value\n";
-$refedArray=array("original.0", "original.1", "original.2");
-$ref=&$refedArray;
-foreach ($refedArray as $k=>&$v2) {
- array_pop($refedArray);
- echo "key: $k; value: $v2\n";
-}
-
-echo "\nAdd elements to a referenced array during loop\n";
-$refedArray=array("original.0", "original.1", "original.2");
-$ref=&$refedArray;
-$count=0;
-foreach ($refedArray as $k=>$v3) {
- array_push($refedArray, "new.$k");
- echo "key: $k; value: $v3\n";
-
- if ($count++>5) {
- echo "Loop detected, as expected.\n";
- break;
- }
-}
-
-echo "\nAdd elements to a referenced array during loop, using &\$value\n";
-$refedArray=array("original.0", "original.1", "original.2");
-$ref=&$refedArray;
-$count=0;
-foreach ($refedArray as $k=>&$v4) {
- array_push($refedArray, "new.$k");
- echo "key: $k; value: $v4\n";
-
- if ($count++>5) {
- echo "Loop detected, as expected.\n";
- break;
- }
-}
-
-?>
---EXPECT--
-
-Remove elements from a referenced array during loop
-key: 0; value: original.0
-key: 1; value: original.1
-key: 2; value: original.2
-
-Remove elements from a referenced array during loop, using &$value
-key: 0; value: original.0
-key: 1; value: original.1
-
-Add elements to a referenced array during loop
-key: 0; value: original.0
-key: 1; value: original.1
-key: 2; value: original.2
-
-Add elements to a referenced array during loop, using &$value
-key: 0; value: original.0
-key: 1; value: original.1
-key: 2; value: original.2
-key: 3; value: new.0
-key: 4; value: new.1
-key: 5; value: new.2
-key: 6; value: new.3
-Loop detected, as expected.
-
+--TEST-- +Foreach loop tests - foreach operates on the original array if the array is referenced outside the loop. +--FILE-- +<?php +// From php.net/foreach: +// "Unless the array is referenced, foreach operates on a copy of the specified array." + +echo "\nRemove elements from a referenced array during loop\n"; +$refedArray=array("original.0", "original.1", "original.2"); +$ref=&$refedArray; +foreach ($refedArray as $k=>$v1) { + array_pop($refedArray); + echo "key: $k; value: $v1\n"; +} + +echo "\nRemove elements from a referenced array during loop, using &\$value\n"; +$refedArray=array("original.0", "original.1", "original.2"); +$ref=&$refedArray; +foreach ($refedArray as $k=>&$v2) { + array_pop($refedArray); + echo "key: $k; value: $v2\n"; +} + +echo "\nAdd elements to a referenced array during loop\n"; +$refedArray=array("original.0", "original.1", "original.2"); +$ref=&$refedArray; +$count=0; +foreach ($refedArray as $k=>$v3) { + array_push($refedArray, "new.$k"); + echo "key: $k; value: $v3\n"; + + if ($count++>5) { + echo "Loop detected, as expected.\n"; + break; + } +} + +echo "\nAdd elements to a referenced array during loop, using &\$value\n"; +$refedArray=array("original.0", "original.1", "original.2"); +$ref=&$refedArray; +$count=0; +foreach ($refedArray as $k=>&$v4) { + array_push($refedArray, "new.$k"); + echo "key: $k; value: $v4\n"; + + if ($count++>5) { + echo "Loop detected, as expected.\n"; + break; + } +} + +?> +--EXPECT-- + +Remove elements from a referenced array during loop +key: 0; value: original.0 +key: 1; value: original.1 +key: 2; value: original.2 + +Remove elements from a referenced array during loop, using &$value +key: 0; value: original.0 +key: 1; value: original.1 + +Add elements to a referenced array during loop +key: 0; value: original.0 +key: 1; value: original.1 +key: 2; value: original.2 + +Add elements to a referenced array during loop, using &$value +key: 0; value: original.0 +key: 1; value: original.1 +key: 2; value: original.2 +key: 3; value: new.0 +key: 4; value: new.1 +key: 5; value: new.2 +key: 6; value: new.3 +Loop detected, as expected. + diff --git a/tests/lang/foreachLoop.010.phpt b/tests/lang/foreachLoop.010.phpt index 31f6e8cc49..c021a80c39 100644 --- a/tests/lang/foreachLoop.010.phpt +++ b/tests/lang/foreachLoop.010.phpt @@ -1,40 +1,40 @@ ---TEST--
-This test illustrates the impact of invoking destructors when refcount is decremented to 0 on foreach.
-It will pass only if the 'contentious code' in PHPValue.decReferences() is enabled.
---FILE--
-<?php
-
-$a = array(1,2,3);
-$container = array(&$a);
-
-// From php.net:
-// "Unless the array is referenced, foreach operates on a copy of
-// the specified array and not the array itself."
-// At this point, the array $a is referenced.
-
-// The following line ensures $a is no longer references as a consequence
-// of running the 'destructor' on $container.
-$container = null;
-
-// At this point the array $a is no longer referenced, so foreach should operate on a copy of the array.
-// However, P8 does not invoke 'destructors' when refcount is decremented to 0.
-// Consequently, $a thinks it is still referenced, and foreach will operate on the array itself.
-// This provokes a difference in behaviour when changing the number of elements in the array while
-// iterating over it.
-
-$i=0;
-foreach ($a as $v) {
- array_push($a, 'new');
- var_dump($v);
-
- if (++$i>10) {
- echo "Infinite loop detected\n";
- break;
- }
-}
-
-?>
---EXPECTF--
-int(1)
-int(2)
+--TEST-- +This test illustrates the impact of invoking destructors when refcount is decremented to 0 on foreach. +It will pass only if the 'contentious code' in PHPValue.decReferences() is enabled. +--FILE-- +<?php + +$a = array(1,2,3); +$container = array(&$a); + +// From php.net: +// "Unless the array is referenced, foreach operates on a copy of +// the specified array and not the array itself." +// At this point, the array $a is referenced. + +// The following line ensures $a is no longer references as a consequence +// of running the 'destructor' on $container. +$container = null; + +// At this point the array $a is no longer referenced, so foreach should operate on a copy of the array. +// However, P8 does not invoke 'destructors' when refcount is decremented to 0. +// Consequently, $a thinks it is still referenced, and foreach will operate on the array itself. +// This provokes a difference in behaviour when changing the number of elements in the array while +// iterating over it. + +$i=0; +foreach ($a as $v) { + array_push($a, 'new'); + var_dump($v); + + if (++$i>10) { + echo "Infinite loop detected\n"; + break; + } +} + +?> +--EXPECTF-- +int(1) +int(2) int(3) diff --git a/tests/lang/foreachLoop.011.phpt b/tests/lang/foreachLoop.011.phpt index 8527a8833e..6ceebd8a50 100644 --- a/tests/lang/foreachLoop.011.phpt +++ b/tests/lang/foreachLoop.011.phpt @@ -1,33 +1,33 @@ ---TEST--
-Changing from an interable type to a non iterable type during the iteration
---FILE--
-<?php
-echo "\nChange from array to non iterable:\n";
-$a = array(1,2,3);
-$b=&$a;
-foreach ($a as $v) {
- var_dump($v);
- $b=1;
-}
-
-echo "\nChange from object to non iterable:\n";
-$a = new stdClass;
-$a->a=1;
-$a->b=2;
-$b=&$a;
-foreach ($a as $v) {
- var_dump($v);
- $b='x';
-}
-
-?>
---EXPECTF--
-
-Change from array to non iterable:
-int(1)
-int(2)
-int(3)
-
-Change from object to non iterable:
-int(1)
-int(2)
+--TEST-- +Changing from an interable type to a non iterable type during the iteration +--FILE-- +<?php +echo "\nChange from array to non iterable:\n"; +$a = array(1,2,3); +$b=&$a; +foreach ($a as $v) { + var_dump($v); + $b=1; +} + +echo "\nChange from object to non iterable:\n"; +$a = new stdClass; +$a->a=1; +$a->b=2; +$b=&$a; +foreach ($a as $v) { + var_dump($v); + $b='x'; +} + +?> +--EXPECTF-- + +Change from array to non iterable: +int(1) +int(2) +int(3) + +Change from object to non iterable: +int(1) +int(2) diff --git a/tests/lang/foreachLoop.012.phpt b/tests/lang/foreachLoop.012.phpt index 1165b74a58..3652a71aed 100644 --- a/tests/lang/foreachLoop.012.phpt +++ b/tests/lang/foreachLoop.012.phpt @@ -1,494 +1,494 @@ ---TEST--
-Directly modifying an unreferenced array when foreach'ing over it.
---FILE--
-<?php
-
-define('MAX_LOOPS',5);
-
-function withRefValue($elements, $transform) {
- echo "\n---( Array with $elements element(s): )---\n";
- //Build array:
- for ($i=0; $i<$elements; $i++) {
- $a[] = "v.$i";
- }
- $counter=0;
-
- echo "--> State of array before loop:\n";
- var_dump($a);
-
- echo "--> Do loop:\n";
- foreach ($a as $k=>$v) {
- echo " iteration $counter: \$k=$k; \$v=$v\n";
- eval($transform);
- $counter++;
- if ($counter>MAX_LOOPS) {
- echo " ** Stuck in a loop! **\n";
- break;
- }
- }
-
- echo "--> State of array after loop:\n";
- var_dump($a);
-}
-
-
-echo "\nPopping elements off end of an unreferenced array";
-$transform = 'array_pop($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nShift elements off start of an unreferenced array";
-$transform = 'array_shift($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nRemove current element of an unreferenced array";
-$transform = 'unset($a[$k]);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the end of an unreferenced array";
-$transform = 'array_push($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the start of an unreferenced array";
-$transform = 'array_unshift($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-?>
---EXPECTF--
-
-Popping elements off end of an unreferenced array
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Shift elements off start of an unreferenced array
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Remove current element of an unreferenced array
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Adding elements to the end of an unreferenced array
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(5) "new.0"
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(5) "new.1"
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(6) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- string(5) "new.2"
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(8) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
- [4]=>
- string(5) "new.0"
- [5]=>
- string(5) "new.1"
- [6]=>
- string(5) "new.2"
- [7]=>
- string(5) "new.3"
-}
-
-
-
-Adding elements to the start of an unreferenced array
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(5) "new.0"
- [1]=>
- string(3) "v.0"
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(6) {
- [0]=>
- string(5) "new.2"
- [1]=>
- string(5) "new.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(3) "v.0"
- [4]=>
- string(3) "v.1"
- [5]=>
- string(3) "v.2"
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(8) {
- [0]=>
- string(5) "new.3"
- [1]=>
- string(5) "new.2"
- [2]=>
- string(5) "new.1"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(3) "v.0"
- [5]=>
- string(3) "v.1"
- [6]=>
- string(3) "v.2"
- [7]=>
- string(3) "v.3"
-}
+--TEST-- +Directly modifying an unreferenced array when foreach'ing over it. +--FILE-- +<?php + +define('MAX_LOOPS',5); + +function withRefValue($elements, $transform) { + echo "\n---( Array with $elements element(s): )---\n"; + //Build array: + for ($i=0; $i<$elements; $i++) { + $a[] = "v.$i"; + } + $counter=0; + + echo "--> State of array before loop:\n"; + var_dump($a); + + echo "--> Do loop:\n"; + foreach ($a as $k=>$v) { + echo " iteration $counter: \$k=$k; \$v=$v\n"; + eval($transform); + $counter++; + if ($counter>MAX_LOOPS) { + echo " ** Stuck in a loop! **\n"; + break; + } + } + + echo "--> State of array after loop:\n"; + var_dump($a); +} + + +echo "\nPopping elements off end of an unreferenced array"; +$transform = 'array_pop($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nShift elements off start of an unreferenced array"; +$transform = 'array_shift($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nRemove current element of an unreferenced array"; +$transform = 'unset($a[$k]);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the end of an unreferenced array"; +$transform = 'array_push($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the start of an unreferenced array"; +$transform = 'array_unshift($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +?> +--EXPECTF-- + +Popping elements off end of an unreferenced array +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Shift elements off start of an unreferenced array +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Remove current element of an unreferenced array +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Adding elements to the end of an unreferenced array +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(5) "new.0" +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(5) "new.0" + [3]=> + string(5) "new.1" +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(6) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + string(5) "new.2" +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(8) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" + [4]=> + string(5) "new.0" + [5]=> + string(5) "new.1" + [6]=> + string(5) "new.2" + [7]=> + string(5) "new.3" +} + + + +Adding elements to the start of an unreferenced array +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(5) "new.0" + [1]=> + string(3) "v.0" +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(6) { + [0]=> + string(5) "new.2" + [1]=> + string(5) "new.1" + [2]=> + string(5) "new.0" + [3]=> + string(3) "v.0" + [4]=> + string(3) "v.1" + [5]=> + string(3) "v.2" +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(8) { + [0]=> + string(5) "new.3" + [1]=> + string(5) "new.2" + [2]=> + string(5) "new.1" + [3]=> + string(5) "new.0" + [4]=> + string(3) "v.0" + [5]=> + string(3) "v.1" + [6]=> + string(3) "v.2" + [7]=> + string(3) "v.3" +} diff --git a/tests/lang/foreachLoop.013.phpt b/tests/lang/foreachLoop.013.phpt index ea728156f0..ba1bc89628 100644 --- a/tests/lang/foreachLoop.013.phpt +++ b/tests/lang/foreachLoop.013.phpt @@ -1,535 +1,535 @@ ---TEST--
-Directly modifying an unreferenced array when foreach'ing over it while using &$value syntax.
---FILE--
-<?php
-
-define('MAX_LOOPS',5);
-
-function withRefValue($elements, $transform) {
- echo "\n---( Array with $elements element(s): )---\n";
- //Build array:
- for ($i=0; $i<$elements; $i++) {
- $a[] = "v.$i";
- }
- $counter=0;
-
- echo "--> State of array before loop:\n";
- var_dump($a);
-
- echo "--> Do loop:\n";
- foreach ($a as $k=>&$v) {
- echo " iteration $counter: \$k=$k; \$v=$v\n";
- eval($transform);
- $counter++;
- if ($counter>MAX_LOOPS) {
- echo " ** Stuck in a loop! **\n";
- break;
- }
- }
-
- echo "--> State of array after loop:\n";
- var_dump($a);
-}
-
-
-echo "\nPopping elements off end of an unreferenced array, using &\$value.";
-$transform = 'array_pop($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nShift elements off start of an unreferenced array, using &\$value.";
-$transform = 'array_shift($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nRemove current element of an unreferenced array, using &\$value.";
-$transform = 'unset($a[$k]);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the end of an unreferenced array, using &\$value.";
-$transform = 'array_push($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the start of an unreferenced array, using &\$value.";
-$transform = 'array_unshift($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-?>
---EXPECT--
-
-Popping elements off end of an unreferenced array, using &$value.
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(1) {
- [0]=>
- &string(3) "v.0"
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- &string(3) "v.1"
-}
-
-
-
-Shift elements off start of an unreferenced array, using &$value.
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
- iteration 2: $k=0; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
- iteration 2: $k=0; $v=v.2
- iteration 3: $k=0; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Remove current element of an unreferenced array, using &$value.
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Adding elements to the end of an unreferenced array, using &$value.
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=new.0
- iteration 2: $k=2; $v=new.1
- iteration 3: $k=3; $v=new.2
- iteration 4: $k=4; $v=new.3
- iteration 5: $k=5; $v=new.4
- ** Stuck in a loop! **
---> State of array after loop:
-array(7) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(5) "new.1"
- [3]=>
- string(5) "new.2"
- [4]=>
- string(5) "new.3"
- [5]=>
- &string(5) "new.4"
- [6]=>
- string(5) "new.5"
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=new.0
- iteration 3: $k=3; $v=new.1
- iteration 4: $k=4; $v=new.2
- iteration 5: $k=5; $v=new.3
- ** Stuck in a loop! **
---> State of array after loop:
-array(8) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(5) "new.1"
- [4]=>
- string(5) "new.2"
- [5]=>
- &string(5) "new.3"
- [6]=>
- string(5) "new.4"
- [7]=>
- string(5) "new.5"
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=new.0
- iteration 4: $k=4; $v=new.1
- iteration 5: $k=5; $v=new.2
- ** Stuck in a loop! **
---> State of array after loop:
-array(9) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- &string(5) "new.2"
- [6]=>
- string(5) "new.3"
- [7]=>
- string(5) "new.4"
- [8]=>
- string(5) "new.5"
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
- iteration 4: $k=4; $v=new.0
- iteration 5: $k=5; $v=new.1
- ** Stuck in a loop! **
---> State of array after loop:
-array(10) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
- [4]=>
- string(5) "new.0"
- [5]=>
- &string(5) "new.1"
- [6]=>
- string(5) "new.2"
- [7]=>
- string(5) "new.3"
- [8]=>
- string(5) "new.4"
- [9]=>
- string(5) "new.5"
-}
-
-
-
-Adding elements to the start of an unreferenced array, using &$value.
----( Array with 1 element(s): )---
---> State of array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(5) "new.0"
- [1]=>
- &string(3) "v.0"
-}
-
----( Array with 2 element(s): )---
---> State of array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=2; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- &string(3) "v.1"
-}
-
----( Array with 3 element(s): )---
---> State of array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=3; $v=v.2
---> State of array after loop:
-array(5) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
- [4]=>
- &string(3) "v.2"
-}
-
----( Array with 4 element(s): )---
---> State of array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=4; $v=v.3
---> State of array after loop:
-array(6) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
- [4]=>
- string(3) "v.2"
- [5]=>
- &string(3) "v.3"
-}
+--TEST-- +Directly modifying an unreferenced array when foreach'ing over it while using &$value syntax. +--FILE-- +<?php + +define('MAX_LOOPS',5); + +function withRefValue($elements, $transform) { + echo "\n---( Array with $elements element(s): )---\n"; + //Build array: + for ($i=0; $i<$elements; $i++) { + $a[] = "v.$i"; + } + $counter=0; + + echo "--> State of array before loop:\n"; + var_dump($a); + + echo "--> Do loop:\n"; + foreach ($a as $k=>&$v) { + echo " iteration $counter: \$k=$k; \$v=$v\n"; + eval($transform); + $counter++; + if ($counter>MAX_LOOPS) { + echo " ** Stuck in a loop! **\n"; + break; + } + } + + echo "--> State of array after loop:\n"; + var_dump($a); +} + + +echo "\nPopping elements off end of an unreferenced array, using &\$value."; +$transform = 'array_pop($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nShift elements off start of an unreferenced array, using &\$value."; +$transform = 'array_shift($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nRemove current element of an unreferenced array, using &\$value."; +$transform = 'unset($a[$k]);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the end of an unreferenced array, using &\$value."; +$transform = 'array_push($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the start of an unreferenced array, using &\$value."; +$transform = 'array_unshift($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +?> +--EXPECT-- + +Popping elements off end of an unreferenced array, using &$value. +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(1) { + [0]=> + &string(3) "v.0" +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(1) { + [0]=> + string(3) "v.0" +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + &string(3) "v.1" +} + + + +Shift elements off start of an unreferenced array, using &$value. +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 + iteration 2: $k=0; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 + iteration 2: $k=0; $v=v.2 + iteration 3: $k=0; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Remove current element of an unreferenced array, using &$value. +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Adding elements to the end of an unreferenced array, using &$value. +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=new.0 + iteration 2: $k=2; $v=new.1 + iteration 3: $k=3; $v=new.2 + iteration 4: $k=4; $v=new.3 + iteration 5: $k=5; $v=new.4 + ** Stuck in a loop! ** +--> State of array after loop: +array(7) { + [0]=> + string(3) "v.0" + [1]=> + string(5) "new.0" + [2]=> + string(5) "new.1" + [3]=> + string(5) "new.2" + [4]=> + string(5) "new.3" + [5]=> + &string(5) "new.4" + [6]=> + string(5) "new.5" +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=new.0 + iteration 3: $k=3; $v=new.1 + iteration 4: $k=4; $v=new.2 + iteration 5: $k=5; $v=new.3 + ** Stuck in a loop! ** +--> State of array after loop: +array(8) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(5) "new.0" + [3]=> + string(5) "new.1" + [4]=> + string(5) "new.2" + [5]=> + &string(5) "new.3" + [6]=> + string(5) "new.4" + [7]=> + string(5) "new.5" +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=new.0 + iteration 4: $k=4; $v=new.1 + iteration 5: $k=5; $v=new.2 + ** Stuck in a loop! ** +--> State of array after loop: +array(9) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + &string(5) "new.2" + [6]=> + string(5) "new.3" + [7]=> + string(5) "new.4" + [8]=> + string(5) "new.5" +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 + iteration 4: $k=4; $v=new.0 + iteration 5: $k=5; $v=new.1 + ** Stuck in a loop! ** +--> State of array after loop: +array(10) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" + [4]=> + string(5) "new.0" + [5]=> + &string(5) "new.1" + [6]=> + string(5) "new.2" + [7]=> + string(5) "new.3" + [8]=> + string(5) "new.4" + [9]=> + string(5) "new.5" +} + + + +Adding elements to the start of an unreferenced array, using &$value. +---( Array with 1 element(s): )--- +--> State of array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(5) "new.0" + [1]=> + &string(3) "v.0" +} + +---( Array with 2 element(s): )--- +--> State of array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=2; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + &string(3) "v.1" +} + +---( Array with 3 element(s): )--- +--> State of array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=3; $v=v.2 +--> State of array after loop: +array(5) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" + [4]=> + &string(3) "v.2" +} + +---( Array with 4 element(s): )--- +--> State of array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=4; $v=v.3 +--> State of array after loop: +array(6) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" + [4]=> + string(3) "v.2" + [5]=> + &string(3) "v.3" +} diff --git a/tests/lang/foreachLoop.014.phpt b/tests/lang/foreachLoop.014.phpt index 9b179ab22a..770ee9f92e 100644 --- a/tests/lang/foreachLoop.014.phpt +++ b/tests/lang/foreachLoop.014.phpt @@ -1,495 +1,495 @@ ---TEST--
-Directly modifying a REFERENCED array when foreach'ing over it.
---FILE--
-<?php
-
-define('MAX_LOOPS',5);
-
-function withRefValue($elements, $transform) {
- echo "\n---( Array with $elements element(s): )---\n";
- //Build array:
- for ($i=0; $i<$elements; $i++) {
- $a[] = "v.$i";
- }
- $counter=0;
-
- $ref = &$a;
-
- echo "--> State of referenced array before loop:\n";
- var_dump($a);
-
- echo "--> Do loop:\n";
- foreach ($a as $k=>$v) {
- echo " iteration $counter: \$k=$k; \$v=$v\n";
- eval($transform);
- $counter++;
- if ($counter>MAX_LOOPS) {
- echo " ** Stuck in a loop! **\n";
- break;
- }
- }
-
- echo "--> State of array after loop:\n";
- var_dump($a);
-}
-
-
-echo "\nPopping elements off end of a referenced array";
-$transform = 'array_pop($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nShift elements off start of a referenced array";
-$transform = 'array_shift($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nRemove current element of a referenced array";
-$transform = 'unset($a[$k]);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the end of a referenced array";
-$transform = 'array_push($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the start of a referenced array";
-$transform = 'array_unshift($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-?>
---EXPECTF--
-Popping elements off end of a referenced array
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Shift elements off start of a referenced array
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Remove current element of a referenced array
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Adding elements to the end of a referenced array
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(5) "new.0"
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(5) "new.1"
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(6) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- string(5) "new.2"
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(8) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
- [4]=>
- string(5) "new.0"
- [5]=>
- string(5) "new.1"
- [6]=>
- string(5) "new.2"
- [7]=>
- string(5) "new.3"
-}
-
-
-
-Adding elements to the start of a referenced array
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(5) "new.0"
- [1]=>
- string(3) "v.0"
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(6) {
- [0]=>
- string(5) "new.2"
- [1]=>
- string(5) "new.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(3) "v.0"
- [4]=>
- string(3) "v.1"
- [5]=>
- string(3) "v.2"
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(8) {
- [0]=>
- string(5) "new.3"
- [1]=>
- string(5) "new.2"
- [2]=>
- string(5) "new.1"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(3) "v.0"
- [5]=>
- string(3) "v.1"
- [6]=>
- string(3) "v.2"
- [7]=>
- string(3) "v.3"
-}
+--TEST-- +Directly modifying a REFERENCED array when foreach'ing over it. +--FILE-- +<?php + +define('MAX_LOOPS',5); + +function withRefValue($elements, $transform) { + echo "\n---( Array with $elements element(s): )---\n"; + //Build array: + for ($i=0; $i<$elements; $i++) { + $a[] = "v.$i"; + } + $counter=0; + + $ref = &$a; + + echo "--> State of referenced array before loop:\n"; + var_dump($a); + + echo "--> Do loop:\n"; + foreach ($a as $k=>$v) { + echo " iteration $counter: \$k=$k; \$v=$v\n"; + eval($transform); + $counter++; + if ($counter>MAX_LOOPS) { + echo " ** Stuck in a loop! **\n"; + break; + } + } + + echo "--> State of array after loop:\n"; + var_dump($a); +} + + +echo "\nPopping elements off end of a referenced array"; +$transform = 'array_pop($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nShift elements off start of a referenced array"; +$transform = 'array_shift($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nRemove current element of a referenced array"; +$transform = 'unset($a[$k]);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the end of a referenced array"; +$transform = 'array_push($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the start of a referenced array"; +$transform = 'array_unshift($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +?> +--EXPECTF-- +Popping elements off end of a referenced array +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Shift elements off start of a referenced array +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Remove current element of a referenced array +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Adding elements to the end of a referenced array +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(5) "new.0" +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(5) "new.0" + [3]=> + string(5) "new.1" +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(6) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + string(5) "new.2" +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(8) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" + [4]=> + string(5) "new.0" + [5]=> + string(5) "new.1" + [6]=> + string(5) "new.2" + [7]=> + string(5) "new.3" +} + + + +Adding elements to the start of a referenced array +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(5) "new.0" + [1]=> + string(3) "v.0" +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(6) { + [0]=> + string(5) "new.2" + [1]=> + string(5) "new.1" + [2]=> + string(5) "new.0" + [3]=> + string(3) "v.0" + [4]=> + string(3) "v.1" + [5]=> + string(3) "v.2" +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(8) { + [0]=> + string(5) "new.3" + [1]=> + string(5) "new.2" + [2]=> + string(5) "new.1" + [3]=> + string(5) "new.0" + [4]=> + string(3) "v.0" + [5]=> + string(3) "v.1" + [6]=> + string(3) "v.2" + [7]=> + string(3) "v.3" +} diff --git a/tests/lang/foreachLoop.015.phpt b/tests/lang/foreachLoop.015.phpt index a4ee09d6a9..f7f5389395 100644 --- a/tests/lang/foreachLoop.015.phpt +++ b/tests/lang/foreachLoop.015.phpt @@ -1,537 +1,537 @@ ---TEST--
-Directly modifying a REFERENCED array when foreach'ing over it while using &$value syntax.
---FILE--
-<?php
-
-define('MAX_LOOPS',5);
-
-function withRefValue($elements, $transform) {
- echo "\n---( Array with $elements element(s): )---\n";
- //Build array:
- for ($i=0; $i<$elements; $i++) {
- $a[] = "v.$i";
- }
- $counter=0;
-
- $ref = &$a;
-
- echo "--> State of referenced array before loop:\n";
- var_dump($a);
-
- echo "--> Do loop:\n";
- foreach ($a as $k=>&$v) {
- echo " iteration $counter: \$k=$k; \$v=$v\n";
- eval($transform);
- $counter++;
- if ($counter>MAX_LOOPS) {
- echo " ** Stuck in a loop! **\n";
- break;
- }
- }
-
- echo "--> State of array after loop:\n";
- var_dump($a);
-}
-
-
-echo "\nPopping elements off end of a referenced array, using &\$value";
-$transform = 'array_pop($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nShift elements off start of a referenced array, using &\$value";
-$transform = 'array_shift($a);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nRemove current element of a referenced array, using &\$value";
-$transform = 'unset($a[$k]);';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the end of a referenced array, using &\$value";
-$transform = 'array_push($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-echo "\n\n\nAdding elements to the start of a referenced array, using &\$value";
-$transform = 'array_unshift($a, "new.$counter");';
-withRefValue(1, $transform);
-withRefValue(2, $transform);
-withRefValue(3, $transform);
-withRefValue(4, $transform);
-
-?>
---EXPECT--
-
-Popping elements off end of a referenced array, using &$value
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(1) {
- [0]=>
- &string(3) "v.0"
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- &string(3) "v.1"
-}
-
-
-
-Shift elements off start of a referenced array, using &$value
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
- iteration 2: $k=0; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=0; $v=v.1
- iteration 2: $k=0; $v=v.2
- iteration 3: $k=0; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Remove current element of a referenced array, using &$value
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(0) {
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
---> State of array after loop:
-array(0) {
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
---> State of array after loop:
-array(0) {
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
---> State of array after loop:
-array(0) {
-}
-
-
-
-Adding elements to the end of a referenced array, using &$value
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=new.0
- iteration 2: $k=2; $v=new.1
- iteration 3: $k=3; $v=new.2
- iteration 4: $k=4; $v=new.3
- iteration 5: $k=5; $v=new.4
- ** Stuck in a loop! **
---> State of array after loop:
-array(7) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(5) "new.1"
- [3]=>
- string(5) "new.2"
- [4]=>
- string(5) "new.3"
- [5]=>
- &string(5) "new.4"
- [6]=>
- string(5) "new.5"
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=new.0
- iteration 3: $k=3; $v=new.1
- iteration 4: $k=4; $v=new.2
- iteration 5: $k=5; $v=new.3
- ** Stuck in a loop! **
---> State of array after loop:
-array(8) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(5) "new.0"
- [3]=>
- string(5) "new.1"
- [4]=>
- string(5) "new.2"
- [5]=>
- &string(5) "new.3"
- [6]=>
- string(5) "new.4"
- [7]=>
- string(5) "new.5"
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=new.0
- iteration 4: $k=4; $v=new.1
- iteration 5: $k=5; $v=new.2
- ** Stuck in a loop! **
---> State of array after loop:
-array(9) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(5) "new.0"
- [4]=>
- string(5) "new.1"
- [5]=>
- &string(5) "new.2"
- [6]=>
- string(5) "new.3"
- [7]=>
- string(5) "new.4"
- [8]=>
- string(5) "new.5"
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=1; $v=v.1
- iteration 2: $k=2; $v=v.2
- iteration 3: $k=3; $v=v.3
- iteration 4: $k=4; $v=new.0
- iteration 5: $k=5; $v=new.1
- ** Stuck in a loop! **
---> State of array after loop:
-array(10) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
- [4]=>
- string(5) "new.0"
- [5]=>
- &string(5) "new.1"
- [6]=>
- string(5) "new.2"
- [7]=>
- string(5) "new.3"
- [8]=>
- string(5) "new.4"
- [9]=>
- string(5) "new.5"
-}
-
-
-
-Adding elements to the start of a referenced array, using &$value
----( Array with 1 element(s): )---
---> State of referenced array before loop:
-array(1) {
- [0]=>
- string(3) "v.0"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
---> State of array after loop:
-array(2) {
- [0]=>
- string(5) "new.0"
- [1]=>
- &string(3) "v.0"
-}
-
----( Array with 2 element(s): )---
---> State of referenced array before loop:
-array(2) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=2; $v=v.1
---> State of array after loop:
-array(4) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- &string(3) "v.1"
-}
-
----( Array with 3 element(s): )---
---> State of referenced array before loop:
-array(3) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=3; $v=v.2
---> State of array after loop:
-array(5) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
- [4]=>
- &string(3) "v.2"
-}
-
----( Array with 4 element(s): )---
---> State of referenced array before loop:
-array(4) {
- [0]=>
- string(3) "v.0"
- [1]=>
- string(3) "v.1"
- [2]=>
- string(3) "v.2"
- [3]=>
- string(3) "v.3"
-}
---> Do loop:
- iteration 0: $k=0; $v=v.0
- iteration 1: $k=4; $v=v.3
---> State of array after loop:
-array(6) {
- [0]=>
- string(5) "new.1"
- [1]=>
- string(5) "new.0"
- [2]=>
- string(3) "v.0"
- [3]=>
- string(3) "v.1"
- [4]=>
- string(3) "v.2"
- [5]=>
- &string(3) "v.3"
-}
+--TEST-- +Directly modifying a REFERENCED array when foreach'ing over it while using &$value syntax. +--FILE-- +<?php + +define('MAX_LOOPS',5); + +function withRefValue($elements, $transform) { + echo "\n---( Array with $elements element(s): )---\n"; + //Build array: + for ($i=0; $i<$elements; $i++) { + $a[] = "v.$i"; + } + $counter=0; + + $ref = &$a; + + echo "--> State of referenced array before loop:\n"; + var_dump($a); + + echo "--> Do loop:\n"; + foreach ($a as $k=>&$v) { + echo " iteration $counter: \$k=$k; \$v=$v\n"; + eval($transform); + $counter++; + if ($counter>MAX_LOOPS) { + echo " ** Stuck in a loop! **\n"; + break; + } + } + + echo "--> State of array after loop:\n"; + var_dump($a); +} + + +echo "\nPopping elements off end of a referenced array, using &\$value"; +$transform = 'array_pop($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nShift elements off start of a referenced array, using &\$value"; +$transform = 'array_shift($a);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nRemove current element of a referenced array, using &\$value"; +$transform = 'unset($a[$k]);'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the end of a referenced array, using &\$value"; +$transform = 'array_push($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +echo "\n\n\nAdding elements to the start of a referenced array, using &\$value"; +$transform = 'array_unshift($a, "new.$counter");'; +withRefValue(1, $transform); +withRefValue(2, $transform); +withRefValue(3, $transform); +withRefValue(4, $transform); + +?> +--EXPECT-- + +Popping elements off end of a referenced array, using &$value +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(1) { + [0]=> + &string(3) "v.0" +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(1) { + [0]=> + string(3) "v.0" +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + &string(3) "v.1" +} + + + +Shift elements off start of a referenced array, using &$value +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 + iteration 2: $k=0; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=0; $v=v.1 + iteration 2: $k=0; $v=v.2 + iteration 3: $k=0; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Remove current element of a referenced array, using &$value +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(0) { +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 +--> State of array after loop: +array(0) { +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 +--> State of array after loop: +array(0) { +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 +--> State of array after loop: +array(0) { +} + + + +Adding elements to the end of a referenced array, using &$value +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=new.0 + iteration 2: $k=2; $v=new.1 + iteration 3: $k=3; $v=new.2 + iteration 4: $k=4; $v=new.3 + iteration 5: $k=5; $v=new.4 + ** Stuck in a loop! ** +--> State of array after loop: +array(7) { + [0]=> + string(3) "v.0" + [1]=> + string(5) "new.0" + [2]=> + string(5) "new.1" + [3]=> + string(5) "new.2" + [4]=> + string(5) "new.3" + [5]=> + &string(5) "new.4" + [6]=> + string(5) "new.5" +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=new.0 + iteration 3: $k=3; $v=new.1 + iteration 4: $k=4; $v=new.2 + iteration 5: $k=5; $v=new.3 + ** Stuck in a loop! ** +--> State of array after loop: +array(8) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(5) "new.0" + [3]=> + string(5) "new.1" + [4]=> + string(5) "new.2" + [5]=> + &string(5) "new.3" + [6]=> + string(5) "new.4" + [7]=> + string(5) "new.5" +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=new.0 + iteration 4: $k=4; $v=new.1 + iteration 5: $k=5; $v=new.2 + ** Stuck in a loop! ** +--> State of array after loop: +array(9) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(5) "new.0" + [4]=> + string(5) "new.1" + [5]=> + &string(5) "new.2" + [6]=> + string(5) "new.3" + [7]=> + string(5) "new.4" + [8]=> + string(5) "new.5" +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=1; $v=v.1 + iteration 2: $k=2; $v=v.2 + iteration 3: $k=3; $v=v.3 + iteration 4: $k=4; $v=new.0 + iteration 5: $k=5; $v=new.1 + ** Stuck in a loop! ** +--> State of array after loop: +array(10) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" + [4]=> + string(5) "new.0" + [5]=> + &string(5) "new.1" + [6]=> + string(5) "new.2" + [7]=> + string(5) "new.3" + [8]=> + string(5) "new.4" + [9]=> + string(5) "new.5" +} + + + +Adding elements to the start of a referenced array, using &$value +---( Array with 1 element(s): )--- +--> State of referenced array before loop: +array(1) { + [0]=> + string(3) "v.0" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 +--> State of array after loop: +array(2) { + [0]=> + string(5) "new.0" + [1]=> + &string(3) "v.0" +} + +---( Array with 2 element(s): )--- +--> State of referenced array before loop: +array(2) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=2; $v=v.1 +--> State of array after loop: +array(4) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + &string(3) "v.1" +} + +---( Array with 3 element(s): )--- +--> State of referenced array before loop: +array(3) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=3; $v=v.2 +--> State of array after loop: +array(5) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" + [4]=> + &string(3) "v.2" +} + +---( Array with 4 element(s): )--- +--> State of referenced array before loop: +array(4) { + [0]=> + string(3) "v.0" + [1]=> + string(3) "v.1" + [2]=> + string(3) "v.2" + [3]=> + string(3) "v.3" +} +--> Do loop: + iteration 0: $k=0; $v=v.0 + iteration 1: $k=4; $v=v.3 +--> State of array after loop: +array(6) { + [0]=> + string(5) "new.1" + [1]=> + string(5) "new.0" + [2]=> + string(3) "v.0" + [3]=> + string(3) "v.1" + [4]=> + string(3) "v.2" + [5]=> + &string(3) "v.3" +} diff --git a/tests/lang/foreachLoop.016.phpt b/tests/lang/foreachLoop.016.phpt index d570aba316..91c96f694d 100644 --- a/tests/lang/foreachLoop.016.phpt +++ b/tests/lang/foreachLoop.016.phpt @@ -1,206 +1,206 @@ ---TEST--
-Ensure foreach splits the iterated entity from its cow reference set, for all sorts of iterated entities.
---FILE--
-<?php
- error_reporting(E_ALL & ~E_STRICT);
-
- echo "\n" . '$a' . "\n";
- $b = $a = array('original');
- foreach($a as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '${\'a\'}' . "\n";
- $b = $a = array('original');
- foreach(${'a'} as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$$a' . "\n";
- $a = 'blah';
- $$a = array('original');
- $b = $$a;
- foreach($$a as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a[0]' . "\n";
- $b = $a[0] = array('original');
- foreach($a[0] as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a[0][0]' . "\n";
- $b = $a[0][0] = array('original');
- foreach($a[0][0] as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a->b' . "\n";
- $b = $a->b = array('original');
- foreach($a->b as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a->b->c' . "\n";
- $b = $a->b->c = array('original');
- foreach($a->b as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a->b[0]' . "\n";
- $b = $a->b[0] = array('original');
- foreach($a->b[0] as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a->b[0][0]' . "\n";
- $b = $a->b[0][0] = array('original');
- foreach($a->b[0][0] as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . '$a->b[0]->c' . "\n";
- $b = $a->b[0]->c = array('original');
- foreach($a->b[0]->c as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- class C {
- public static $a;
- }
-
- echo "\n" . 'C::$a' . "\n";
- C::$a = array('original');
- $b = C::$a;
- foreach(C::$a as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset($a, $b);
-
- echo "\n" . 'C::$a[0]' . "\n";
- C::$a[0] = array('original');
- $b = C::$a[0];
- foreach(C::$a[0] as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset(C::$a[0], $b);
-
- echo "\n" . 'C::$a[0]->b' . "\n";
- C::$a[0]->b = array('original');
- $b = C::$a[0]->b;
- foreach(C::$a[0]->b as $k=>&$v) {
- $v = 'changed';
- }
- var_dump($b);
- unset(C::$a[0]->b, $b);
-?>
---EXPECTF--
-
-$a
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-${'a'}
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$$a
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a[0]
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a[0][0]
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a->b
-
-Warning: Creating default object from empty value in %s on line %d
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a->b->c
-
-Warning: Creating default object from empty value in %s on line %d
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a->b[0]
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a->b[0][0]
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-$a->b[0]->c
-
-Warning: Creating default object from empty value in %s on line %d
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-C::$a
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-C::$a[0]
-array(1) {
- [0]=>
- string(8) "original"
-}
-
-C::$a[0]->b
-
-Warning: Creating default object from empty value in %s on line %d
-array(1) {
- [0]=>
- string(8) "original"
-}
+--TEST-- +Ensure foreach splits the iterated entity from its cow reference set, for all sorts of iterated entities. +--FILE-- +<?php + error_reporting(E_ALL & ~E_STRICT); + + echo "\n" . '$a' . "\n"; + $b = $a = array('original'); + foreach($a as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '${\'a\'}' . "\n"; + $b = $a = array('original'); + foreach(${'a'} as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$$a' . "\n"; + $a = 'blah'; + $$a = array('original'); + $b = $$a; + foreach($$a as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a[0]' . "\n"; + $b = $a[0] = array('original'); + foreach($a[0] as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a[0][0]' . "\n"; + $b = $a[0][0] = array('original'); + foreach($a[0][0] as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a->b' . "\n"; + $b = $a->b = array('original'); + foreach($a->b as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a->b->c' . "\n"; + $b = $a->b->c = array('original'); + foreach($a->b as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a->b[0]' . "\n"; + $b = $a->b[0] = array('original'); + foreach($a->b[0] as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a->b[0][0]' . "\n"; + $b = $a->b[0][0] = array('original'); + foreach($a->b[0][0] as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . '$a->b[0]->c' . "\n"; + $b = $a->b[0]->c = array('original'); + foreach($a->b[0]->c as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + class C { + public static $a; + } + + echo "\n" . 'C::$a' . "\n"; + C::$a = array('original'); + $b = C::$a; + foreach(C::$a as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset($a, $b); + + echo "\n" . 'C::$a[0]' . "\n"; + C::$a[0] = array('original'); + $b = C::$a[0]; + foreach(C::$a[0] as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset(C::$a[0], $b); + + echo "\n" . 'C::$a[0]->b' . "\n"; + C::$a[0]->b = array('original'); + $b = C::$a[0]->b; + foreach(C::$a[0]->b as $k=>&$v) { + $v = 'changed'; + } + var_dump($b); + unset(C::$a[0]->b, $b); +?> +--EXPECTF-- + +$a +array(1) { + [0]=> + string(8) "original" +} + +${'a'} +array(1) { + [0]=> + string(8) "original" +} + +$$a +array(1) { + [0]=> + string(8) "original" +} + +$a[0] +array(1) { + [0]=> + string(8) "original" +} + +$a[0][0] +array(1) { + [0]=> + string(8) "original" +} + +$a->b + +Warning: Creating default object from empty value in %s on line %d +array(1) { + [0]=> + string(8) "original" +} + +$a->b->c + +Warning: Creating default object from empty value in %s on line %d +array(1) { + [0]=> + string(8) "original" +} + +$a->b[0] +array(1) { + [0]=> + string(8) "original" +} + +$a->b[0][0] +array(1) { + [0]=> + string(8) "original" +} + +$a->b[0]->c + +Warning: Creating default object from empty value in %s on line %d +array(1) { + [0]=> + string(8) "original" +} + +C::$a +array(1) { + [0]=> + string(8) "original" +} + +C::$a[0] +array(1) { + [0]=> + string(8) "original" +} + +C::$a[0]->b + +Warning: Creating default object from empty value in %s on line %d +array(1) { + [0]=> + string(8) "original" +} diff --git a/tests/lang/foreachLoop.017.phpt b/tests/lang/foreachLoop.017.phpt index 4c3a1f6c3e..987fe3cb27 100644 --- a/tests/lang/foreachLoop.017.phpt +++ b/tests/lang/foreachLoop.017.phpt @@ -1,11 +1,11 @@ ---TEST--
-Ensure foreach works with arrays with Binary keys.
---FILE--
-<?php
-$a = array ( "\x90" => 10 );
-foreach ($a as $val=>$key) echo $key;
-echo "\nDone\n";
-?>
---EXPECTF--
-10
+--TEST-- +Ensure foreach works with arrays with Binary keys. +--FILE-- +<?php +$a = array ( "\x90" => 10 ); +foreach ($a as $val=>$key) echo $key; +echo "\nDone\n"; +?> +--EXPECTF-- +10 Done diff --git a/tests/lang/operators/add_basiclong_64bit.phpt b/tests/lang/operators/add_basiclong_64bit.phpt index cae8f4f1fb..eb55d5f210 100644 --- a/tests/lang/operators/add_basiclong_64bit.phpt +++ b/tests/lang/operators/add_basiclong_64bit.phpt @@ -1,44 +1,44 @@ ---TEST--
-Test + operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
-
-error_reporting(E_ERROR);
-
-foreach ($longVals as $longVal) {
- foreach($otherVals as $otherVal) {
- echo "--- testing: $longVal + $otherVal ---\n";
- var_dump($longVal+$otherVal);
- }
-}
-
-foreach ($otherVals as $otherVal) {
- foreach($longVals as $longVal) {
- echo "--- testing: $otherVal + $longVal ---\n";
- var_dump($otherVal+$longVal);
- }
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test + operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + +$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); + +error_reporting(E_ERROR); + +foreach ($longVals as $longVal) { + foreach($otherVals as $otherVal) { + echo "--- testing: $longVal + $otherVal ---\n"; + var_dump($longVal+$otherVal); + } +} + +foreach ($otherVals as $otherVal) { + foreach($longVals as $longVal) { + echo "--- testing: $otherVal + $longVal ---\n"; + var_dump($otherVal+$longVal); + } +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 + 0 --- int(9223372036854775807) --- testing: 9223372036854775807 + 1 --- @@ -578,5 +578,5 @@ float(1.844674407371E+19) --- testing: 9223372036854775807 + -9223372036854775807 --- int(0) --- testing: 9223372036854775807 + -9.2233720368548E+18 --- -float(0)
-===DONE===
+float(0) +===DONE=== diff --git a/tests/lang/operators/add_variationStr.phpt b/tests/lang/operators/add_variationStr.phpt index 264c5c1bb9..9bf11ec698 100644 --- a/tests/lang/operators/add_variationStr.phpt +++ b/tests/lang/operators/add_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test + operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' + '$otherVal' ---\n";
- var_dump($strVal+$otherVal);
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test + operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' + '$otherVal' ---\n"; + var_dump($strVal+$otherVal); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' + '0' --- int(0) --- testing: '0' + '65' --- @@ -412,5 +412,5 @@ int(123) --- testing: 'a5.9' + '3.4a' --- float(3.4) --- testing: 'a5.9' + 'a5.9' --- -int(0)
-===DONE===
+int(0) +===DONE=== diff --git a/tests/lang/operators/bitwiseAnd_variationStr.phpt b/tests/lang/operators/bitwiseAnd_variationStr.phpt index 26022705fc..5b7cb10b12 100644 --- a/tests/lang/operators/bitwiseAnd_variationStr.phpt +++ b/tests/lang/operators/bitwiseAnd_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test & operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' & '$otherVal' ---\n";
- var_dump(bin2hex($strVal&$otherVal));
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test & operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' & '$otherVal' ---\n"; + var_dump(bin2hex($strVal&$otherVal)); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' & '0' --- string(2) "30" --- testing: '0' & '65' --- @@ -412,5 +412,5 @@ string(8) "21302221" --- testing: 'a5.9' & '3.4a' --- string(8) "21242421" --- testing: 'a5.9' & 'a5.9' --- -string(8) "61352e39"
-===DONE===
+string(8) "61352e39" +===DONE=== diff --git a/tests/lang/operators/bitwiseNot_variationStr.phpt b/tests/lang/operators/bitwiseNot_variationStr.phpt index 3e7b698680..98bca9e473 100644 --- a/tests/lang/operators/bitwiseNot_variationStr.phpt +++ b/tests/lang/operators/bitwiseNot_variationStr.phpt @@ -1,22 +1,22 @@ ---TEST--
-Test ~N operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-
-foreach ($strVals as $strVal) {
- echo "--- testing: '$strVal' ---\n";
- var_dump(bin2hex(~$strVal));
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test ~N operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + + +foreach ($strVals as $strVal) { + echo "--- testing: '$strVal' ---\n"; + var_dump(bin2hex(~$strVal)); +} + +?> +===DONE=== +--EXPECT-- --- testing: '0' --- string(2) "cf" --- testing: '65' --- @@ -44,5 +44,5 @@ string(14) "cecdcc9e9d9cdf" --- testing: '3.4a' --- string(8) "ccd1cb9e" --- testing: 'a5.9' --- -string(8) "9ecad1c6"
-===DONE===
+string(8) "9ecad1c6" +===DONE=== diff --git a/tests/lang/operators/bitwiseOr_variationStr.phpt b/tests/lang/operators/bitwiseOr_variationStr.phpt index 6c31477884..2d1d353788 100644 --- a/tests/lang/operators/bitwiseOr_variationStr.phpt +++ b/tests/lang/operators/bitwiseOr_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test | operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' | '$otherVal' ---\n";
- var_dump(bin2hex($strVal|$otherVal));
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test | operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' | '$otherVal' ---\n"; + var_dump(bin2hex($strVal|$otherVal)); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' | '0' --- string(2) "30" --- testing: '0' | '65' --- @@ -412,5 +412,5 @@ string(14) "71373f79626320" --- testing: 'a5.9' | '3.4a' --- string(8) "733f3e79" --- testing: 'a5.9' | 'a5.9' --- -string(8) "61352e39"
-===DONE===
+string(8) "61352e39" +===DONE=== diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt index 69fd90f1c8..ddfd2f7c6d 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt @@ -1,424 +1,424 @@ ---TEST--
-Test << operator : various numbers as strings
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' << '$otherVal' ---\n";
- try {
- var_dump($strVal<<$otherVal);
- } catch (ArithmeticError $e) {
- echo "Exception: " . $e->getMessage() . "\n";
- }
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
---- testing: '0' << '0' ---
-int(0)
---- testing: '0' << '65' ---
-int(0)
---- testing: '0' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '0' << '1.2' ---
-int(0)
---- testing: '0' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '0' << 'abc' ---
-int(0)
---- testing: '0' << '123abc' ---
-int(0)
---- testing: '0' << '123e5' ---
-int(0)
---- testing: '0' << '123e5xyz' ---
-int(0)
---- testing: '0' << ' 123abc' ---
-int(0)
---- testing: '0' << '123 abc' ---
-int(0)
---- testing: '0' << '123abc ' ---
-int(0)
---- testing: '0' << '3.4a' ---
-int(0)
---- testing: '0' << 'a5.9' ---
-int(0)
---- testing: '65' << '0' ---
-int(65)
---- testing: '65' << '65' ---
-int(0)
---- testing: '65' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '65' << '1.2' ---
-int(130)
---- testing: '65' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '65' << 'abc' ---
-int(65)
---- testing: '65' << '123abc' ---
-int(0)
---- testing: '65' << '123e5' ---
-int(0)
---- testing: '65' << '123e5xyz' ---
-int(0)
---- testing: '65' << ' 123abc' ---
-int(0)
---- testing: '65' << '123 abc' ---
-int(0)
---- testing: '65' << '123abc ' ---
-int(0)
---- testing: '65' << '3.4a' ---
-int(520)
---- testing: '65' << 'a5.9' ---
-int(65)
---- testing: '-44' << '0' ---
-int(-44)
---- testing: '-44' << '65' ---
-int(0)
---- testing: '-44' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '-44' << '1.2' ---
-int(-88)
---- testing: '-44' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '-44' << 'abc' ---
-int(-44)
---- testing: '-44' << '123abc' ---
-int(0)
---- testing: '-44' << '123e5' ---
-int(0)
---- testing: '-44' << '123e5xyz' ---
-int(0)
---- testing: '-44' << ' 123abc' ---
-int(0)
---- testing: '-44' << '123 abc' ---
-int(0)
---- testing: '-44' << '123abc ' ---
-int(0)
---- testing: '-44' << '3.4a' ---
-int(-352)
---- testing: '-44' << 'a5.9' ---
-int(-44)
---- testing: '1.2' << '0' ---
-int(1)
---- testing: '1.2' << '65' ---
-int(0)
---- testing: '1.2' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '1.2' << '1.2' ---
-int(2)
---- testing: '1.2' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '1.2' << 'abc' ---
-int(1)
---- testing: '1.2' << '123abc' ---
-int(0)
---- testing: '1.2' << '123e5' ---
-int(0)
---- testing: '1.2' << '123e5xyz' ---
-int(0)
---- testing: '1.2' << ' 123abc' ---
-int(0)
---- testing: '1.2' << '123 abc' ---
-int(0)
---- testing: '1.2' << '123abc ' ---
-int(0)
---- testing: '1.2' << '3.4a' ---
-int(8)
---- testing: '1.2' << 'a5.9' ---
-int(1)
---- testing: '-7.7' << '0' ---
-int(-7)
---- testing: '-7.7' << '65' ---
-int(0)
---- testing: '-7.7' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '-7.7' << '1.2' ---
-int(-14)
---- testing: '-7.7' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '-7.7' << 'abc' ---
-int(-7)
---- testing: '-7.7' << '123abc' ---
-int(0)
---- testing: '-7.7' << '123e5' ---
-int(0)
---- testing: '-7.7' << '123e5xyz' ---
-int(0)
---- testing: '-7.7' << ' 123abc' ---
-int(0)
---- testing: '-7.7' << '123 abc' ---
-int(0)
---- testing: '-7.7' << '123abc ' ---
-int(0)
---- testing: '-7.7' << '3.4a' ---
-int(-56)
---- testing: '-7.7' << 'a5.9' ---
-int(-7)
---- testing: 'abc' << '0' ---
-int(0)
---- testing: 'abc' << '65' ---
-int(0)
---- testing: 'abc' << '-44' ---
-Exception: Bit shift by negative number
---- testing: 'abc' << '1.2' ---
-int(0)
---- testing: 'abc' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: 'abc' << 'abc' ---
-int(0)
---- testing: 'abc' << '123abc' ---
-int(0)
---- testing: 'abc' << '123e5' ---
-int(0)
---- testing: 'abc' << '123e5xyz' ---
-int(0)
---- testing: 'abc' << ' 123abc' ---
-int(0)
---- testing: 'abc' << '123 abc' ---
-int(0)
---- testing: 'abc' << '123abc ' ---
-int(0)
---- testing: 'abc' << '3.4a' ---
-int(0)
---- testing: 'abc' << 'a5.9' ---
-int(0)
---- testing: '123abc' << '0' ---
-int(123)
---- testing: '123abc' << '65' ---
-int(0)
---- testing: '123abc' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '123abc' << '1.2' ---
-int(246)
---- testing: '123abc' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '123abc' << 'abc' ---
-int(123)
---- testing: '123abc' << '123abc' ---
-int(0)
---- testing: '123abc' << '123e5' ---
-int(0)
---- testing: '123abc' << '123e5xyz' ---
-int(0)
---- testing: '123abc' << ' 123abc' ---
-int(0)
---- testing: '123abc' << '123 abc' ---
-int(0)
---- testing: '123abc' << '123abc ' ---
-int(0)
---- testing: '123abc' << '3.4a' ---
-int(984)
---- testing: '123abc' << 'a5.9' ---
-int(123)
---- testing: '123e5' << '0' ---
-int(12300000)
---- testing: '123e5' << '65' ---
-int(0)
---- testing: '123e5' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '123e5' << '1.2' ---
-int(24600000)
---- testing: '123e5' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '123e5' << 'abc' ---
-int(12300000)
---- testing: '123e5' << '123abc' ---
-int(0)
---- testing: '123e5' << '123e5' ---
-int(0)
---- testing: '123e5' << '123e5xyz' ---
-int(0)
---- testing: '123e5' << ' 123abc' ---
-int(0)
---- testing: '123e5' << '123 abc' ---
-int(0)
---- testing: '123e5' << '123abc ' ---
-int(0)
---- testing: '123e5' << '3.4a' ---
-int(98400000)
---- testing: '123e5' << 'a5.9' ---
-int(12300000)
---- testing: '123e5xyz' << '0' ---
-int(12300000)
---- testing: '123e5xyz' << '65' ---
-int(0)
---- testing: '123e5xyz' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '123e5xyz' << '1.2' ---
-int(24600000)
---- testing: '123e5xyz' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '123e5xyz' << 'abc' ---
-int(12300000)
---- testing: '123e5xyz' << '123abc' ---
-int(0)
---- testing: '123e5xyz' << '123e5' ---
-int(0)
---- testing: '123e5xyz' << '123e5xyz' ---
-int(0)
---- testing: '123e5xyz' << ' 123abc' ---
-int(0)
---- testing: '123e5xyz' << '123 abc' ---
-int(0)
---- testing: '123e5xyz' << '123abc ' ---
-int(0)
---- testing: '123e5xyz' << '3.4a' ---
-int(98400000)
---- testing: '123e5xyz' << 'a5.9' ---
-int(12300000)
---- testing: ' 123abc' << '0' ---
-int(123)
---- testing: ' 123abc' << '65' ---
-int(0)
---- testing: ' 123abc' << '-44' ---
-Exception: Bit shift by negative number
---- testing: ' 123abc' << '1.2' ---
-int(246)
---- testing: ' 123abc' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: ' 123abc' << 'abc' ---
-int(123)
---- testing: ' 123abc' << '123abc' ---
-int(0)
---- testing: ' 123abc' << '123e5' ---
-int(0)
---- testing: ' 123abc' << '123e5xyz' ---
-int(0)
---- testing: ' 123abc' << ' 123abc' ---
-int(0)
---- testing: ' 123abc' << '123 abc' ---
-int(0)
---- testing: ' 123abc' << '123abc ' ---
-int(0)
---- testing: ' 123abc' << '3.4a' ---
-int(984)
---- testing: ' 123abc' << 'a5.9' ---
-int(123)
---- testing: '123 abc' << '0' ---
-int(123)
---- testing: '123 abc' << '65' ---
-int(0)
---- testing: '123 abc' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '123 abc' << '1.2' ---
-int(246)
---- testing: '123 abc' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '123 abc' << 'abc' ---
-int(123)
---- testing: '123 abc' << '123abc' ---
-int(0)
---- testing: '123 abc' << '123e5' ---
-int(0)
---- testing: '123 abc' << '123e5xyz' ---
-int(0)
---- testing: '123 abc' << ' 123abc' ---
-int(0)
---- testing: '123 abc' << '123 abc' ---
-int(0)
---- testing: '123 abc' << '123abc ' ---
-int(0)
---- testing: '123 abc' << '3.4a' ---
-int(984)
---- testing: '123 abc' << 'a5.9' ---
-int(123)
---- testing: '123abc ' << '0' ---
-int(123)
---- testing: '123abc ' << '65' ---
-int(0)
---- testing: '123abc ' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '123abc ' << '1.2' ---
-int(246)
---- testing: '123abc ' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '123abc ' << 'abc' ---
-int(123)
---- testing: '123abc ' << '123abc' ---
-int(0)
---- testing: '123abc ' << '123e5' ---
-int(0)
---- testing: '123abc ' << '123e5xyz' ---
-int(0)
---- testing: '123abc ' << ' 123abc' ---
-int(0)
---- testing: '123abc ' << '123 abc' ---
-int(0)
---- testing: '123abc ' << '123abc ' ---
-int(0)
---- testing: '123abc ' << '3.4a' ---
-int(984)
---- testing: '123abc ' << 'a5.9' ---
-int(123)
---- testing: '3.4a' << '0' ---
-int(3)
---- testing: '3.4a' << '65' ---
-int(0)
---- testing: '3.4a' << '-44' ---
-Exception: Bit shift by negative number
---- testing: '3.4a' << '1.2' ---
-int(6)
---- testing: '3.4a' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: '3.4a' << 'abc' ---
-int(3)
---- testing: '3.4a' << '123abc' ---
-int(0)
---- testing: '3.4a' << '123e5' ---
-int(0)
---- testing: '3.4a' << '123e5xyz' ---
-int(0)
---- testing: '3.4a' << ' 123abc' ---
-int(0)
---- testing: '3.4a' << '123 abc' ---
-int(0)
---- testing: '3.4a' << '123abc ' ---
-int(0)
---- testing: '3.4a' << '3.4a' ---
-int(24)
---- testing: '3.4a' << 'a5.9' ---
-int(3)
---- testing: 'a5.9' << '0' ---
-int(0)
---- testing: 'a5.9' << '65' ---
-int(0)
---- testing: 'a5.9' << '-44' ---
-Exception: Bit shift by negative number
---- testing: 'a5.9' << '1.2' ---
-int(0)
---- testing: 'a5.9' << '-7.7' ---
-Exception: Bit shift by negative number
---- testing: 'a5.9' << 'abc' ---
-int(0)
---- testing: 'a5.9' << '123abc' ---
-int(0)
---- testing: 'a5.9' << '123e5' ---
-int(0)
---- testing: 'a5.9' << '123e5xyz' ---
-int(0)
---- testing: 'a5.9' << ' 123abc' ---
-int(0)
---- testing: 'a5.9' << '123 abc' ---
-int(0)
---- testing: 'a5.9' << '123abc ' ---
-int(0)
---- testing: 'a5.9' << '3.4a' ---
-int(0)
---- testing: 'a5.9' << 'a5.9' ---
-int(0)
-===DONE===
+--TEST-- +Test << operator : various numbers as strings +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' << '$otherVal' ---\n"; + try { + var_dump($strVal<<$otherVal); + } catch (ArithmeticError $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } + } +} + + +?> +===DONE=== +--EXPECT-- +--- testing: '0' << '0' --- +int(0) +--- testing: '0' << '65' --- +int(0) +--- testing: '0' << '-44' --- +Exception: Bit shift by negative number +--- testing: '0' << '1.2' --- +int(0) +--- testing: '0' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '0' << 'abc' --- +int(0) +--- testing: '0' << '123abc' --- +int(0) +--- testing: '0' << '123e5' --- +int(0) +--- testing: '0' << '123e5xyz' --- +int(0) +--- testing: '0' << ' 123abc' --- +int(0) +--- testing: '0' << '123 abc' --- +int(0) +--- testing: '0' << '123abc ' --- +int(0) +--- testing: '0' << '3.4a' --- +int(0) +--- testing: '0' << 'a5.9' --- +int(0) +--- testing: '65' << '0' --- +int(65) +--- testing: '65' << '65' --- +int(0) +--- testing: '65' << '-44' --- +Exception: Bit shift by negative number +--- testing: '65' << '1.2' --- +int(130) +--- testing: '65' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '65' << 'abc' --- +int(65) +--- testing: '65' << '123abc' --- +int(0) +--- testing: '65' << '123e5' --- +int(0) +--- testing: '65' << '123e5xyz' --- +int(0) +--- testing: '65' << ' 123abc' --- +int(0) +--- testing: '65' << '123 abc' --- +int(0) +--- testing: '65' << '123abc ' --- +int(0) +--- testing: '65' << '3.4a' --- +int(520) +--- testing: '65' << 'a5.9' --- +int(65) +--- testing: '-44' << '0' --- +int(-44) +--- testing: '-44' << '65' --- +int(0) +--- testing: '-44' << '-44' --- +Exception: Bit shift by negative number +--- testing: '-44' << '1.2' --- +int(-88) +--- testing: '-44' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '-44' << 'abc' --- +int(-44) +--- testing: '-44' << '123abc' --- +int(0) +--- testing: '-44' << '123e5' --- +int(0) +--- testing: '-44' << '123e5xyz' --- +int(0) +--- testing: '-44' << ' 123abc' --- +int(0) +--- testing: '-44' << '123 abc' --- +int(0) +--- testing: '-44' << '123abc ' --- +int(0) +--- testing: '-44' << '3.4a' --- +int(-352) +--- testing: '-44' << 'a5.9' --- +int(-44) +--- testing: '1.2' << '0' --- +int(1) +--- testing: '1.2' << '65' --- +int(0) +--- testing: '1.2' << '-44' --- +Exception: Bit shift by negative number +--- testing: '1.2' << '1.2' --- +int(2) +--- testing: '1.2' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '1.2' << 'abc' --- +int(1) +--- testing: '1.2' << '123abc' --- +int(0) +--- testing: '1.2' << '123e5' --- +int(0) +--- testing: '1.2' << '123e5xyz' --- +int(0) +--- testing: '1.2' << ' 123abc' --- +int(0) +--- testing: '1.2' << '123 abc' --- +int(0) +--- testing: '1.2' << '123abc ' --- +int(0) +--- testing: '1.2' << '3.4a' --- +int(8) +--- testing: '1.2' << 'a5.9' --- +int(1) +--- testing: '-7.7' << '0' --- +int(-7) +--- testing: '-7.7' << '65' --- +int(0) +--- testing: '-7.7' << '-44' --- +Exception: Bit shift by negative number +--- testing: '-7.7' << '1.2' --- +int(-14) +--- testing: '-7.7' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '-7.7' << 'abc' --- +int(-7) +--- testing: '-7.7' << '123abc' --- +int(0) +--- testing: '-7.7' << '123e5' --- +int(0) +--- testing: '-7.7' << '123e5xyz' --- +int(0) +--- testing: '-7.7' << ' 123abc' --- +int(0) +--- testing: '-7.7' << '123 abc' --- +int(0) +--- testing: '-7.7' << '123abc ' --- +int(0) +--- testing: '-7.7' << '3.4a' --- +int(-56) +--- testing: '-7.7' << 'a5.9' --- +int(-7) +--- testing: 'abc' << '0' --- +int(0) +--- testing: 'abc' << '65' --- +int(0) +--- testing: 'abc' << '-44' --- +Exception: Bit shift by negative number +--- testing: 'abc' << '1.2' --- +int(0) +--- testing: 'abc' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: 'abc' << 'abc' --- +int(0) +--- testing: 'abc' << '123abc' --- +int(0) +--- testing: 'abc' << '123e5' --- +int(0) +--- testing: 'abc' << '123e5xyz' --- +int(0) +--- testing: 'abc' << ' 123abc' --- +int(0) +--- testing: 'abc' << '123 abc' --- +int(0) +--- testing: 'abc' << '123abc ' --- +int(0) +--- testing: 'abc' << '3.4a' --- +int(0) +--- testing: 'abc' << 'a5.9' --- +int(0) +--- testing: '123abc' << '0' --- +int(123) +--- testing: '123abc' << '65' --- +int(0) +--- testing: '123abc' << '-44' --- +Exception: Bit shift by negative number +--- testing: '123abc' << '1.2' --- +int(246) +--- testing: '123abc' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '123abc' << 'abc' --- +int(123) +--- testing: '123abc' << '123abc' --- +int(0) +--- testing: '123abc' << '123e5' --- +int(0) +--- testing: '123abc' << '123e5xyz' --- +int(0) +--- testing: '123abc' << ' 123abc' --- +int(0) +--- testing: '123abc' << '123 abc' --- +int(0) +--- testing: '123abc' << '123abc ' --- +int(0) +--- testing: '123abc' << '3.4a' --- +int(984) +--- testing: '123abc' << 'a5.9' --- +int(123) +--- testing: '123e5' << '0' --- +int(12300000) +--- testing: '123e5' << '65' --- +int(0) +--- testing: '123e5' << '-44' --- +Exception: Bit shift by negative number +--- testing: '123e5' << '1.2' --- +int(24600000) +--- testing: '123e5' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '123e5' << 'abc' --- +int(12300000) +--- testing: '123e5' << '123abc' --- +int(0) +--- testing: '123e5' << '123e5' --- +int(0) +--- testing: '123e5' << '123e5xyz' --- +int(0) +--- testing: '123e5' << ' 123abc' --- +int(0) +--- testing: '123e5' << '123 abc' --- +int(0) +--- testing: '123e5' << '123abc ' --- +int(0) +--- testing: '123e5' << '3.4a' --- +int(98400000) +--- testing: '123e5' << 'a5.9' --- +int(12300000) +--- testing: '123e5xyz' << '0' --- +int(12300000) +--- testing: '123e5xyz' << '65' --- +int(0) +--- testing: '123e5xyz' << '-44' --- +Exception: Bit shift by negative number +--- testing: '123e5xyz' << '1.2' --- +int(24600000) +--- testing: '123e5xyz' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '123e5xyz' << 'abc' --- +int(12300000) +--- testing: '123e5xyz' << '123abc' --- +int(0) +--- testing: '123e5xyz' << '123e5' --- +int(0) +--- testing: '123e5xyz' << '123e5xyz' --- +int(0) +--- testing: '123e5xyz' << ' 123abc' --- +int(0) +--- testing: '123e5xyz' << '123 abc' --- +int(0) +--- testing: '123e5xyz' << '123abc ' --- +int(0) +--- testing: '123e5xyz' << '3.4a' --- +int(98400000) +--- testing: '123e5xyz' << 'a5.9' --- +int(12300000) +--- testing: ' 123abc' << '0' --- +int(123) +--- testing: ' 123abc' << '65' --- +int(0) +--- testing: ' 123abc' << '-44' --- +Exception: Bit shift by negative number +--- testing: ' 123abc' << '1.2' --- +int(246) +--- testing: ' 123abc' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: ' 123abc' << 'abc' --- +int(123) +--- testing: ' 123abc' << '123abc' --- +int(0) +--- testing: ' 123abc' << '123e5' --- +int(0) +--- testing: ' 123abc' << '123e5xyz' --- +int(0) +--- testing: ' 123abc' << ' 123abc' --- +int(0) +--- testing: ' 123abc' << '123 abc' --- +int(0) +--- testing: ' 123abc' << '123abc ' --- +int(0) +--- testing: ' 123abc' << '3.4a' --- +int(984) +--- testing: ' 123abc' << 'a5.9' --- +int(123) +--- testing: '123 abc' << '0' --- +int(123) +--- testing: '123 abc' << '65' --- +int(0) +--- testing: '123 abc' << '-44' --- +Exception: Bit shift by negative number +--- testing: '123 abc' << '1.2' --- +int(246) +--- testing: '123 abc' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '123 abc' << 'abc' --- +int(123) +--- testing: '123 abc' << '123abc' --- +int(0) +--- testing: '123 abc' << '123e5' --- +int(0) +--- testing: '123 abc' << '123e5xyz' --- +int(0) +--- testing: '123 abc' << ' 123abc' --- +int(0) +--- testing: '123 abc' << '123 abc' --- +int(0) +--- testing: '123 abc' << '123abc ' --- +int(0) +--- testing: '123 abc' << '3.4a' --- +int(984) +--- testing: '123 abc' << 'a5.9' --- +int(123) +--- testing: '123abc ' << '0' --- +int(123) +--- testing: '123abc ' << '65' --- +int(0) +--- testing: '123abc ' << '-44' --- +Exception: Bit shift by negative number +--- testing: '123abc ' << '1.2' --- +int(246) +--- testing: '123abc ' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '123abc ' << 'abc' --- +int(123) +--- testing: '123abc ' << '123abc' --- +int(0) +--- testing: '123abc ' << '123e5' --- +int(0) +--- testing: '123abc ' << '123e5xyz' --- +int(0) +--- testing: '123abc ' << ' 123abc' --- +int(0) +--- testing: '123abc ' << '123 abc' --- +int(0) +--- testing: '123abc ' << '123abc ' --- +int(0) +--- testing: '123abc ' << '3.4a' --- +int(984) +--- testing: '123abc ' << 'a5.9' --- +int(123) +--- testing: '3.4a' << '0' --- +int(3) +--- testing: '3.4a' << '65' --- +int(0) +--- testing: '3.4a' << '-44' --- +Exception: Bit shift by negative number +--- testing: '3.4a' << '1.2' --- +int(6) +--- testing: '3.4a' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: '3.4a' << 'abc' --- +int(3) +--- testing: '3.4a' << '123abc' --- +int(0) +--- testing: '3.4a' << '123e5' --- +int(0) +--- testing: '3.4a' << '123e5xyz' --- +int(0) +--- testing: '3.4a' << ' 123abc' --- +int(0) +--- testing: '3.4a' << '123 abc' --- +int(0) +--- testing: '3.4a' << '123abc ' --- +int(0) +--- testing: '3.4a' << '3.4a' --- +int(24) +--- testing: '3.4a' << 'a5.9' --- +int(3) +--- testing: 'a5.9' << '0' --- +int(0) +--- testing: 'a5.9' << '65' --- +int(0) +--- testing: 'a5.9' << '-44' --- +Exception: Bit shift by negative number +--- testing: 'a5.9' << '1.2' --- +int(0) +--- testing: 'a5.9' << '-7.7' --- +Exception: Bit shift by negative number +--- testing: 'a5.9' << 'abc' --- +int(0) +--- testing: 'a5.9' << '123abc' --- +int(0) +--- testing: 'a5.9' << '123e5' --- +int(0) +--- testing: 'a5.9' << '123e5xyz' --- +int(0) +--- testing: 'a5.9' << ' 123abc' --- +int(0) +--- testing: 'a5.9' << '123 abc' --- +int(0) +--- testing: 'a5.9' << '123abc ' --- +int(0) +--- testing: 'a5.9' << '3.4a' --- +int(0) +--- testing: 'a5.9' << 'a5.9' --- +int(0) +===DONE=== diff --git a/tests/lang/operators/bitwiseXor_variationStr.phpt b/tests/lang/operators/bitwiseXor_variationStr.phpt index 7dda65910a..64d5eb75d8 100644 --- a/tests/lang/operators/bitwiseXor_variationStr.phpt +++ b/tests/lang/operators/bitwiseXor_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test ^ operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' ^ '$otherVal' ---\n";
- var_dump(bin2hex($strVal^$otherVal));
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test ^ operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' ^ '$otherVal' ---\n"; + var_dump(bin2hex($strVal^$otherVal)); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' ^ '0' --- string(2) "00" --- testing: '0' ^ '65' --- @@ -412,5 +412,5 @@ string(8) "50071d58" --- testing: 'a5.9' ^ '3.4a' --- string(8) "521b1a58" --- testing: 'a5.9' ^ 'a5.9' --- -string(8) "00000000"
-===DONE===
+string(8) "00000000" +===DONE=== diff --git a/tests/lang/operators/divide_basiclong_64bit.phpt b/tests/lang/operators/divide_basiclong_64bit.phpt index c6bed0c88b..0dd08f534f 100644 --- a/tests/lang/operators/divide_basiclong_64bit.phpt +++ b/tests/lang/operators/divide_basiclong_64bit.phpt @@ -1,44 +1,44 @@ ---TEST--
-Test / operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
-
-error_reporting(E_ERROR);
-
-foreach ($longVals as $longVal) {
- foreach($otherVals as $otherVal) {
- echo "--- testing: $longVal / $otherVal ---\n";
- var_dump($longVal/$otherVal);
- }
-}
-
-foreach ($otherVals as $otherVal) {
- foreach($longVals as $longVal) {
- echo "--- testing: $otherVal / $longVal ---\n";
- var_dump($otherVal/$longVal);
- }
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test / operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + +$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); + +error_reporting(E_ERROR); + +foreach ($longVals as $longVal) { + foreach($otherVals as $otherVal) { + echo "--- testing: $longVal / $otherVal ---\n"; + var_dump($longVal/$otherVal); + } +} + +foreach ($otherVals as $otherVal) { + foreach($longVals as $longVal) { + echo "--- testing: $otherVal / $longVal ---\n"; + var_dump($otherVal/$longVal); + } +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 / 0 --- float(INF) --- testing: 9223372036854775807 / 1 --- @@ -578,5 +578,5 @@ float(1) --- testing: 9223372036854775807 / -9223372036854775807 --- int(-1) --- testing: 9223372036854775807 / -9.2233720368548E+18 --- -float(-1)
-===DONE===
+float(-1) +===DONE=== diff --git a/tests/lang/operators/divide_variationStr.phpt b/tests/lang/operators/divide_variationStr.phpt index f54013fcec..88ff8f1840 100644 --- a/tests/lang/operators/divide_variationStr.phpt +++ b/tests/lang/operators/divide_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test / operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' / '$otherVal' ---\n";
- var_dump($strVal/$otherVal);
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test / operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' / '$otherVal' ---\n"; + var_dump($strVal/$otherVal); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' / '0' --- float(NAN) --- testing: '0' / '65' --- @@ -412,5 +412,5 @@ int(0) --- testing: 'a5.9' / '3.4a' --- float(0) --- testing: 'a5.9' / 'a5.9' --- -float(NAN)
-===DONE===
+float(NAN) +===DONE=== diff --git a/tests/lang/operators/modulus_variationStr.phpt b/tests/lang/operators/modulus_variationStr.phpt index 4cfd7768ff..6441428e3e 100644 --- a/tests/lang/operators/modulus_variationStr.phpt +++ b/tests/lang/operators/modulus_variationStr.phpt @@ -1,420 +1,420 @@ ---TEST--
-Test % operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' % '$otherVal' ---\n";
- try {
- var_dump($strVal%$otherVal);
- } catch (DivisionByZeroError $e) {
- echo "Exception: " . $e->getMessage() . "\n";
- }
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
---- testing: '0' % '0' ---
-Exception: Modulo by zero
---- testing: '0' % '65' ---
-int(0)
---- testing: '0' % '-44' ---
-int(0)
---- testing: '0' % '1.2' ---
-int(0)
---- testing: '0' % '-7.7' ---
-int(0)
---- testing: '0' % 'abc' ---
-Exception: Modulo by zero
---- testing: '0' % '123abc' ---
-int(0)
---- testing: '0' % '123e5' ---
-int(0)
---- testing: '0' % '123e5xyz' ---
-int(0)
---- testing: '0' % ' 123abc' ---
-int(0)
---- testing: '0' % '123 abc' ---
-int(0)
---- testing: '0' % '123abc ' ---
-int(0)
---- testing: '0' % '3.4a' ---
-int(0)
---- testing: '0' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '65' % '0' ---
-Exception: Modulo by zero
---- testing: '65' % '65' ---
-int(0)
---- testing: '65' % '-44' ---
-int(21)
---- testing: '65' % '1.2' ---
-int(0)
---- testing: '65' % '-7.7' ---
-int(2)
---- testing: '65' % 'abc' ---
-Exception: Modulo by zero
---- testing: '65' % '123abc' ---
-int(65)
---- testing: '65' % '123e5' ---
-int(65)
---- testing: '65' % '123e5xyz' ---
-int(65)
---- testing: '65' % ' 123abc' ---
-int(65)
---- testing: '65' % '123 abc' ---
-int(65)
---- testing: '65' % '123abc ' ---
-int(65)
---- testing: '65' % '3.4a' ---
-int(2)
---- testing: '65' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '-44' % '0' ---
-Exception: Modulo by zero
---- testing: '-44' % '65' ---
-int(-44)
---- testing: '-44' % '-44' ---
-int(0)
---- testing: '-44' % '1.2' ---
-int(0)
---- testing: '-44' % '-7.7' ---
-int(-2)
---- testing: '-44' % 'abc' ---
-Exception: Modulo by zero
---- testing: '-44' % '123abc' ---
-int(-44)
---- testing: '-44' % '123e5' ---
-int(-44)
---- testing: '-44' % '123e5xyz' ---
-int(-44)
---- testing: '-44' % ' 123abc' ---
-int(-44)
---- testing: '-44' % '123 abc' ---
-int(-44)
---- testing: '-44' % '123abc ' ---
-int(-44)
---- testing: '-44' % '3.4a' ---
-int(-2)
---- testing: '-44' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '1.2' % '0' ---
-Exception: Modulo by zero
---- testing: '1.2' % '65' ---
-int(1)
---- testing: '1.2' % '-44' ---
-int(1)
---- testing: '1.2' % '1.2' ---
-int(0)
---- testing: '1.2' % '-7.7' ---
-int(1)
---- testing: '1.2' % 'abc' ---
-Exception: Modulo by zero
---- testing: '1.2' % '123abc' ---
-int(1)
---- testing: '1.2' % '123e5' ---
-int(1)
---- testing: '1.2' % '123e5xyz' ---
-int(1)
---- testing: '1.2' % ' 123abc' ---
-int(1)
---- testing: '1.2' % '123 abc' ---
-int(1)
---- testing: '1.2' % '123abc ' ---
-int(1)
---- testing: '1.2' % '3.4a' ---
-int(1)
---- testing: '1.2' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '-7.7' % '0' ---
-Exception: Modulo by zero
---- testing: '-7.7' % '65' ---
-int(-7)
---- testing: '-7.7' % '-44' ---
-int(-7)
---- testing: '-7.7' % '1.2' ---
-int(0)
---- testing: '-7.7' % '-7.7' ---
-int(0)
---- testing: '-7.7' % 'abc' ---
-Exception: Modulo by zero
---- testing: '-7.7' % '123abc' ---
-int(-7)
---- testing: '-7.7' % '123e5' ---
-int(-7)
---- testing: '-7.7' % '123e5xyz' ---
-int(-7)
---- testing: '-7.7' % ' 123abc' ---
-int(-7)
---- testing: '-7.7' % '123 abc' ---
-int(-7)
---- testing: '-7.7' % '123abc ' ---
-int(-7)
---- testing: '-7.7' % '3.4a' ---
-int(-1)
---- testing: '-7.7' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: 'abc' % '0' ---
-Exception: Modulo by zero
---- testing: 'abc' % '65' ---
-int(0)
---- testing: 'abc' % '-44' ---
-int(0)
---- testing: 'abc' % '1.2' ---
-int(0)
---- testing: 'abc' % '-7.7' ---
-int(0)
---- testing: 'abc' % 'abc' ---
-Exception: Modulo by zero
---- testing: 'abc' % '123abc' ---
-int(0)
---- testing: 'abc' % '123e5' ---
-int(0)
---- testing: 'abc' % '123e5xyz' ---
-int(0)
---- testing: 'abc' % ' 123abc' ---
-int(0)
---- testing: 'abc' % '123 abc' ---
-int(0)
---- testing: 'abc' % '123abc ' ---
-int(0)
---- testing: 'abc' % '3.4a' ---
-int(0)
---- testing: 'abc' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '123abc' % '0' ---
-Exception: Modulo by zero
---- testing: '123abc' % '65' ---
-int(58)
---- testing: '123abc' % '-44' ---
-int(35)
---- testing: '123abc' % '1.2' ---
-int(0)
---- testing: '123abc' % '-7.7' ---
-int(4)
---- testing: '123abc' % 'abc' ---
-Exception: Modulo by zero
---- testing: '123abc' % '123abc' ---
-int(0)
---- testing: '123abc' % '123e5' ---
-int(123)
---- testing: '123abc' % '123e5xyz' ---
-int(123)
---- testing: '123abc' % ' 123abc' ---
-int(0)
---- testing: '123abc' % '123 abc' ---
-int(0)
---- testing: '123abc' % '123abc ' ---
-int(0)
---- testing: '123abc' % '3.4a' ---
-int(0)
---- testing: '123abc' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '123e5' % '0' ---
-Exception: Modulo by zero
---- testing: '123e5' % '65' ---
-int(50)
---- testing: '123e5' % '-44' ---
-int(20)
---- testing: '123e5' % '1.2' ---
-int(0)
---- testing: '123e5' % '-7.7' ---
-int(6)
---- testing: '123e5' % 'abc' ---
-Exception: Modulo by zero
---- testing: '123e5' % '123abc' ---
-int(0)
---- testing: '123e5' % '123e5' ---
-int(0)
---- testing: '123e5' % '123e5xyz' ---
-int(0)
---- testing: '123e5' % ' 123abc' ---
-int(0)
---- testing: '123e5' % '123 abc' ---
-int(0)
---- testing: '123e5' % '123abc ' ---
-int(0)
---- testing: '123e5' % '3.4a' ---
-int(0)
---- testing: '123e5' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '123e5xyz' % '0' ---
-Exception: Modulo by zero
---- testing: '123e5xyz' % '65' ---
-int(50)
---- testing: '123e5xyz' % '-44' ---
-int(20)
---- testing: '123e5xyz' % '1.2' ---
-int(0)
---- testing: '123e5xyz' % '-7.7' ---
-int(6)
---- testing: '123e5xyz' % 'abc' ---
-Exception: Modulo by zero
---- testing: '123e5xyz' % '123abc' ---
-int(0)
---- testing: '123e5xyz' % '123e5' ---
-int(0)
---- testing: '123e5xyz' % '123e5xyz' ---
-int(0)
---- testing: '123e5xyz' % ' 123abc' ---
-int(0)
---- testing: '123e5xyz' % '123 abc' ---
-int(0)
---- testing: '123e5xyz' % '123abc ' ---
-int(0)
---- testing: '123e5xyz' % '3.4a' ---
-int(0)
---- testing: '123e5xyz' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: ' 123abc' % '0' ---
-Exception: Modulo by zero
---- testing: ' 123abc' % '65' ---
-int(58)
---- testing: ' 123abc' % '-44' ---
-int(35)
---- testing: ' 123abc' % '1.2' ---
-int(0)
---- testing: ' 123abc' % '-7.7' ---
-int(4)
---- testing: ' 123abc' % 'abc' ---
-Exception: Modulo by zero
---- testing: ' 123abc' % '123abc' ---
-int(0)
---- testing: ' 123abc' % '123e5' ---
-int(123)
---- testing: ' 123abc' % '123e5xyz' ---
-int(123)
---- testing: ' 123abc' % ' 123abc' ---
-int(0)
---- testing: ' 123abc' % '123 abc' ---
-int(0)
---- testing: ' 123abc' % '123abc ' ---
-int(0)
---- testing: ' 123abc' % '3.4a' ---
-int(0)
---- testing: ' 123abc' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '123 abc' % '0' ---
-Exception: Modulo by zero
---- testing: '123 abc' % '65' ---
-int(58)
---- testing: '123 abc' % '-44' ---
-int(35)
---- testing: '123 abc' % '1.2' ---
-int(0)
---- testing: '123 abc' % '-7.7' ---
-int(4)
---- testing: '123 abc' % 'abc' ---
-Exception: Modulo by zero
---- testing: '123 abc' % '123abc' ---
-int(0)
---- testing: '123 abc' % '123e5' ---
-int(123)
---- testing: '123 abc' % '123e5xyz' ---
-int(123)
---- testing: '123 abc' % ' 123abc' ---
-int(0)
---- testing: '123 abc' % '123 abc' ---
-int(0)
---- testing: '123 abc' % '123abc ' ---
-int(0)
---- testing: '123 abc' % '3.4a' ---
-int(0)
---- testing: '123 abc' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '123abc ' % '0' ---
-Exception: Modulo by zero
---- testing: '123abc ' % '65' ---
-int(58)
---- testing: '123abc ' % '-44' ---
-int(35)
---- testing: '123abc ' % '1.2' ---
-int(0)
---- testing: '123abc ' % '-7.7' ---
-int(4)
---- testing: '123abc ' % 'abc' ---
-Exception: Modulo by zero
---- testing: '123abc ' % '123abc' ---
-int(0)
---- testing: '123abc ' % '123e5' ---
-int(123)
---- testing: '123abc ' % '123e5xyz' ---
-int(123)
---- testing: '123abc ' % ' 123abc' ---
-int(0)
---- testing: '123abc ' % '123 abc' ---
-int(0)
---- testing: '123abc ' % '123abc ' ---
-int(0)
---- testing: '123abc ' % '3.4a' ---
-int(0)
---- testing: '123abc ' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: '3.4a' % '0' ---
-Exception: Modulo by zero
---- testing: '3.4a' % '65' ---
-int(3)
---- testing: '3.4a' % '-44' ---
-int(3)
---- testing: '3.4a' % '1.2' ---
-int(0)
---- testing: '3.4a' % '-7.7' ---
-int(3)
---- testing: '3.4a' % 'abc' ---
-Exception: Modulo by zero
---- testing: '3.4a' % '123abc' ---
-int(3)
---- testing: '3.4a' % '123e5' ---
-int(3)
---- testing: '3.4a' % '123e5xyz' ---
-int(3)
---- testing: '3.4a' % ' 123abc' ---
-int(3)
---- testing: '3.4a' % '123 abc' ---
-int(3)
---- testing: '3.4a' % '123abc ' ---
-int(3)
---- testing: '3.4a' % '3.4a' ---
-int(0)
---- testing: '3.4a' % 'a5.9' ---
-Exception: Modulo by zero
---- testing: 'a5.9' % '0' ---
-Exception: Modulo by zero
---- testing: 'a5.9' % '65' ---
-int(0)
---- testing: 'a5.9' % '-44' ---
-int(0)
---- testing: 'a5.9' % '1.2' ---
-int(0)
---- testing: 'a5.9' % '-7.7' ---
-int(0)
---- testing: 'a5.9' % 'abc' ---
-Exception: Modulo by zero
---- testing: 'a5.9' % '123abc' ---
-int(0)
---- testing: 'a5.9' % '123e5' ---
-int(0)
---- testing: 'a5.9' % '123e5xyz' ---
-int(0)
---- testing: 'a5.9' % ' 123abc' ---
-int(0)
---- testing: 'a5.9' % '123 abc' ---
-int(0)
---- testing: 'a5.9' % '123abc ' ---
-int(0)
---- testing: 'a5.9' % '3.4a' ---
-int(0)
---- testing: 'a5.9' % 'a5.9' ---
-Exception: Modulo by zero
-===DONE===
+--TEST-- +Test % operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' % '$otherVal' ---\n"; + try { + var_dump($strVal%$otherVal); + } catch (DivisionByZeroError $e) { + echo "Exception: " . $e->getMessage() . "\n"; + } + } +} + + +?> +===DONE=== +--EXPECT-- +--- testing: '0' % '0' --- +Exception: Modulo by zero +--- testing: '0' % '65' --- +int(0) +--- testing: '0' % '-44' --- +int(0) +--- testing: '0' % '1.2' --- +int(0) +--- testing: '0' % '-7.7' --- +int(0) +--- testing: '0' % 'abc' --- +Exception: Modulo by zero +--- testing: '0' % '123abc' --- +int(0) +--- testing: '0' % '123e5' --- +int(0) +--- testing: '0' % '123e5xyz' --- +int(0) +--- testing: '0' % ' 123abc' --- +int(0) +--- testing: '0' % '123 abc' --- +int(0) +--- testing: '0' % '123abc ' --- +int(0) +--- testing: '0' % '3.4a' --- +int(0) +--- testing: '0' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '65' % '0' --- +Exception: Modulo by zero +--- testing: '65' % '65' --- +int(0) +--- testing: '65' % '-44' --- +int(21) +--- testing: '65' % '1.2' --- +int(0) +--- testing: '65' % '-7.7' --- +int(2) +--- testing: '65' % 'abc' --- +Exception: Modulo by zero +--- testing: '65' % '123abc' --- +int(65) +--- testing: '65' % '123e5' --- +int(65) +--- testing: '65' % '123e5xyz' --- +int(65) +--- testing: '65' % ' 123abc' --- +int(65) +--- testing: '65' % '123 abc' --- +int(65) +--- testing: '65' % '123abc ' --- +int(65) +--- testing: '65' % '3.4a' --- +int(2) +--- testing: '65' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '-44' % '0' --- +Exception: Modulo by zero +--- testing: '-44' % '65' --- +int(-44) +--- testing: '-44' % '-44' --- +int(0) +--- testing: '-44' % '1.2' --- +int(0) +--- testing: '-44' % '-7.7' --- +int(-2) +--- testing: '-44' % 'abc' --- +Exception: Modulo by zero +--- testing: '-44' % '123abc' --- +int(-44) +--- testing: '-44' % '123e5' --- +int(-44) +--- testing: '-44' % '123e5xyz' --- +int(-44) +--- testing: '-44' % ' 123abc' --- +int(-44) +--- testing: '-44' % '123 abc' --- +int(-44) +--- testing: '-44' % '123abc ' --- +int(-44) +--- testing: '-44' % '3.4a' --- +int(-2) +--- testing: '-44' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '1.2' % '0' --- +Exception: Modulo by zero +--- testing: '1.2' % '65' --- +int(1) +--- testing: '1.2' % '-44' --- +int(1) +--- testing: '1.2' % '1.2' --- +int(0) +--- testing: '1.2' % '-7.7' --- +int(1) +--- testing: '1.2' % 'abc' --- +Exception: Modulo by zero +--- testing: '1.2' % '123abc' --- +int(1) +--- testing: '1.2' % '123e5' --- +int(1) +--- testing: '1.2' % '123e5xyz' --- +int(1) +--- testing: '1.2' % ' 123abc' --- +int(1) +--- testing: '1.2' % '123 abc' --- +int(1) +--- testing: '1.2' % '123abc ' --- +int(1) +--- testing: '1.2' % '3.4a' --- +int(1) +--- testing: '1.2' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '-7.7' % '0' --- +Exception: Modulo by zero +--- testing: '-7.7' % '65' --- +int(-7) +--- testing: '-7.7' % '-44' --- +int(-7) +--- testing: '-7.7' % '1.2' --- +int(0) +--- testing: '-7.7' % '-7.7' --- +int(0) +--- testing: '-7.7' % 'abc' --- +Exception: Modulo by zero +--- testing: '-7.7' % '123abc' --- +int(-7) +--- testing: '-7.7' % '123e5' --- +int(-7) +--- testing: '-7.7' % '123e5xyz' --- +int(-7) +--- testing: '-7.7' % ' 123abc' --- +int(-7) +--- testing: '-7.7' % '123 abc' --- +int(-7) +--- testing: '-7.7' % '123abc ' --- +int(-7) +--- testing: '-7.7' % '3.4a' --- +int(-1) +--- testing: '-7.7' % 'a5.9' --- +Exception: Modulo by zero +--- testing: 'abc' % '0' --- +Exception: Modulo by zero +--- testing: 'abc' % '65' --- +int(0) +--- testing: 'abc' % '-44' --- +int(0) +--- testing: 'abc' % '1.2' --- +int(0) +--- testing: 'abc' % '-7.7' --- +int(0) +--- testing: 'abc' % 'abc' --- +Exception: Modulo by zero +--- testing: 'abc' % '123abc' --- +int(0) +--- testing: 'abc' % '123e5' --- +int(0) +--- testing: 'abc' % '123e5xyz' --- +int(0) +--- testing: 'abc' % ' 123abc' --- +int(0) +--- testing: 'abc' % '123 abc' --- +int(0) +--- testing: 'abc' % '123abc ' --- +int(0) +--- testing: 'abc' % '3.4a' --- +int(0) +--- testing: 'abc' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '123abc' % '0' --- +Exception: Modulo by zero +--- testing: '123abc' % '65' --- +int(58) +--- testing: '123abc' % '-44' --- +int(35) +--- testing: '123abc' % '1.2' --- +int(0) +--- testing: '123abc' % '-7.7' --- +int(4) +--- testing: '123abc' % 'abc' --- +Exception: Modulo by zero +--- testing: '123abc' % '123abc' --- +int(0) +--- testing: '123abc' % '123e5' --- +int(123) +--- testing: '123abc' % '123e5xyz' --- +int(123) +--- testing: '123abc' % ' 123abc' --- +int(0) +--- testing: '123abc' % '123 abc' --- +int(0) +--- testing: '123abc' % '123abc ' --- +int(0) +--- testing: '123abc' % '3.4a' --- +int(0) +--- testing: '123abc' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '123e5' % '0' --- +Exception: Modulo by zero +--- testing: '123e5' % '65' --- +int(50) +--- testing: '123e5' % '-44' --- +int(20) +--- testing: '123e5' % '1.2' --- +int(0) +--- testing: '123e5' % '-7.7' --- +int(6) +--- testing: '123e5' % 'abc' --- +Exception: Modulo by zero +--- testing: '123e5' % '123abc' --- +int(0) +--- testing: '123e5' % '123e5' --- +int(0) +--- testing: '123e5' % '123e5xyz' --- +int(0) +--- testing: '123e5' % ' 123abc' --- +int(0) +--- testing: '123e5' % '123 abc' --- +int(0) +--- testing: '123e5' % '123abc ' --- +int(0) +--- testing: '123e5' % '3.4a' --- +int(0) +--- testing: '123e5' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '123e5xyz' % '0' --- +Exception: Modulo by zero +--- testing: '123e5xyz' % '65' --- +int(50) +--- testing: '123e5xyz' % '-44' --- +int(20) +--- testing: '123e5xyz' % '1.2' --- +int(0) +--- testing: '123e5xyz' % '-7.7' --- +int(6) +--- testing: '123e5xyz' % 'abc' --- +Exception: Modulo by zero +--- testing: '123e5xyz' % '123abc' --- +int(0) +--- testing: '123e5xyz' % '123e5' --- +int(0) +--- testing: '123e5xyz' % '123e5xyz' --- +int(0) +--- testing: '123e5xyz' % ' 123abc' --- +int(0) +--- testing: '123e5xyz' % '123 abc' --- +int(0) +--- testing: '123e5xyz' % '123abc ' --- +int(0) +--- testing: '123e5xyz' % '3.4a' --- +int(0) +--- testing: '123e5xyz' % 'a5.9' --- +Exception: Modulo by zero +--- testing: ' 123abc' % '0' --- +Exception: Modulo by zero +--- testing: ' 123abc' % '65' --- +int(58) +--- testing: ' 123abc' % '-44' --- +int(35) +--- testing: ' 123abc' % '1.2' --- +int(0) +--- testing: ' 123abc' % '-7.7' --- +int(4) +--- testing: ' 123abc' % 'abc' --- +Exception: Modulo by zero +--- testing: ' 123abc' % '123abc' --- +int(0) +--- testing: ' 123abc' % '123e5' --- +int(123) +--- testing: ' 123abc' % '123e5xyz' --- +int(123) +--- testing: ' 123abc' % ' 123abc' --- +int(0) +--- testing: ' 123abc' % '123 abc' --- +int(0) +--- testing: ' 123abc' % '123abc ' --- +int(0) +--- testing: ' 123abc' % '3.4a' --- +int(0) +--- testing: ' 123abc' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '123 abc' % '0' --- +Exception: Modulo by zero +--- testing: '123 abc' % '65' --- +int(58) +--- testing: '123 abc' % '-44' --- +int(35) +--- testing: '123 abc' % '1.2' --- +int(0) +--- testing: '123 abc' % '-7.7' --- +int(4) +--- testing: '123 abc' % 'abc' --- +Exception: Modulo by zero +--- testing: '123 abc' % '123abc' --- +int(0) +--- testing: '123 abc' % '123e5' --- +int(123) +--- testing: '123 abc' % '123e5xyz' --- +int(123) +--- testing: '123 abc' % ' 123abc' --- +int(0) +--- testing: '123 abc' % '123 abc' --- +int(0) +--- testing: '123 abc' % '123abc ' --- +int(0) +--- testing: '123 abc' % '3.4a' --- +int(0) +--- testing: '123 abc' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '123abc ' % '0' --- +Exception: Modulo by zero +--- testing: '123abc ' % '65' --- +int(58) +--- testing: '123abc ' % '-44' --- +int(35) +--- testing: '123abc ' % '1.2' --- +int(0) +--- testing: '123abc ' % '-7.7' --- +int(4) +--- testing: '123abc ' % 'abc' --- +Exception: Modulo by zero +--- testing: '123abc ' % '123abc' --- +int(0) +--- testing: '123abc ' % '123e5' --- +int(123) +--- testing: '123abc ' % '123e5xyz' --- +int(123) +--- testing: '123abc ' % ' 123abc' --- +int(0) +--- testing: '123abc ' % '123 abc' --- +int(0) +--- testing: '123abc ' % '123abc ' --- +int(0) +--- testing: '123abc ' % '3.4a' --- +int(0) +--- testing: '123abc ' % 'a5.9' --- +Exception: Modulo by zero +--- testing: '3.4a' % '0' --- +Exception: Modulo by zero +--- testing: '3.4a' % '65' --- +int(3) +--- testing: '3.4a' % '-44' --- +int(3) +--- testing: '3.4a' % '1.2' --- +int(0) +--- testing: '3.4a' % '-7.7' --- +int(3) +--- testing: '3.4a' % 'abc' --- +Exception: Modulo by zero +--- testing: '3.4a' % '123abc' --- +int(3) +--- testing: '3.4a' % '123e5' --- +int(3) +--- testing: '3.4a' % '123e5xyz' --- +int(3) +--- testing: '3.4a' % ' 123abc' --- +int(3) +--- testing: '3.4a' % '123 abc' --- +int(3) +--- testing: '3.4a' % '123abc ' --- +int(3) +--- testing: '3.4a' % '3.4a' --- +int(0) +--- testing: '3.4a' % 'a5.9' --- +Exception: Modulo by zero +--- testing: 'a5.9' % '0' --- +Exception: Modulo by zero +--- testing: 'a5.9' % '65' --- +int(0) +--- testing: 'a5.9' % '-44' --- +int(0) +--- testing: 'a5.9' % '1.2' --- +int(0) +--- testing: 'a5.9' % '-7.7' --- +int(0) +--- testing: 'a5.9' % 'abc' --- +Exception: Modulo by zero +--- testing: 'a5.9' % '123abc' --- +int(0) +--- testing: 'a5.9' % '123e5' --- +int(0) +--- testing: 'a5.9' % '123e5xyz' --- +int(0) +--- testing: 'a5.9' % ' 123abc' --- +int(0) +--- testing: 'a5.9' % '123 abc' --- +int(0) +--- testing: 'a5.9' % '123abc ' --- +int(0) +--- testing: 'a5.9' % '3.4a' --- +int(0) +--- testing: 'a5.9' % 'a5.9' --- +Exception: Modulo by zero +===DONE=== diff --git a/tests/lang/operators/multiply_basiclong_64bit.phpt b/tests/lang/operators/multiply_basiclong_64bit.phpt index 4c7077bf3b..31d9188a77 100644 --- a/tests/lang/operators/multiply_basiclong_64bit.phpt +++ b/tests/lang/operators/multiply_basiclong_64bit.phpt @@ -1,44 +1,44 @@ ---TEST--
-Test * operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
-
-error_reporting(E_ERROR);
-
-foreach ($longVals as $longVal) {
- foreach($otherVals as $otherVal) {
- echo "--- testing: $longVal * $otherVal ---\n";
- var_dump($longVal*$otherVal);
- }
-}
-
-foreach ($otherVals as $otherVal) {
- foreach($longVals as $longVal) {
- echo "--- testing: $otherVal * $longVal ---\n";
- var_dump($otherVal*$longVal);
- }
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test * operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + +$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); + +error_reporting(E_ERROR); + +foreach ($longVals as $longVal) { + foreach($otherVals as $otherVal) { + echo "--- testing: $longVal * $otherVal ---\n"; + var_dump($longVal*$otherVal); + } +} + +foreach ($otherVals as $otherVal) { + foreach($longVals as $longVal) { + echo "--- testing: $otherVal * $longVal ---\n"; + var_dump($otherVal*$longVal); + } +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 * 0 --- int(0) --- testing: 9223372036854775807 * 1 --- @@ -578,5 +578,5 @@ float(8.5070591730235E+37) --- testing: 9223372036854775807 * -9223372036854775807 --- float(-8.5070591730235E+37) --- testing: 9223372036854775807 * -9.2233720368548E+18 --- -float(-8.5070591730235E+37)
-===DONE===
+float(-8.5070591730235E+37) +===DONE=== diff --git a/tests/lang/operators/multiply_variationStr.phpt b/tests/lang/operators/multiply_variationStr.phpt index 30d5f79f1a..01d7e05074 100644 --- a/tests/lang/operators/multiply_variationStr.phpt +++ b/tests/lang/operators/multiply_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test * operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' * '$otherVal' ---\n";
- var_dump($strVal*$otherVal);
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test * operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' * '$otherVal' ---\n"; + var_dump($strVal*$otherVal); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' * '0' --- int(0) --- testing: '0' * '65' --- @@ -412,5 +412,5 @@ int(0) --- testing: 'a5.9' * '3.4a' --- float(0) --- testing: 'a5.9' * 'a5.9' --- -int(0)
-===DONE===
+int(0) +===DONE=== diff --git a/tests/lang/operators/negate_basiclong_64bit.phpt b/tests/lang/operators/negate_basiclong_64bit.phpt index e0cf10da69..47b25e5397 100644 --- a/tests/lang/operators/negate_basiclong_64bit.phpt +++ b/tests/lang/operators/negate_basiclong_64bit.phpt @@ -1,32 +1,32 @@ ---TEST--
-Test -N operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-
-foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- var_dump(-$longVal);
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test -N operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + + +foreach ($longVals as $longVal) { + echo "--- testing: $longVal ---\n"; + var_dump(-$longVal); +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 --- int(-9223372036854775807) --- testing: -9223372036854775808 --- @@ -56,5 +56,5 @@ float(-9.2233720368548E+18) --- testing: -9223372036854775807 --- int(9223372036854775807) --- testing: -9.2233720368548E+18 --- -float(9.2233720368548E+18)
-===DONE===
+float(9.2233720368548E+18) +===DONE=== diff --git a/tests/lang/operators/negate_variationStr.phpt b/tests/lang/operators/negate_variationStr.phpt index 7405d42882..ccff2fba2c 100644 --- a/tests/lang/operators/negate_variationStr.phpt +++ b/tests/lang/operators/negate_variationStr.phpt @@ -1,22 +1,22 @@ ---TEST--
-Test -N operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-
-foreach ($strVals as $strVal) {
- echo "--- testing: '$strVal' ---\n";
- var_dump(-$strVal);
-}
-
-?>
-===DONE===
---EXPECTF--
+--TEST-- +Test -N operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + + +foreach ($strVals as $strVal) { + echo "--- testing: '$strVal' ---\n"; + var_dump(-$strVal); +} + +?> +===DONE=== +--EXPECTF-- --- testing: '0' --- int(0) --- testing: '65' --- @@ -60,5 +60,5 @@ float(-3.4) --- testing: 'a5.9' --- Warning: A non-numeric value encountered in %s on line %d -int(0)
-===DONE===
+int(0) +===DONE=== diff --git a/tests/lang/operators/operator_equals_basic.phpt b/tests/lang/operators/operator_equals_basic.phpt index 3cb2704444..9de4ed1a2a 100644 --- a/tests/lang/operators/operator_equals_basic.phpt +++ b/tests/lang/operators/operator_equals_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test == operator : different types
---FILE--
-<?php
-
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", +679);
-$valid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4);
-$invalid_int1 = array("6 7 9", "6y79", 678);
-$invalid_int2 = array("- 67835", "-67,835", "-67 835", "-678y35", -76834);
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4);
-$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4);
-$invalid_float1 = array("57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4);
-$invalid_float2 = array("- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4);
-
-
-$toCompare = array(
- true, $valid_true, $valid_false,
- false, $valid_false, $valid_true,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest == $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' != '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest == $compareVal) {
- echo "FAILED: '$typeToTest' == '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test == operator : different types +--FILE-- +<?php + +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", +679); +$valid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4); +$invalid_int1 = array("6 7 9", "6y79", 678); +$invalid_int2 = array("- 67835", "-67,835", "-67 835", "-678y35", -76834); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4); +$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4); +$invalid_float1 = array("57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4); +$invalid_float2 = array("- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4); + + +$toCompare = array( + true, $valid_true, $valid_false, + false, $valid_false, $valid_true, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest == $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' != '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest == $compareVal) { + echo "FAILED: '$typeToTest' == '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_equals_variation.phpt b/tests/lang/operators/operator_equals_variation.phpt index f7dc32868c..d72253404b 100644 --- a/tests/lang/operators/operator_equals_variation.phpt +++ b/tests/lang/operators/operator_equals_variation.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test == operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$invalidEqual = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validEqual); $i +=2) {
- $typeToTestVal = $validEqual[$i];
- $compares = $validEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal == $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' != '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidEqual); $i +=2) {
- $typeToTestVal = $invalidEqual[$i];
- $compares = $invalidEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal == $compareVal) {
- echo "FAILED: '$typeToTestVal' == '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test == operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$invalidEqual = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validEqual); $i +=2) { + $typeToTestVal = $validEqual[$i]; + $compares = $validEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal == $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' != '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidEqual); $i +=2) { + $typeToTestVal = $invalidEqual[$i]; + $compares = $invalidEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal == $compareVal) { + echo "FAILED: '$typeToTestVal' == '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_equals_variation_64bit.phpt b/tests/lang/operators/operator_equals_variation_64bit.phpt index 6329225fcc..ada6c2d7ec 100644 --- a/tests/lang/operators/operator_equals_variation_64bit.phpt +++ b/tests/lang/operators/operator_equals_variation_64bit.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test == operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1),
-);
-
-$invalidEqual = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit + 1),
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validEqual); $i +=2) {
- $typeToTestVal = $validEqual[$i];
- $compares = $validEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal == $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' != '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidEqual); $i +=2) {
- $typeToTestVal = $invalidEqual[$i];
- $compares = $invalidEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal == $compareVal) {
- echo "FAILED: '$typeToTestVal' == '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test == operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1), +); + +$invalidEqual = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit + 1), +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validEqual); $i +=2) { + $typeToTestVal = $validEqual[$i]; + $compares = $validEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal == $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' != '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidEqual); $i +=2) { + $typeToTestVal = $invalidEqual[$i]; + $compares = $invalidEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal == $compareVal) { + echo "FAILED: '$typeToTestVal' == '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_basic.phpt b/tests/lang/operators/operator_gt_basic.phpt index c410b19dc8..db856c62e6 100644 --- a/tests/lang/operators/operator_gt_basic.phpt +++ b/tests/lang/operators/operator_gt_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test > operator : different types
---FILE--
-<?php
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678);
-$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4);
-$invalid_int1 = array(679, "679");
-$invalid_int2 = array(-67835, "-67835");
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4);
-$valid_float2 = array("-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4);
-$invalid_float1 = array(57385.45835, 5.738545835e4);
-$invalid_float2 = array(-67345.76567, -6.734576567E4);
-
-
-$toCompare = array(
-// boolean test will result in both sides being converted to boolean so !0 = true and true is not > true for example
-// also note that a string of "0" is converted to false but a string of "0.0" is converted to true
-// false cannot be tested as 0 can never be > 0 or 1
- true, $valid_false, $valid_true,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest > $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' <= '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest > $compareVal) {
- echo "FAILED: '$typeToTest' > '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test > operator : different types +--FILE-- +<?php +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); +$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4); +$invalid_int1 = array(679, "679"); +$invalid_int2 = array(-67835, "-67835"); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); +$valid_float2 = array("-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4); +$invalid_float1 = array(57385.45835, 5.738545835e4); +$invalid_float2 = array(-67345.76567, -6.734576567E4); + + +$toCompare = array( +// boolean test will result in both sides being converted to boolean so !0 = true and true is not > true for example +// also note that a string of "0" is converted to false but a string of "0.0" is converted to true +// false cannot be tested as 0 can never be > 0 or 1 + true, $valid_false, $valid_true, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest > $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' <= '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest > $compareVal) { + echo "FAILED: '$typeToTest' > '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_or_equal_basic.phpt b/tests/lang/operators/operator_gt_or_equal_basic.phpt index 20b00df8bb..f1b1e01048 100644 --- a/tests/lang/operators/operator_gt_or_equal_basic.phpt +++ b/tests/lang/operators/operator_gt_or_equal_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test >= operator : different types
---FILE--
-<?php
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("679", "679abc", " 679", 679.0, 6.79E2, "678", "678abc", " 678", 678.0, 6.78E2, 6.789E2, "+678", +678);
-$valid_int2 = array("-67835", "-67835abc", " -67835", -67835.000, -6.7835E4, "-67836", "-67836abc". " -67836", -67835.0001, -6.78351E4, "-67836", -67835.0001, -6.78351E4);
-$invalid_int1 = array(680, "680");
-$invalid_int2 = array(-67834, "-67834");
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4, "57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4);
-$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4, "-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4);
-$invalid_float1 = array(57385.45836, 5.738545836e4);
-$invalid_float2 = array(-67345.76564, -6.734576564E4);
-
-$toCompare = array(
-
- true, array_merge($valid_false, $valid_true), NULL,
- false, $valid_false, $valid_true,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest >= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' < '$compareVal'\n";
- $failed = true;
- }
- }
-
- if ($invalid_compares != NULL) {
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest >= $compareVal) {
- echo "FAILED: '$typeToTest' >= '$compareVal'\n";
- $failed = true;
- }
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test >= operator : different types +--FILE-- +<?php +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("679", "679abc", " 679", 679.0, 6.79E2, "678", "678abc", " 678", 678.0, 6.78E2, 6.789E2, "+678", +678); +$valid_int2 = array("-67835", "-67835abc", " -67835", -67835.000, -6.7835E4, "-67836", "-67836abc". " -67836", -67835.0001, -6.78351E4, "-67836", -67835.0001, -6.78351E4); +$invalid_int1 = array(680, "680"); +$invalid_int2 = array(-67834, "-67834"); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4, "57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); +$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4, "-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4); +$invalid_float1 = array(57385.45836, 5.738545836e4); +$invalid_float2 = array(-67345.76564, -6.734576564E4); + +$toCompare = array( + + true, array_merge($valid_false, $valid_true), NULL, + false, $valid_false, $valid_true, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest >= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' < '$compareVal'\n"; + $failed = true; + } + } + + if ($invalid_compares != NULL) { + foreach($invalid_compares as $compareVal) { + if ($typeToTest >= $compareVal) { + echo "FAILED: '$typeToTest' >= '$compareVal'\n"; + $failed = true; + } + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_or_equal_variation.phpt b/tests/lang/operators/operator_gt_or_equal_variation.phpt index 6cb6ed6d81..2355ab4c45 100644 --- a/tests/lang/operators/operator_gt_or_equal_variation.phpt +++ b/tests/lang/operators/operator_gt_or_equal_variation.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test >= operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validGtOrEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit - 1),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$invalidGtOrEqual = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit + 1,"-2147483646", -2.1474836460001e9)
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validGtOrEqual); $i +=2) {
- $typeToTestVal = $validGtOrEqual[$i];
- $compares = $validGtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal >= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' < '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidGtOrEqual); $i +=2) {
- $typeToTestVal = $invalidGtOrEqual[$i];
- $compares = $invalidGtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal >= $compareVal) {
- echo "FAILED: '$typeToTestVal' >= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test >= operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validGtOrEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit - 1), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$invalidGtOrEqual = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit + 1,"-2147483646", -2.1474836460001e9) +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validGtOrEqual); $i +=2) { + $typeToTestVal = $validGtOrEqual[$i]; + $compares = $validGtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal >= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' < '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidGtOrEqual); $i +=2) { + $typeToTestVal = $invalidGtOrEqual[$i]; + $compares = $invalidGtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal >= $compareVal) { + echo "FAILED: '$typeToTestVal' >= '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_or_equal_variation_64bit.phpt b/tests/lang/operators/operator_gt_or_equal_variation_64bit.phpt index 52ef7100a6..8a1ed35f10 100644 --- a/tests/lang/operators/operator_gt_or_equal_variation_64bit.phpt +++ b/tests/lang/operators/operator_gt_or_equal_variation_64bit.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test >= operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validGtOrEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit - 1),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1),
-);
-
-$invalidGtOrEqual = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit + 1,"-2147483646", -2.1474836460001e9)
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validGtOrEqual); $i +=2) {
- $typeToTestVal = $validGtOrEqual[$i];
- $compares = $validGtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal >= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' < '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidGtOrEqual); $i +=2) {
- $typeToTestVal = $invalidGtOrEqual[$i];
- $compares = $invalidGtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal >= $compareVal) {
- echo "FAILED: '$typeToTestVal' >= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test >= operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validGtOrEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit - 1), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1), +); + +$invalidGtOrEqual = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit + 1,"-2147483646", -2.1474836460001e9) +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validGtOrEqual); $i +=2) { + $typeToTestVal = $validGtOrEqual[$i]; + $compares = $validGtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal >= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' < '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidGtOrEqual); $i +=2) { + $typeToTestVal = $invalidGtOrEqual[$i]; + $compares = $invalidGtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal >= $compareVal) { + echo "FAILED: '$typeToTestVal' >= '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_variation.phpt b/tests/lang/operators/operator_gt_variation.phpt index 1b429a076f..ff15550dbe 100644 --- a/tests/lang/operators/operator_gt_variation.phpt +++ b/tests/lang/operators/operator_gt_variation.phpt @@ -1,62 +1,62 @@ ---TEST--
-Test > operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validGreaterThan = array (
-MAX_32Bit, array(MAX_32Bit - 1, "2147483646", "2147483646.999", 2.147483646e9, 2147483646.9, MIN_32Bit),
--2147483647, array(MIN_32Bit, "-2147483648", "-2147483647.001", -2.1474836471e9, -2147483647.9),
-);
-
-$invalidGreaterThan = array (
-MAX_32Bit, array(2e33, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit + 1, MAX_32Bit)
-);
-
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validGreaterThan); $i +=2) {
- $typeToTestVal = $validGreaterThan[$i];
- $compares = $validGreaterThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal > $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' <= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidGreaterThan); $i +=2) {
- $typeToTestVal = $invalidGreaterThan[$i];
- $compares = $invalidGreaterThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal > $compareVal) {
- echo "FAILED: '$typeToTestVal' > '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test > operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validGreaterThan = array ( +MAX_32Bit, array(MAX_32Bit - 1, "2147483646", "2147483646.999", 2.147483646e9, 2147483646.9, MIN_32Bit), +-2147483647, array(MIN_32Bit, "-2147483648", "-2147483647.001", -2.1474836471e9, -2147483647.9), +); + +$invalidGreaterThan = array ( +MAX_32Bit, array(2e33, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit + 1, MAX_32Bit) +); + + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validGreaterThan); $i +=2) { + $typeToTestVal = $validGreaterThan[$i]; + $compares = $validGreaterThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal > $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' <= '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidGreaterThan); $i +=2) { + $typeToTestVal = $invalidGreaterThan[$i]; + $compares = $invalidGreaterThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal > $compareVal) { + echo "FAILED: '$typeToTestVal' > '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_gt_variation_64bit.phpt b/tests/lang/operators/operator_gt_variation_64bit.phpt index 1881567080..15c6b88319 100644 --- a/tests/lang/operators/operator_gt_variation_64bit.phpt +++ b/tests/lang/operators/operator_gt_variation_64bit.phpt @@ -1,62 +1,62 @@ ---TEST--
-Test > operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validGreaterThan = array (
-MAX_32Bit, array(MAX_32Bit - 1, "2147483646", "2147483646.999", 2.147483646e9, 2147483646.9, MIN_32Bit),
--2147483647, array(MIN_32Bit, "-2147483648", "-2147483647.001", -2.1474836471e9, -2147483647.9),
-);
-
-$invalidGreaterThan = array (
-MAX_32Bit, array(2e33, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit + 1, MAX_32Bit)
-);
-
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validGreaterThan); $i +=2) {
- $typeToTestVal = $validGreaterThan[$i];
- $compares = $validGreaterThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal > $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' <= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidGreaterThan); $i +=2) {
- $typeToTestVal = $invalidGreaterThan[$i];
- $compares = $invalidGreaterThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal > $compareVal) {
- echo "FAILED: '$typeToTestVal' > '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test > operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validGreaterThan = array ( +MAX_32Bit, array(MAX_32Bit - 1, "2147483646", "2147483646.999", 2.147483646e9, 2147483646.9, MIN_32Bit), +-2147483647, array(MIN_32Bit, "-2147483648", "-2147483647.001", -2.1474836471e9, -2147483647.9), +); + +$invalidGreaterThan = array ( +MAX_32Bit, array(2e33, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit + 1, MAX_32Bit) +); + + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validGreaterThan); $i +=2) { + $typeToTestVal = $validGreaterThan[$i]; + $compares = $validGreaterThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal > $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' <= '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidGreaterThan); $i +=2) { + $typeToTestVal = $invalidGreaterThan[$i]; + $compares = $invalidGreaterThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal > $compareVal) { + echo "FAILED: '$typeToTestVal' > '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_identical_basic.phpt b/tests/lang/operators/operator_identical_basic.phpt index dbf4c62f5b..e3a0fe272f 100644 --- a/tests/lang/operators/operator_identical_basic.phpt +++ b/tests/lang/operators/operator_identical_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test === operator : different types
---FILE--
-<?php
-
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array(679, +679);
-$valid_int2 = array(-67835);
-$invalid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", "6 7 9", "6y79", 678);
-$invalid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4, "- 67835", "-67,835", "-67 835", "-678y35", -76834);
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array(57385.45835, 5.738545835e4);
-$valid_float2 = array(-67345.76567, -6.734576567E4);
-$invalid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", "57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4);
-$invalid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", "- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4);
-
-
-$toCompare = array(
- true, array(true), array_merge($valid_true, $valid_false),
- false, array(false), array_merge($valid_true, $valid_false),
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest === $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' != '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest === $compareVal) {
- echo "FAILED: '$typeToTest' == '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test === operator : different types +--FILE-- +<?php + +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array(679, +679); +$valid_int2 = array(-67835); +$invalid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", "6 7 9", "6y79", 678); +$invalid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4, "- 67835", "-67,835", "-67 835", "-678y35", -76834); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array(57385.45835, 5.738545835e4); +$valid_float2 = array(-67345.76567, -6.734576567E4); +$invalid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", "57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4); +$invalid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", "- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4); + + +$toCompare = array( + true, array(true), array_merge($valid_true, $valid_false), + false, array(false), array_merge($valid_true, $valid_false), + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest === $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' != '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest === $compareVal) { + echo "FAILED: '$typeToTest' == '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_identical_variation.phpt b/tests/lang/operators/operator_identical_variation.phpt index f2150e956d..a215fef0a4 100644 --- a/tests/lang/operators/operator_identical_variation.phpt +++ b/tests/lang/operators/operator_identical_variation.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test === operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validIdentical = array (
-MAX_32Bit, array(MAX_32Bit),
-MIN_32Bit, array(MIN_32Bit),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$invalidIdentical = array (
-MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-);
-
-
-$failed = false;
-// test for valid values
-for ($i = 0; $i < count($validIdentical); $i +=2) {
- $typeToTestVal = $validIdentical[$i];
- $compares = $validIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal === $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' !== '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidIdentical); $i +=2) {
- $typeToTestVal = $invalidIdentical[$i];
- $compares = $invalidIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal === $compareVal) {
- echo "FAILED: '$typeToTestVal' === '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test === operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validIdentical = array ( +MAX_32Bit, array(MAX_32Bit), +MIN_32Bit, array(MIN_32Bit), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$invalidIdentical = array ( +MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +); + + +$failed = false; +// test for valid values +for ($i = 0; $i < count($validIdentical); $i +=2) { + $typeToTestVal = $validIdentical[$i]; + $compares = $validIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal === $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' !== '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidIdentical); $i +=2) { + $typeToTestVal = $invalidIdentical[$i]; + $compares = $invalidIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal === $compareVal) { + echo "FAILED: '$typeToTestVal' === '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_identical_variation_64bit.phpt b/tests/lang/operators/operator_identical_variation_64bit.phpt index 138a53a119..0c8d398daf 100644 --- a/tests/lang/operators/operator_identical_variation_64bit.phpt +++ b/tests/lang/operators/operator_identical_variation_64bit.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test === operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validIdentical = array (
-MAX_32Bit, array(MAX_32Bit),
-MIN_32Bit, array(MIN_32Bit),
-MAX_64Bit, array(MAX_64Bit),
-MIN_64Bit, array(MIN_64Bit),
-);
-
-$invalidIdentical = array (
-MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit - 1, MAX_64Bit + 1),
-MIN_64Bit, array(MIN_64Bit + 1, MIN_64Bit - 1),
-);
-
-
-$failed = false;
-// test for valid values
-for ($i = 0; $i < count($validIdentical); $i +=2) {
- $typeToTestVal = $validIdentical[$i];
- $compares = $validIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal === $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' !== '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidIdentical); $i +=2) {
- $typeToTestVal = $invalidIdentical[$i];
- $compares = $invalidIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal === $compareVal) {
- echo "FAILED: '$typeToTestVal' === '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test === operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validIdentical = array ( +MAX_32Bit, array(MAX_32Bit), +MIN_32Bit, array(MIN_32Bit), +MAX_64Bit, array(MAX_64Bit), +MIN_64Bit, array(MIN_64Bit), +); + +$invalidIdentical = array ( +MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit - 1, MAX_64Bit + 1), +MIN_64Bit, array(MIN_64Bit + 1, MIN_64Bit - 1), +); + + +$failed = false; +// test for valid values +for ($i = 0; $i < count($validIdentical); $i +=2) { + $typeToTestVal = $validIdentical[$i]; + $compares = $validIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal === $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' !== '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidIdentical); $i +=2) { + $typeToTestVal = $invalidIdentical[$i]; + $compares = $invalidIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal === $compareVal) { + echo "FAILED: '$typeToTestVal' === '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_basic.phpt b/tests/lang/operators/operator_lt_basic.phpt index 016b35dd4b..41f18ef9d2 100644 --- a/tests/lang/operators/operator_lt_basic.phpt +++ b/tests/lang/operators/operator_lt_basic.phpt @@ -1,62 +1,62 @@ ---TEST--
-Test < operator : different types
---FILE--
-<?php
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 677;
-$int2 = -67837;
-$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678);
-$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4);
-$invalid_int1 = array(676, "676");
-$invalid_int2 = array(-67837, "-67837");
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45836", "57385.45836aaa", " 57385.45836", 5.738545836e4);
-$valid_float2 = array("-67345.76566", "-67345.76566aaa", " -67345.76566", -6.734576566E4);
-$invalid_float1 = array(57385.45835, 5.738545835e4);
-$invalid_float2 = array(-67345.76567, -6.734576567E4);
-
-
-$toCompare = array(
- false, $valid_true, $valid_false,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest < $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' >= '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest < $compareVal) {
- echo "FAILED: '$typeToTest' < '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test < operator : different types +--FILE-- +<?php +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 677; +$int2 = -67837; +$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); +$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4); +$invalid_int1 = array(676, "676"); +$invalid_int2 = array(-67837, "-67837"); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45836", "57385.45836aaa", " 57385.45836", 5.738545836e4); +$valid_float2 = array("-67345.76566", "-67345.76566aaa", " -67345.76566", -6.734576566E4); +$invalid_float1 = array(57385.45835, 5.738545835e4); +$invalid_float2 = array(-67345.76567, -6.734576567E4); + + +$toCompare = array( + false, $valid_true, $valid_false, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest < $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' >= '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest < $compareVal) { + echo "FAILED: '$typeToTest' < '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_or_equal_basic.phpt b/tests/lang/operators/operator_lt_or_equal_basic.phpt index 785b9338ac..85a86e1996 100644 --- a/tests/lang/operators/operator_lt_or_equal_basic.phpt +++ b/tests/lang/operators/operator_lt_or_equal_basic.phpt @@ -1,64 +1,64 @@ ---TEST--
-Test <= operator : different types
---FILE--
-<?php
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 678;
-$int2 = -67836;
-$valid_int1 = array("679", "679abc", " 679", 679.0, 6.79E2, "678", "678abc", " 678", 678.0, 6.78E2, 6.789E2, "+678", +678);
-$valid_int2 = array("-67835", "-67835abc", " -67835", -67835.000, -6.7835E4, "-67836", "-67836abc". " -67836", -67835.0001, -6.78351E4, "-67836", -67835.0001, -6.78351E4);
-$invalid_int1 = array(677, "677");
-$invalid_int2 = array(-67874, "-67837");
-
-$float1 = 57385.45834;
-$float2 = -67345.76568;
-$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4, "57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4);
-$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4, "-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4);
-$invalid_float1 = array(57385.45833, 5.738545833e4);
-$invalid_float2 = array(-67345.76569, -6.734576569E4);
-
-$toCompare = array(
- true, $valid_true, $valid_false,
- false, array_merge($valid_false, $valid_true), NULL,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest <= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' > '$compareVal'\n";
- $failed = true;
- }
- }
-
- if ($invalid_compares != NULL) {
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest <= $compareVal) {
- echo "FAILED: '$typeToTest' <= '$compareVal'\n";
- $failed = true;
- }
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test <= operator : different types +--FILE-- +<?php +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 678; +$int2 = -67836; +$valid_int1 = array("679", "679abc", " 679", 679.0, 6.79E2, "678", "678abc", " 678", 678.0, 6.78E2, 6.789E2, "+678", +678); +$valid_int2 = array("-67835", "-67835abc", " -67835", -67835.000, -6.7835E4, "-67836", "-67836abc". " -67836", -67835.0001, -6.78351E4, "-67836", -67835.0001, -6.78351E4); +$invalid_int1 = array(677, "677"); +$invalid_int2 = array(-67874, "-67837"); + +$float1 = 57385.45834; +$float2 = -67345.76568; +$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4, "57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); +$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4, "-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4); +$invalid_float1 = array(57385.45833, 5.738545833e4); +$invalid_float2 = array(-67345.76569, -6.734576569E4); + +$toCompare = array( + true, $valid_true, $valid_false, + false, array_merge($valid_false, $valid_true), NULL, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest <= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' > '$compareVal'\n"; + $failed = true; + } + } + + if ($invalid_compares != NULL) { + foreach($invalid_compares as $compareVal) { + if ($typeToTest <= $compareVal) { + echo "FAILED: '$typeToTest' <= '$compareVal'\n"; + $failed = true; + } + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_or_equal_variation.phpt b/tests/lang/operators/operator_lt_or_equal_variation.phpt index 293205876d..5724511a0e 100644 --- a/tests/lang/operators/operator_lt_or_equal_variation.phpt +++ b/tests/lang/operators/operator_lt_or_equal_variation.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test <= operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validLtOrEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$invalidLtOrEqual = array (
-MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9)
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validLtOrEqual); $i +=2) {
- $typeToTestVal = $validLtOrEqual[$i];
- $compares = $validLtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal <= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' > '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidLtOrEqual); $i +=2) {
- $typeToTestVal = $invalidLtOrEqual[$i];
- $compares = $invalidLtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal <= $compareVal) {
- echo "FAILED: '$typeToTestVal' <= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test <= operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validLtOrEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$invalidLtOrEqual = array ( +MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9) +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validLtOrEqual); $i +=2) { + $typeToTestVal = $validLtOrEqual[$i]; + $compares = $validLtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal <= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' > '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidLtOrEqual); $i +=2) { + $typeToTestVal = $invalidLtOrEqual[$i]; + $compares = $invalidLtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal <= $compareVal) { + echo "FAILED: '$typeToTestVal' <= '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_or_equal_variation_64bit.phpt b/tests/lang/operators/operator_lt_or_equal_variation_64bit.phpt index 055cfc673b..f3b16c1fc9 100644 --- a/tests/lang/operators/operator_lt_or_equal_variation_64bit.phpt +++ b/tests/lang/operators/operator_lt_or_equal_variation_64bit.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test <= operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validLtOrEqual = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit + 1),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$invalidLtOrEqual = array (
-MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9)
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validLtOrEqual); $i +=2) {
- $typeToTestVal = $validLtOrEqual[$i];
- $compares = $validLtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal <= $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' > '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidLtOrEqual); $i +=2) {
- $typeToTestVal = $invalidLtOrEqual[$i];
- $compares = $invalidLtOrEqual[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal <= $compareVal) {
- echo "FAILED: '$typeToTestVal' <= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test <= operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validLtOrEqual = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, MAX_32Bit + 1), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$invalidLtOrEqual = array ( +MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9) +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validLtOrEqual); $i +=2) { + $typeToTestVal = $validLtOrEqual[$i]; + $compares = $validLtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal <= $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' > '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidLtOrEqual); $i +=2) { + $typeToTestVal = $invalidLtOrEqual[$i]; + $compares = $invalidLtOrEqual[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal <= $compareVal) { + echo "FAILED: '$typeToTestVal' <= '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_variation.phpt b/tests/lang/operators/operator_lt_variation.phpt index 62fedfad5a..4f468638dc 100644 --- a/tests/lang/operators/operator_lt_variation.phpt +++ b/tests/lang/operators/operator_lt_variation.phpt @@ -1,60 +1,60 @@ ---TEST--
-Test < operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validLessThan = array (
-2147483646, array(MAX_32Bit, "2147483647", "2147483647.001", 2.147483647e9, 2147483647.9),
-MIN_32Bit, array(MIN_32Bit + 1, "-2147483647", "-2147483646.001", -2.1474836461e9, -2147483646.9),
-);
-
-$invalidLessThan = array (
-MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9)
-);
-
-$failed = false;
-// test for equality
-for ($i = 0; $i < count($validLessThan); $i +=2) {
- $typeToTestVal = $validLessThan[$i];
- $compares = $validLessThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal < $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' >= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidLessThan); $i +=2) {
- $typeToTestVal = $invalidLessThan[$i];
- $compares = $invalidLessThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal < $compareVal) {
- echo "FAILED: '$typeToTestVal' < '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test < operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validLessThan = array ( +2147483646, array(MAX_32Bit, "2147483647", "2147483647.001", 2.147483647e9, 2147483647.9), +MIN_32Bit, array(MIN_32Bit + 1, "-2147483647", "-2147483646.001", -2.1474836461e9, -2147483646.9), +); + +$invalidLessThan = array ( +MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9) +); + +$failed = false; +// test for equality +for ($i = 0; $i < count($validLessThan); $i +=2) { + $typeToTestVal = $validLessThan[$i]; + $compares = $validLessThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal < $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' >= '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidLessThan); $i +=2) { + $typeToTestVal = $invalidLessThan[$i]; + $compares = $invalidLessThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal < $compareVal) { + echo "FAILED: '$typeToTestVal' < '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_lt_variation_64bit.phpt b/tests/lang/operators/operator_lt_variation_64bit.phpt index e6f16a3883..3ee274aea0 100644 --- a/tests/lang/operators/operator_lt_variation_64bit.phpt +++ b/tests/lang/operators/operator_lt_variation_64bit.phpt @@ -1,60 +1,60 @@ ---TEST--
-Test < operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$validLessThan = array (
-2147483646, array(MAX_32Bit, "2147483647", "2147483647.001", 2.147483647e9, 2147483647.9),
-MIN_32Bit, array(MIN_32Bit + 1, "-2147483647", "-2147483646.001", -2.1474836461e9, -2147483646.9),
-);
-
-$invalidLessThan = array (
-MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1),
-MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9)
-);
-
-$failed = false;
-// test for equality
-for ($i = 0; $i < count($validLessThan); $i +=2) {
- $typeToTestVal = $validLessThan[$i];
- $compares = $validLessThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal < $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' >= '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidLessThan); $i +=2) {
- $typeToTestVal = $invalidLessThan[$i];
- $compares = $invalidLessThan[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal < $compareVal) {
- echo "FAILED: '$typeToTestVal' < '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test < operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$validLessThan = array ( +2147483646, array(MAX_32Bit, "2147483647", "2147483647.001", 2.147483647e9, 2147483647.9), +MIN_32Bit, array(MIN_32Bit + 1, "-2147483647", "-2147483646.001", -2.1474836461e9, -2147483646.9), +); + +$invalidLessThan = array ( +MAX_32Bit, array("2147483646", 2.1474836460001e9, MAX_32Bit - 1), +MIN_32Bit, array(MIN_32Bit - 1, "-2147483649", -2.1474836480001e9) +); + +$failed = false; +// test for equality +for ($i = 0; $i < count($validLessThan); $i +=2) { + $typeToTestVal = $validLessThan[$i]; + $compares = $validLessThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal < $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' >= '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidLessThan); $i +=2) { + $typeToTestVal = $invalidLessThan[$i]; + $compares = $invalidLessThan[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal < $compareVal) { + echo "FAILED: '$typeToTestVal' < '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notequals_basic.phpt b/tests/lang/operators/operator_notequals_basic.phpt index 80754dacb4..cef0be6279 100644 --- a/tests/lang/operators/operator_notequals_basic.phpt +++ b/tests/lang/operators/operator_notequals_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test != operator : different types
---FILE--
-<?php
-
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("6 7 9", "6y79", 678);
-$valid_int2 = array("- 67835", "-67,835", "-67 835", "-678y35", -76834);
-$invalid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", +679);
-$invalid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4);
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4);
-$valid_float2 = array("- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4);
-$invalid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4);
-$invalid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4);
-
-
-$toCompare = array(
- true, $valid_false, $valid_true,
- false, $valid_true, $valid_false,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest != $compareVal && $typeToTest <> $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' == '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest != $compareVal || $typeToTest <> $compareVal) {
- echo "FAILED: '$typeToTest' != '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test != operator : different types +--FILE-- +<?php + +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("6 7 9", "6y79", 678); +$valid_int2 = array("- 67835", "-67,835", "-67 835", "-678y35", -76834); +$invalid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", +679); +$invalid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4); +$valid_float2 = array("- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4); +$invalid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", 5.738545835e4); +$invalid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", -6.734576567E4); + + +$toCompare = array( + true, $valid_false, $valid_true, + false, $valid_true, $valid_false, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest != $compareVal && $typeToTest <> $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' == '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest != $compareVal || $typeToTest <> $compareVal) { + echo "FAILED: '$typeToTest' != '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notequals_variation.phpt b/tests/lang/operators/operator_notequals_variation.phpt index 2a0b57035d..25bbfc5859 100644 --- a/tests/lang/operators/operator_notequals_variation.phpt +++ b/tests/lang/operators/operator_notequals_variation.phpt @@ -1,63 +1,63 @@ ---TEST--
-Test != operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$invalidNotEquals = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$validNotEquals = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validNotEquals); $i +=2) {
- $typeToTestVal = $validNotEquals[$i];
- $compares = $validNotEquals[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal != $compareVal && $typeToTestVal != $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' == '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidNotEquals); $i +=2) {
- $typeToTestVal = $invalidNotEquals[$i];
- $compares = $invalidNotEquals[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal != $compareVal || $typeToTestVal != $compareVal) {
- echo "FAILED: '$typeToTestVal' != '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test != operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$invalidNotEquals = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$validNotEquals = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validNotEquals); $i +=2) { + $typeToTestVal = $validNotEquals[$i]; + $compares = $validNotEquals[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal != $compareVal && $typeToTestVal != $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' == '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidNotEquals); $i +=2) { + $typeToTestVal = $invalidNotEquals[$i]; + $compares = $invalidNotEquals[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal != $compareVal || $typeToTestVal != $compareVal) { + echo "FAILED: '$typeToTestVal' != '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notequals_variation_64bit.phpt b/tests/lang/operators/operator_notequals_variation_64bit.phpt index 16ec925cb8..6fbc496fa5 100644 --- a/tests/lang/operators/operator_notequals_variation_64bit.phpt +++ b/tests/lang/operators/operator_notequals_variation_64bit.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test == operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$invalidNotEquals = array (
-MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9),
-MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1),
-);
-
-$validNotEquals = array (
-MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit + 1),
-);
-
-
-$failed = false;
-// test valid values
-for ($i = 0; $i < count($validNotEquals); $i +=2) {
- $typeToTestVal = $validNotEquals[$i];
- $compares = $validNotEquals[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal != $compareVal && $typeToTestVal <> $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' == '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test invalid values
-for ($i = 0; $i < count($invalidNotEquals); $i +=2) {
- $typeToTestVal = $invalidNotEquals[$i];
- $compares = $invalidNotEquals[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal != $compareVal || $typeToTestVal <> $compareVal) {
- echo "FAILED: '$typeToTestVal' != '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test == operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$invalidNotEquals = array ( +MAX_32Bit, array(MAX_32Bit, "2147483647", "2147483647.0000000", 2.147483647e9), +MIN_32Bit, array(MIN_32Bit, "-2147483648", "-2147483648.000", -2.147483648e9), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1), +); + +$validNotEquals = array ( +MAX_32Bit, array("2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit + 1), +); + + +$failed = false; +// test valid values +for ($i = 0; $i < count($validNotEquals); $i +=2) { + $typeToTestVal = $validNotEquals[$i]; + $compares = $validNotEquals[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal != $compareVal && $typeToTestVal <> $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTestVal' == '$compareVal'\n"; + $failed = true; + } + } +} +// test invalid values +for ($i = 0; $i < count($invalidNotEquals); $i +=2) { + $typeToTestVal = $invalidNotEquals[$i]; + $compares = $invalidNotEquals[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal != $compareVal || $typeToTestVal <> $compareVal) { + echo "FAILED: '$typeToTestVal' != '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notidentical_basic.phpt b/tests/lang/operators/operator_notidentical_basic.phpt index 143d72038b..9f21ea4bca 100644 --- a/tests/lang/operators/operator_notidentical_basic.phpt +++ b/tests/lang/operators/operator_notidentical_basic.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test !== operator : different types
---FILE--
-<?php
-
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", "6 7 9", "6y79", 678);
-$valid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4, "- 67835", "-67,835", "-67 835", "-678y35", -76834);
-$invalid_int1 = array(679, +679);
-$invalid_int2 = array(-67835);
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", "57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4);
-$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", "- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4);
-$invalid_float1 = array(57385.45835, 5.738545835e4);
-$invalid_float2 = array(-67345.76567, -6.734576567E4);
-
-
-$toCompare = array(
- true, array_merge($valid_true, $valid_false), array(true),
- false, array_merge($valid_true, $valid_false), array(false),
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if ($typeToTest !== $compareVal) {
- // do nothing
- }
- else {
- echo "FAILED: '$typeToTest' === '$compareVal'\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if ($typeToTest !== $compareVal) {
- echo "FAILED: '$typeToTest' !== '$compareVal'\n";
- $failed = true;
- }
- }
-
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test !== operator : different types +--FILE-- +<?php + +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("679", "679abc", " 679", "679 ", 679.0, 6.79E2, "+679", "6 7 9", "6y79", 678); +$valid_int2 = array("-67835", "-67835abc", " -67835", "-67835 ", -67835.000, -6.7835E4, "- 67835", "-67,835", "-67 835", "-678y35", -76834); +$invalid_int1 = array(679, +679); +$invalid_int2 = array(-67835); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45835", "57385.45835aaa", " 57385.45835", "57385. 45835", "57,385.45835", 57385.45834, 5.738545834e4); +$valid_float2 = array("-67345.76567", "-67345.76567aaa", " -67345.76567", "- 67345.76567", "-67,345.76567", -67345.76566, -6.734576566E4); +$invalid_float1 = array(57385.45835, 5.738545835e4); +$invalid_float2 = array(-67345.76567, -6.734576567E4); + + +$toCompare = array( + true, array_merge($valid_true, $valid_false), array(true), + false, array_merge($valid_true, $valid_false), array(false), + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if ($typeToTest !== $compareVal) { + // do nothing + } + else { + echo "FAILED: '$typeToTest' === '$compareVal'\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if ($typeToTest !== $compareVal) { + echo "FAILED: '$typeToTest' !== '$compareVal'\n"; + $failed = true; + } + } + +} +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notidentical_variation.phpt b/tests/lang/operators/operator_notidentical_variation.phpt index 702797ec8d..a9fbcf60e1 100644 --- a/tests/lang/operators/operator_notidentical_variation.phpt +++ b/tests/lang/operators/operator_notidentical_variation.phpt @@ -1,64 +1,64 @@ ---TEST--
-Test !== operator : max int 32bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$invalidNotIdentical = array (
-MAX_32Bit, array(MAX_32Bit),
-MIN_32Bit, array(MIN_32Bit),
-MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1),
-MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1),
-);
-
-$validNotIdentical = array (
-MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-);
-
-
-$failed = false;
-// test for valid values
-for ($i = 0; $i < count($validNotIdentical); $i +=2) {
- $typeToTestVal = $validNotIdentical[$i];
- $compares = $validNotIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal !== $compareVal) {
- //Do Nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' === '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidNotIdentical); $i +=2) {
- $typeToTestVal = $invalidNotIdentical[$i];
- $compares = $invalidNotIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal !== $compareVal) {
- echo "FAILED: '$typeToTestVal' !== '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test !== operator : max int 32bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$invalidNotIdentical = array ( +MAX_32Bit, array(MAX_32Bit), +MIN_32Bit, array(MIN_32Bit), +MAX_64Bit, array(MAX_64Bit, MAX_64Bit + 1, MAX_64Bit - 1), +MIN_64Bit, array(MIN_64Bit, MIN_64Bit - 1, MIN_64Bit + 1), +); + +$validNotIdentical = array ( +MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +); + + +$failed = false; +// test for valid values +for ($i = 0; $i < count($validNotIdentical); $i +=2) { + $typeToTestVal = $validNotIdentical[$i]; + $compares = $validNotIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal !== $compareVal) { + //Do Nothing + } + else { + echo "FAILED: '$typeToTestVal' === '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidNotIdentical); $i +=2) { + $typeToTestVal = $invalidNotIdentical[$i]; + $compares = $invalidNotIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal !== $compareVal) { + echo "FAILED: '$typeToTestVal' !== '$compareVal'\n"; + $failed = true; + } + } +} + + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_notidentical_variation_64bit.phpt b/tests/lang/operators/operator_notidentical_variation_64bit.phpt index 8a60cfdbb4..aa5aab7a59 100644 --- a/tests/lang/operators/operator_notidentical_variation_64bit.phpt +++ b/tests/lang/operators/operator_notidentical_variation_64bit.phpt @@ -1,65 +1,65 @@ ---TEST--
-Test !== operator : max int 64bit range
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$invalidNotIdentical = array (
-MAX_32Bit, array(MAX_32Bit),
-MIN_32Bit, array(MIN_32Bit),
-MAX_64Bit, array(MAX_64Bit),
-MIN_64Bit, array(MIN_64Bit),
-);
-
-$validNotIdentical = array (
-MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1),
-MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1),
-MAX_64Bit, array(MAX_64Bit - 1, MAX_64Bit + 1),
-MIN_64Bit, array(MIN_64Bit + 1, MIN_64Bit - 1),
-);
-
-
-$failed = false;
-// test for valid values
-for ($i = 0; $i < count($validNotIdentical); $i +=2) {
- $typeToTestVal = $validNotIdentical[$i];
- $compares = $validNotIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal !== $compareVal) {
- //Do Nothing
- }
- else {
- echo "FAILED: '$typeToTestVal' === '$compareVal'\n";
- $failed = true;
- }
- }
-}
-// test for invalid values
-for ($i = 0; $i < count($invalidNotIdentical); $i +=2) {
- $typeToTestVal = $invalidNotIdentical[$i];
- $compares = $invalidNotIdentical[$i + 1];
- foreach($compares as $compareVal) {
- if ($typeToTestVal !== $compareVal) {
- echo "FAILED: '$typeToTestVal' !== '$compareVal'\n";
- $failed = true;
- }
- }
-}
-
-if ($failed == false) {
- echo "Test Passed\n";
-}
-
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test !== operator : max int 64bit range +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$invalidNotIdentical = array ( +MAX_32Bit, array(MAX_32Bit), +MIN_32Bit, array(MIN_32Bit), +MAX_64Bit, array(MAX_64Bit), +MIN_64Bit, array(MIN_64Bit), +); + +$validNotIdentical = array ( +MAX_32Bit, array("2147483647", "2147483647.0000000", 2.147483647e9, 2147483647.0, "2147483648", 2.1474836470001e9, MAX_32Bit - 1, MAX_32Bit + 1), +MIN_32Bit, array("-2147483648", "-2147483648.000", -2.147483648e9, -2147483648.0, "-2147483649", -2.1474836480001e9, MIN_32Bit -1, MIN_32Bit + 1), +MAX_64Bit, array(MAX_64Bit - 1, MAX_64Bit + 1), +MIN_64Bit, array(MIN_64Bit + 1, MIN_64Bit - 1), +); + + +$failed = false; +// test for valid values +for ($i = 0; $i < count($validNotIdentical); $i +=2) { + $typeToTestVal = $validNotIdentical[$i]; + $compares = $validNotIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal !== $compareVal) { + //Do Nothing + } + else { + echo "FAILED: '$typeToTestVal' === '$compareVal'\n"; + $failed = true; + } + } +} +// test for invalid values +for ($i = 0; $i < count($invalidNotIdentical); $i +=2) { + $typeToTestVal = $invalidNotIdentical[$i]; + $compares = $invalidNotIdentical[$i + 1]; + foreach($compares as $compareVal) { + if ($typeToTestVal !== $compareVal) { + echo "FAILED: '$typeToTestVal' !== '$compareVal'\n"; + $failed = true; + } + } +} + +if ($failed == false) { + echo "Test Passed\n"; +} + +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/operator_spaceship_basic.phpt b/tests/lang/operators/operator_spaceship_basic.phpt index 3dbdbb4197..81b0516757 100644 --- a/tests/lang/operators/operator_spaceship_basic.phpt +++ b/tests/lang/operators/operator_spaceship_basic.phpt @@ -1,94 +1,94 @@ ---TEST--
-Test <=> operator : different types
---FILE--
-<?php
-$valid_true = array(1, "1", "true", 1.0, array(1));
-$valid_false = array(0, "", 0.0, array(), NULL);
-
-$int1 = 679;
-$int2 = -67835;
-$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678);
-$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4);
-$invalid_int1 = array(679, "679");
-$invalid_int2 = array(-67835, "-67835");
-
-$float1 = 57385.45835;
-$float2 = -67345.76567;
-$valid_float1 = array("57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4);
-$valid_float2 = array("-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4);
-$invalid_float1 = array(57385.45835, 5.738545835e4);
-$invalid_float2 = array(-67345.76567, -6.734576567E4);
-
-
-$toCompare = array(
-// boolean test will result in both sides being converted to boolean so !0 = true and true is not > true for example
-// also note that a string of "0" is converted to false but a string of "0.0" is converted to true
-// false cannot be tested as 0 can never be > 0 or 1
- true, $valid_false, $valid_true,
- $int1, $valid_int1, $invalid_int1,
- $int2, $valid_int2, $invalid_int2,
- $float1, $valid_float1, $invalid_float1,
- $float2, $valid_float2, $invalid_float2
-);
-
-$failed = false;
-for ($i = 0; $i < count($toCompare); $i +=3) {
- $typeToTest = $toCompare[$i];
- $valid_compares = $toCompare[$i + 1];
- $invalid_compares = $toCompare[$i + 2];
-
- foreach($valid_compares as $compareVal) {
- if (($typeToTest <=> $compareVal) === 1) {
- // do nothing
- }
- else {
- echo "FAILED: ('$typeToTest' <=> '$compareVal') !== 1\n";
- $failed = true;
- }
- if (($compareVal <=> $typeToTest) === -1) {
- // do nothing
- }
- else {
- echo "FAILED: ('$compareVal' <=> '$typeToTest') !== -1\n";
- $failed = true;
- }
- if (($compareVal <=> $compareVal) === 0) {
- // do nothing
- }
- else {
- echo "FAILED: ('$compareVal' <=> '$compareVal') !== 0\n";
- $failed = true;
- }
- }
-
- foreach($invalid_compares as $compareVal) {
- if (($typeToTest <=> $compareVal) === 1) {
- echo "FAILED: ('$typeToTest' <=> '$compareVal') === 1\n";
- $failed = true;
- }
- if (($compareVal <=> $typeToTest) === -1) {
- echo "FAILED: ('$compareVal' <=> '$typeToTest') === -1\n";
- $failed = true;
- }
- if (($compareVal <=> $compareVal) !== 0) {
- echo "FAILED: ('$compareVal' <=> '$compareVal') !== 0\n";
- $failed = true;
- }
- }
-
- if (($typeToTest <=> $typeToTest) === 0) {
- // do nothing
- }
- else {
- echo "FAILED: ('$typeToTest' <=> '$typeToTest') !== 0\n";
- $failed = true;
- }
-}
-if ($failed == false) {
- echo "Test Passed\n";
-}
-?>
-===DONE===
---EXPECT--
-Test Passed
+--TEST-- +Test <=> operator : different types +--FILE-- +<?php +$valid_true = array(1, "1", "true", 1.0, array(1)); +$valid_false = array(0, "", 0.0, array(), NULL); + +$int1 = 679; +$int2 = -67835; +$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); +$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4); +$invalid_int1 = array(679, "679"); +$invalid_int2 = array(-67835, "-67835"); + +$float1 = 57385.45835; +$float2 = -67345.76567; +$valid_float1 = array("57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); +$valid_float2 = array("-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4); +$invalid_float1 = array(57385.45835, 5.738545835e4); +$invalid_float2 = array(-67345.76567, -6.734576567E4); + + +$toCompare = array( +// boolean test will result in both sides being converted to boolean so !0 = true and true is not > true for example +// also note that a string of "0" is converted to false but a string of "0.0" is converted to true +// false cannot be tested as 0 can never be > 0 or 1 + true, $valid_false, $valid_true, + $int1, $valid_int1, $invalid_int1, + $int2, $valid_int2, $invalid_int2, + $float1, $valid_float1, $invalid_float1, + $float2, $valid_float2, $invalid_float2 +); + +$failed = false; +for ($i = 0; $i < count($toCompare); $i +=3) { + $typeToTest = $toCompare[$i]; + $valid_compares = $toCompare[$i + 1]; + $invalid_compares = $toCompare[$i + 2]; + + foreach($valid_compares as $compareVal) { + if (($typeToTest <=> $compareVal) === 1) { + // do nothing + } + else { + echo "FAILED: ('$typeToTest' <=> '$compareVal') !== 1\n"; + $failed = true; + } + if (($compareVal <=> $typeToTest) === -1) { + // do nothing + } + else { + echo "FAILED: ('$compareVal' <=> '$typeToTest') !== -1\n"; + $failed = true; + } + if (($compareVal <=> $compareVal) === 0) { + // do nothing + } + else { + echo "FAILED: ('$compareVal' <=> '$compareVal') !== 0\n"; + $failed = true; + } + } + + foreach($invalid_compares as $compareVal) { + if (($typeToTest <=> $compareVal) === 1) { + echo "FAILED: ('$typeToTest' <=> '$compareVal') === 1\n"; + $failed = true; + } + if (($compareVal <=> $typeToTest) === -1) { + echo "FAILED: ('$compareVal' <=> '$typeToTest') === -1\n"; + $failed = true; + } + if (($compareVal <=> $compareVal) !== 0) { + echo "FAILED: ('$compareVal' <=> '$compareVal') !== 0\n"; + $failed = true; + } + } + + if (($typeToTest <=> $typeToTest) === 0) { + // do nothing + } + else { + echo "FAILED: ('$typeToTest' <=> '$typeToTest') !== 0\n"; + $failed = true; + } +} +if ($failed == false) { + echo "Test Passed\n"; +} +?> +===DONE=== +--EXPECT-- +Test Passed ===DONE=== diff --git a/tests/lang/operators/postdec_basiclong_64bit.phpt b/tests/lang/operators/postdec_basiclong_64bit.phpt index 9875df85ae..f3e825ca3d 100644 --- a/tests/lang/operators/postdec_basiclong_64bit.phpt +++ b/tests/lang/operators/postdec_basiclong_64bit.phpt @@ -1,61 +1,61 @@ ---TEST--
-Test N-- operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-
-foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- $longVal--;
- var_dump($longVal);
-}
-
-?>
-===DONE===
---EXPECT--
---- testing: 9223372036854775807 ---
-int(9223372036854775806)
---- testing: -9223372036854775808 ---
-float(-9.2233720368548E+18)
---- testing: 2147483647 ---
-int(2147483646)
---- testing: -2147483648 ---
-int(-2147483649)
---- testing: 9223372034707292160 ---
-int(9223372034707292159)
---- testing: -9223372034707292160 ---
-int(-9223372034707292161)
---- testing: 2147483648 ---
-int(2147483647)
---- testing: -2147483649 ---
-int(-2147483650)
---- testing: 4294967294 ---
-int(4294967293)
---- testing: 4294967295 ---
-int(4294967294)
---- testing: 4294967293 ---
-int(4294967292)
---- testing: 9223372036854775806 ---
-int(9223372036854775805)
---- testing: 9.2233720368548E+18 ---
-float(9.2233720368548E+18)
---- testing: -9223372036854775807 ---
-int(-9223372036854775808)
---- testing: -9.2233720368548E+18 ---
-float(-9.2233720368548E+18)
-===DONE===
+--TEST-- +Test N-- operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + + +foreach ($longVals as $longVal) { + echo "--- testing: $longVal ---\n"; + $longVal--; + var_dump($longVal); +} + +?> +===DONE=== +--EXPECT-- +--- testing: 9223372036854775807 --- +int(9223372036854775806) +--- testing: -9223372036854775808 --- +float(-9.2233720368548E+18) +--- testing: 2147483647 --- +int(2147483646) +--- testing: -2147483648 --- +int(-2147483649) +--- testing: 9223372034707292160 --- +int(9223372034707292159) +--- testing: -9223372034707292160 --- +int(-9223372034707292161) +--- testing: 2147483648 --- +int(2147483647) +--- testing: -2147483649 --- +int(-2147483650) +--- testing: 4294967294 --- +int(4294967293) +--- testing: 4294967295 --- +int(4294967294) +--- testing: 4294967293 --- +int(4294967292) +--- testing: 9223372036854775806 --- +int(9223372036854775805) +--- testing: 9.2233720368548E+18 --- +float(9.2233720368548E+18) +--- testing: -9223372036854775807 --- +int(-9223372036854775808) +--- testing: -9.2233720368548E+18 --- +float(-9.2233720368548E+18) +===DONE=== diff --git a/tests/lang/operators/postdec_variationStr.phpt b/tests/lang/operators/postdec_variationStr.phpt index ee5a8cd4b7..0db326d27e 100644 --- a/tests/lang/operators/postdec_variationStr.phpt +++ b/tests/lang/operators/postdec_variationStr.phpt @@ -1,49 +1,49 @@ ---TEST--
-Test N-- operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-
-foreach ($strVals as $strVal) {
- echo "--- testing: '$strVal' ---\n";
- $strVal--;
- var_dump($strVal);
-}
-
-?>
-===DONE===
---EXPECT--
---- testing: '0' ---
-int(-1)
---- testing: '65' ---
-int(64)
---- testing: '-44' ---
-int(-45)
---- testing: '1.2' ---
-float(0.2)
---- testing: '-7.7' ---
-float(-8.7)
---- testing: 'abc' ---
-string(3) "abc"
---- testing: '123abc' ---
-string(6) "123abc"
---- testing: '123e5' ---
-float(12299999)
---- testing: '123e5xyz' ---
-string(8) "123e5xyz"
---- testing: ' 123abc' ---
-string(7) " 123abc"
---- testing: '123 abc' ---
-string(7) "123 abc"
---- testing: '123abc ' ---
-string(7) "123abc "
---- testing: '3.4a' ---
-string(4) "3.4a"
---- testing: 'a5.9' ---
-string(4) "a5.9"
-===DONE===
+--TEST-- +Test N-- operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + + +foreach ($strVals as $strVal) { + echo "--- testing: '$strVal' ---\n"; + $strVal--; + var_dump($strVal); +} + +?> +===DONE=== +--EXPECT-- +--- testing: '0' --- +int(-1) +--- testing: '65' --- +int(64) +--- testing: '-44' --- +int(-45) +--- testing: '1.2' --- +float(0.2) +--- testing: '-7.7' --- +float(-8.7) +--- testing: 'abc' --- +string(3) "abc" +--- testing: '123abc' --- +string(6) "123abc" +--- testing: '123e5' --- +float(12299999) +--- testing: '123e5xyz' --- +string(8) "123e5xyz" +--- testing: ' 123abc' --- +string(7) " 123abc" +--- testing: '123 abc' --- +string(7) "123 abc" +--- testing: '123abc ' --- +string(7) "123abc " +--- testing: '3.4a' --- +string(4) "3.4a" +--- testing: 'a5.9' --- +string(4) "a5.9" +===DONE=== diff --git a/tests/lang/operators/postinc_basiclong_64bit.phpt b/tests/lang/operators/postinc_basiclong_64bit.phpt index 494259acd8..18e8bddedd 100644 --- a/tests/lang/operators/postinc_basiclong_64bit.phpt +++ b/tests/lang/operators/postinc_basiclong_64bit.phpt @@ -1,61 +1,61 @@ ---TEST--
-Test N++ operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-
-foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- $longVal++;
- var_dump($longVal);
-}
-
-?>
-===DONE===
---EXPECT--
---- testing: 9223372036854775807 ---
-float(9.2233720368548E+18)
---- testing: -9223372036854775808 ---
-int(-9223372036854775807)
---- testing: 2147483647 ---
-int(2147483648)
---- testing: -2147483648 ---
-int(-2147483647)
---- testing: 9223372034707292160 ---
-int(9223372034707292161)
---- testing: -9223372034707292160 ---
-int(-9223372034707292159)
---- testing: 2147483648 ---
-int(2147483649)
---- testing: -2147483649 ---
-int(-2147483648)
---- testing: 4294967294 ---
-int(4294967295)
---- testing: 4294967295 ---
-int(4294967296)
---- testing: 4294967293 ---
-int(4294967294)
---- testing: 9223372036854775806 ---
-int(9223372036854775807)
---- testing: 9.2233720368548E+18 ---
-float(9.2233720368548E+18)
---- testing: -9223372036854775807 ---
-int(-9223372036854775806)
---- testing: -9.2233720368548E+18 ---
-float(-9.2233720368548E+18)
-===DONE===
+--TEST-- +Test N++ operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + + +foreach ($longVals as $longVal) { + echo "--- testing: $longVal ---\n"; + $longVal++; + var_dump($longVal); +} + +?> +===DONE=== +--EXPECT-- +--- testing: 9223372036854775807 --- +float(9.2233720368548E+18) +--- testing: -9223372036854775808 --- +int(-9223372036854775807) +--- testing: 2147483647 --- +int(2147483648) +--- testing: -2147483648 --- +int(-2147483647) +--- testing: 9223372034707292160 --- +int(9223372034707292161) +--- testing: -9223372034707292160 --- +int(-9223372034707292159) +--- testing: 2147483648 --- +int(2147483649) +--- testing: -2147483649 --- +int(-2147483648) +--- testing: 4294967294 --- +int(4294967295) +--- testing: 4294967295 --- +int(4294967296) +--- testing: 4294967293 --- +int(4294967294) +--- testing: 9223372036854775806 --- +int(9223372036854775807) +--- testing: 9.2233720368548E+18 --- +float(9.2233720368548E+18) +--- testing: -9223372036854775807 --- +int(-9223372036854775806) +--- testing: -9.2233720368548E+18 --- +float(-9.2233720368548E+18) +===DONE=== diff --git a/tests/lang/operators/postinc_variationStr.phpt b/tests/lang/operators/postinc_variationStr.phpt index 6fbe804319..35e19888e1 100644 --- a/tests/lang/operators/postinc_variationStr.phpt +++ b/tests/lang/operators/postinc_variationStr.phpt @@ -1,49 +1,49 @@ ---TEST--
-Test N++ operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-
-foreach ($strVals as $strVal) {
- echo "--- testing: '$strVal' ---\n";
- $strVal++;
- var_dump($strVal);
-}
-
-?>
-===DONE===
---EXPECT--
---- testing: '0' ---
-int(1)
---- testing: '65' ---
-int(66)
---- testing: '-44' ---
-int(-43)
---- testing: '1.2' ---
-float(2.2)
---- testing: '-7.7' ---
-float(-6.7)
---- testing: 'abc' ---
-string(3) "abd"
---- testing: '123abc' ---
-string(6) "123abd"
---- testing: '123e5' ---
-float(12300001)
---- testing: '123e5xyz' ---
-string(8) "123e5xza"
---- testing: ' 123abc' ---
-string(7) " 123abd"
---- testing: '123 abc' ---
-string(7) "123 abd"
---- testing: '123abc ' ---
-string(7) "123abc "
---- testing: '3.4a' ---
-string(4) "3.4b"
---- testing: 'a5.9' ---
-string(4) "a5.0"
-===DONE===
+--TEST-- +Test N++ operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + + +foreach ($strVals as $strVal) { + echo "--- testing: '$strVal' ---\n"; + $strVal++; + var_dump($strVal); +} + +?> +===DONE=== +--EXPECT-- +--- testing: '0' --- +int(1) +--- testing: '65' --- +int(66) +--- testing: '-44' --- +int(-43) +--- testing: '1.2' --- +float(2.2) +--- testing: '-7.7' --- +float(-6.7) +--- testing: 'abc' --- +string(3) "abd" +--- testing: '123abc' --- +string(6) "123abd" +--- testing: '123e5' --- +float(12300001) +--- testing: '123e5xyz' --- +string(8) "123e5xza" +--- testing: ' 123abc' --- +string(7) " 123abd" +--- testing: '123 abc' --- +string(7) "123 abd" +--- testing: '123abc ' --- +string(7) "123abc " +--- testing: '3.4a' --- +string(4) "3.4b" +--- testing: 'a5.9' --- +string(4) "a5.0" +===DONE=== diff --git a/tests/lang/operators/predec_basiclong_64bit.phpt b/tests/lang/operators/predec_basiclong_64bit.phpt index c1b15fdf34..b2b11709b3 100644 --- a/tests/lang/operators/predec_basiclong_64bit.phpt +++ b/tests/lang/operators/predec_basiclong_64bit.phpt @@ -1,32 +1,32 @@ ---TEST--
-Test --N operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-
-foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- var_dump(--$longVal);
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test --N operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + + +foreach ($longVals as $longVal) { + echo "--- testing: $longVal ---\n"; + var_dump(--$longVal); +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 --- int(9223372036854775806) --- testing: -9223372036854775808 --- @@ -56,5 +56,5 @@ float(9.2233720368548E+18) --- testing: -9223372036854775807 --- int(-9223372036854775808) --- testing: -9.2233720368548E+18 --- -float(-9.2233720368548E+18)
-===DONE===
+float(-9.2233720368548E+18) +===DONE=== diff --git a/tests/lang/operators/predec_variationStr.phpt b/tests/lang/operators/predec_variationStr.phpt index c7fb5744a0..1d1fade74d 100644 --- a/tests/lang/operators/predec_variationStr.phpt +++ b/tests/lang/operators/predec_variationStr.phpt @@ -1,22 +1,22 @@ ---TEST--
-Test --N operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-
-foreach ($strVals as $strVal) {
- echo "--- testing: '$strVal' ---\n";
- var_dump(--$strVal);
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test --N operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + + +foreach ($strVals as $strVal) { + echo "--- testing: '$strVal' ---\n"; + var_dump(--$strVal); +} + +?> +===DONE=== +--EXPECT-- --- testing: '0' --- int(-1) --- testing: '65' --- @@ -44,5 +44,5 @@ string(7) "123abc " --- testing: '3.4a' --- string(4) "3.4a" --- testing: 'a5.9' --- -string(4) "a5.9"
-===DONE===
+string(4) "a5.9" +===DONE=== diff --git a/tests/lang/operators/preinc_basiclong_64bit.phpt b/tests/lang/operators/preinc_basiclong_64bit.phpt index 599aa4e001..e24cc283aa 100644 --- a/tests/lang/operators/preinc_basiclong_64bit.phpt +++ b/tests/lang/operators/preinc_basiclong_64bit.phpt @@ -1,32 +1,32 @@ ---TEST--
-Test ++N operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-
-foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- var_dump(++$longVal);
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test ++N operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + + +foreach ($longVals as $longVal) { + echo "--- testing: $longVal ---\n"; + var_dump(++$longVal); +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 --- float(9.2233720368548E+18) --- testing: -9223372036854775808 --- @@ -56,5 +56,5 @@ float(9.2233720368548E+18) --- testing: -9223372036854775807 --- int(-9223372036854775806) --- testing: -9.2233720368548E+18 --- -float(-9.2233720368548E+18)
-===DONE===
+float(-9.2233720368548E+18) +===DONE=== diff --git a/tests/lang/operators/subtract_basiclong_64bit.phpt b/tests/lang/operators/subtract_basiclong_64bit.phpt index f52b951442..ca80e3f52d 100644 --- a/tests/lang/operators/subtract_basiclong_64bit.phpt +++ b/tests/lang/operators/subtract_basiclong_64bit.phpt @@ -1,44 +1,44 @@ ---TEST--
-Test - operator : 64bit long tests
---SKIPIF--
-<?php
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
-?>
---FILE--
-<?php
-
-define("MAX_64Bit", 9223372036854775807);
-define("MAX_32Bit", 2147483647);
-define("MIN_64Bit", -9223372036854775807 - 1);
-define("MIN_32Bit", -2147483647 - 1);
-
-$longVals = array(
- MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit,
- MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1,
- MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1
-);
-
-$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit);
-
-error_reporting(E_ERROR);
-
-foreach ($longVals as $longVal) {
- foreach($otherVals as $otherVal) {
- echo "--- testing: $longVal - $otherVal ---\n";
- var_dump($longVal-$otherVal);
- }
-}
-
-foreach ($otherVals as $otherVal) {
- foreach($longVals as $longVal) {
- echo "--- testing: $otherVal - $longVal ---\n";
- var_dump($otherVal-$longVal);
- }
-}
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test - operator : 64bit long tests +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +?> +--FILE-- +<?php + +define("MAX_64Bit", 9223372036854775807); +define("MAX_32Bit", 2147483647); +define("MIN_64Bit", -9223372036854775807 - 1); +define("MIN_32Bit", -2147483647 - 1); + +$longVals = array( + MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, + MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, (MAX_32Bit * 2) + 1, (MAX_32Bit * 2) - 1, + MAX_64Bit -1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1 +); + +$otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); + +error_reporting(E_ERROR); + +foreach ($longVals as $longVal) { + foreach($otherVals as $otherVal) { + echo "--- testing: $longVal - $otherVal ---\n"; + var_dump($longVal-$otherVal); + } +} + +foreach ($otherVals as $otherVal) { + foreach($longVals as $longVal) { + echo "--- testing: $otherVal - $longVal ---\n"; + var_dump($otherVal-$longVal); + } +} + +?> +===DONE=== +--EXPECT-- --- testing: 9223372036854775807 - 0 --- int(9223372036854775807) --- testing: 9223372036854775807 - 1 --- @@ -578,5 +578,5 @@ float(0) --- testing: 9223372036854775807 - -9223372036854775807 --- float(1.844674407371E+19) --- testing: 9223372036854775807 - -9.2233720368548E+18 --- -float(1.844674407371E+19)
-===DONE===
+float(1.844674407371E+19) +===DONE=== diff --git a/tests/lang/operators/subtract_variationStr.phpt b/tests/lang/operators/subtract_variationStr.phpt index 5b5bae2e35..51b5ed4dca 100644 --- a/tests/lang/operators/subtract_variationStr.phpt +++ b/tests/lang/operators/subtract_variationStr.phpt @@ -1,26 +1,26 @@ ---TEST--
-Test - operator : various numbers as strings
---FILE--
-<?php
-
-$strVals = array(
- "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
- "a5.9"
-);
-
-error_reporting(E_ERROR);
-
-foreach ($strVals as $strVal) {
- foreach($strVals as $otherVal) {
- echo "--- testing: '$strVal' - '$otherVal' ---\n";
- var_dump($strVal-$otherVal);
- }
-}
-
-
-?>
-===DONE===
---EXPECT--
+--TEST-- +Test - operator : various numbers as strings +--FILE-- +<?php + +$strVals = array( + "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", + "a5.9" +); + +error_reporting(E_ERROR); + +foreach ($strVals as $strVal) { + foreach($strVals as $otherVal) { + echo "--- testing: '$strVal' - '$otherVal' ---\n"; + var_dump($strVal-$otherVal); + } +} + + +?> +===DONE=== +--EXPECT-- --- testing: '0' - '0' --- int(0) --- testing: '0' - '65' --- @@ -412,5 +412,5 @@ int(-123) --- testing: 'a5.9' - '3.4a' --- float(-3.4) --- testing: 'a5.9' - 'a5.9' --- -int(0)
-===DONE===
+int(0) +===DONE=== diff --git a/tests/lang/returnByReference.001.phpt b/tests/lang/returnByReference.001.phpt index 51e63b8694..1feccd4a97 100644 --- a/tests/lang/returnByReference.001.phpt +++ b/tests/lang/returnByReference.001.phpt @@ -1,20 +1,20 @@ ---TEST--
-Returning a reference from a function
---FILE--
-<?php
-
-function &returnByRef(&$arg1)
-{
- return $arg1;
-}
-
-$a = 7;
-$b =& returnByRef($a);
-var_dump($b);
-$a++;
-var_dump($b);
-
-?>
---EXPECT--
-int(7)
+--TEST-- +Returning a reference from a function +--FILE-- +<?php + +function &returnByRef(&$arg1) +{ + return $arg1; +} + +$a = 7; +$b =& returnByRef($a); +var_dump($b); +$a++; +var_dump($b); + +?> +--EXPECT-- +int(7) int(8) diff --git a/tests/lang/returnByReference.002.phpt b/tests/lang/returnByReference.002.phpt index 1c635b5298..99365f1b14 100644 --- a/tests/lang/returnByReference.002.phpt +++ b/tests/lang/returnByReference.002.phpt @@ -1,29 +1,29 @@ ---TEST--
-Returning a reference from a function.
---FILE--
-<?php
-function &returnRef() {
- global $a;
- return $a;
-}
-
-function returnVal() {
- global $a;
- return $a;
-}
-
-$a = "original";
-$b =& returnVal();
-$b = "changed";
-var_dump($a); //expecting warning + "original"
-
-$a = "original";
-$b =& returnRef();
-$b = "changed";
-var_dump($a); //expecting "changed"
-?>
---EXPECTF--
-
-Notice: Only variables should be assigned by reference in %s on line 13
-string(8) "original"
-string(7) "changed"
+--TEST-- +Returning a reference from a function. +--FILE-- +<?php +function &returnRef() { + global $a; + return $a; +} + +function returnVal() { + global $a; + return $a; +} + +$a = "original"; +$b =& returnVal(); +$b = "changed"; +var_dump($a); //expecting warning + "original" + +$a = "original"; +$b =& returnRef(); +$b = "changed"; +var_dump($a); //expecting "changed" +?> +--EXPECTF-- + +Notice: Only variables should be assigned by reference in %s on line 13 +string(8) "original" +string(7) "changed" diff --git a/tests/lang/returnByReference.003.phpt b/tests/lang/returnByReference.003.phpt index 3f03037bf5..b14ae69549 100644 --- a/tests/lang/returnByReference.003.phpt +++ b/tests/lang/returnByReference.003.phpt @@ -1,55 +1,55 @@ ---TEST--
-Returning a reference from a function
---FILE--
-<?php
-function returnConstantByValue() {
- return 100;
-}
-
-function &returnConstantByRef() {
- return 100;
-}
-
-function &returnVariableByRef() {
- return $GLOBALS['a'];
-}
-
-echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnConstantByValue();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnConstantByRef();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnVariableByRef();
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
-
----> 1. Trying to assign by reference the return value of a function that returns by value:
-
-Notice: Only variables should be assigned by reference in %s on line 17
-int(5)
-int(100)
-
----> 2. Trying to assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 7
-int(5)
-int(100)
-
----> 3. Trying to assign by reference the return value of a function that returns by ref:
-int(5)
-int(5)
+--TEST-- +Returning a reference from a function +--FILE-- +<?php +function returnConstantByValue() { + return 100; +} + +function &returnConstantByRef() { + return 100; +} + +function &returnVariableByRef() { + return $GLOBALS['a']; +} + +echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &returnConstantByValue(); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &returnConstantByRef(); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &returnVariableByRef(); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- + +---> 1. Trying to assign by reference the return value of a function that returns by value: + +Notice: Only variables should be assigned by reference in %s on line 17 +int(5) +int(100) + +---> 2. Trying to assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 7 +int(5) +int(100) + +---> 3. Trying to assign by reference the return value of a function that returns by ref: +int(5) +int(5) diff --git a/tests/lang/returnByReference.004.phpt b/tests/lang/returnByReference.004.phpt index f7d1165a22..b37506ce0a 100644 --- a/tests/lang/returnByReference.004.phpt +++ b/tests/lang/returnByReference.004.phpt @@ -1,57 +1,57 @@ ---TEST--
-Returning a reference from a static method
---FILE--
-<?php
-Class C {
- static function returnConstantByValue() {
- return 100;
- }
-
- static function &returnConstantByRef() {
- return 100;
- }
-
- static function &returnVariableByRef() {
- return $GLOBALS['a'];
- }
-}
-
-echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnConstantByValue();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnConstantByRef();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnVariableByRef();
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
-
----> 1. Trying to assign by reference the return value of a function that returns by value:
-
-Notice: Only variables should be assigned by reference in %s on line 19
-int(5)
-int(100)
-
----> 2. Trying to assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 8
-int(5)
-int(100)
-
----> 3. Trying to assign by reference the return value of a function that returns by ref:
-int(5)
-int(5)
+--TEST-- +Returning a reference from a static method +--FILE-- +<?php +Class C { + static function returnConstantByValue() { + return 100; + } + + static function &returnConstantByRef() { + return 100; + } + + static function &returnVariableByRef() { + return $GLOBALS['a']; + } +} + +echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnConstantByValue(); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnConstantByRef(); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnVariableByRef(); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- + +---> 1. Trying to assign by reference the return value of a function that returns by value: + +Notice: Only variables should be assigned by reference in %s on line 19 +int(5) +int(100) + +---> 2. Trying to assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 8 +int(5) +int(100) + +---> 3. Trying to assign by reference the return value of a function that returns by ref: +int(5) +int(5) diff --git a/tests/lang/returnByReference.005.phpt b/tests/lang/returnByReference.005.phpt index 840b89fa53..adb11617c4 100644 --- a/tests/lang/returnByReference.005.phpt +++ b/tests/lang/returnByReference.005.phpt @@ -1,58 +1,58 @@ ---TEST--
-Returning a reference from a method
---FILE--
-<?php
-Class C {
- function returnConstantByValue() {
- return 100;
- }
-
- function &returnConstantByRef() {
- return 100;
- }
-
- static function &returnVariableByRef() {
- return $GLOBALS['a'];
- }
-}
-$c = new C;
-
-echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnConstantByValue();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnConstantByRef();
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnVariableByRef();
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
-
----> 1. Trying to assign by reference the return value of a function that returns by value:
-
-Notice: Only variables should be assigned by reference in %s on line 20
-int(5)
-int(100)
-
----> 2. Trying to assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 8
-int(5)
-int(100)
-
----> 3. Trying to assign by reference the return value of a function that returns by ref:
-int(5)
-int(5)
+--TEST-- +Returning a reference from a method +--FILE-- +<?php +Class C { + function returnConstantByValue() { + return 100; + } + + function &returnConstantByRef() { + return 100; + } + + static function &returnVariableByRef() { + return $GLOBALS['a']; + } +} +$c = new C; + +echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnConstantByValue(); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnConstantByRef(); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnVariableByRef(); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- + +---> 1. Trying to assign by reference the return value of a function that returns by value: + +Notice: Only variables should be assigned by reference in %s on line 20 +int(5) +int(100) + +---> 2. Trying to assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 8 +int(5) +int(100) + +---> 3. Trying to assign by reference the return value of a function that returns by ref: +int(5) +int(5) diff --git a/tests/lang/returnByReference.006.phpt b/tests/lang/returnByReference.006.phpt index 4019f3ab45..d2c7041be8 100644 --- a/tests/lang/returnByReference.006.phpt +++ b/tests/lang/returnByReference.006.phpt @@ -1,60 +1,60 @@ ---TEST--
-Returning a reference from a function via another function
---INI--
-error_reporting = E_ALL & ~E_STRICT
---FILE--
-<?php
-function returnConstantByValue() {
- return 100;
-}
-
-function &returnConstantByRef() {
- return 100;
-}
-
-function &returnVariableByRef() {
- return $GLOBALS['a'];
-}
-
-function &returnFunctionCallByRef($functionToCall) {
- return $functionToCall();
-}
-
-echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnFunctionCallByRef('returnConstantByValue');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnFunctionCallByRef('returnConstantByRef');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &returnFunctionCallByRef('returnVariableByRef');
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
----> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:
-
-Notice: Only variable references should be returned by reference in %s on line 15
-int(5)
-int(100)
-
----> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 7
-int(5)
-int(100)
-
----> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:
-int(5)
-int(5)
+--TEST-- +Returning a reference from a function via another function +--INI-- +error_reporting = E_ALL & ~E_STRICT +--FILE-- +<?php +function returnConstantByValue() { + return 100; +} + +function &returnConstantByRef() { + return 100; +} + +function &returnVariableByRef() { + return $GLOBALS['a']; +} + +function &returnFunctionCallByRef($functionToCall) { + return $functionToCall(); +} + +echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &returnFunctionCallByRef('returnConstantByValue'); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &returnFunctionCallByRef('returnConstantByRef'); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &returnFunctionCallByRef('returnVariableByRef'); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- +---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value: + +Notice: Only variable references should be returned by reference in %s on line 15 +int(5) +int(100) + +---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 7 +int(5) +int(100) + +---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref: +int(5) +int(5) diff --git a/tests/lang/returnByReference.007.phpt b/tests/lang/returnByReference.007.phpt index badb7365f5..45fa0ddc88 100644 --- a/tests/lang/returnByReference.007.phpt +++ b/tests/lang/returnByReference.007.phpt @@ -1,63 +1,63 @@ ---TEST--
-Returning a reference from a static method via another static method
---INI--
-error_reporting = E_ALL & ~E_STRICT
---FILE--
-<?php
-class C {
- static function returnConstantByValue() {
- return 100;
- }
-
- static function &returnConstantByRef() {
- return 100;
- }
-
- static function &returnVariableByRef() {
- return $GLOBALS['a'];
- }
-
- static function &returnFunctionCallByRef($functionToCall) {
- return C::$functionToCall();
- }
-}
-
-echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnFunctionCallByRef('returnConstantByValue');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnFunctionCallByRef('returnConstantByRef');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &C::returnFunctionCallByRef('returnVariableByRef');
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
-
----> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:
-
-Notice: Only variable references should be returned by reference in %s on line 16
-int(5)
-int(100)
-
----> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 8
-int(5)
-int(100)
-
----> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:
-int(5)
+--TEST-- +Returning a reference from a static method via another static method +--INI-- +error_reporting = E_ALL & ~E_STRICT +--FILE-- +<?php +class C { + static function returnConstantByValue() { + return 100; + } + + static function &returnConstantByRef() { + return 100; + } + + static function &returnVariableByRef() { + return $GLOBALS['a']; + } + + static function &returnFunctionCallByRef($functionToCall) { + return C::$functionToCall(); + } +} + +echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnFunctionCallByRef('returnConstantByValue'); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnFunctionCallByRef('returnConstantByRef'); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &C::returnFunctionCallByRef('returnVariableByRef'); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- + +---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value: + +Notice: Only variable references should be returned by reference in %s on line 16 +int(5) +int(100) + +---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 8 +int(5) +int(100) + +---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref: +int(5) int(5) diff --git a/tests/lang/returnByReference.008.phpt b/tests/lang/returnByReference.008.phpt index 9c396be1bc..3774a917c5 100644 --- a/tests/lang/returnByReference.008.phpt +++ b/tests/lang/returnByReference.008.phpt @@ -1,64 +1,64 @@ ---TEST--
-Returning a reference from a non-static method via another non-static method
---INI--
-error_reporting = E_ALL & ~E_STRICT
---FILE--
-<?php
-class C {
- function returnConstantByValue() {
- return 100;
- }
-
- function &returnConstantByRef() {
- return 100;
- }
-
- function &returnVariableByRef() {
- return $GLOBALS['a'];
- }
-
- function &returnFunctionCallByRef($functionToCall) {
- return $this->$functionToCall();
- }
-}
-$c = new C;
-
-echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnFunctionCallByRef('returnConstantByValue');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnFunctionCallByRef('returnConstantByRef');
-$a++;
-var_dump($a, $b);
-
-echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n";
-unset($a, $b);
-$a = 4;
-$b = &$c->returnFunctionCallByRef('returnVariableByRef');
-$a++;
-var_dump($a, $b);
-
-?>
---EXPECTF--
-
----> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:
-
-Notice: Only variable references should be returned by reference in %s on line 16
-int(5)
-int(100)
-
----> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:
-
-Notice: Only variable references should be returned by reference in %s on line 8
-int(5)
-int(100)
-
----> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:
-int(5)
+--TEST-- +Returning a reference from a non-static method via another non-static method +--INI-- +error_reporting = E_ALL & ~E_STRICT +--FILE-- +<?php +class C { + function returnConstantByValue() { + return 100; + } + + function &returnConstantByRef() { + return 100; + } + + function &returnVariableByRef() { + return $GLOBALS['a']; + } + + function &returnFunctionCallByRef($functionToCall) { + return $this->$functionToCall(); + } +} +$c = new C; + +echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnFunctionCallByRef('returnConstantByValue'); +$a++; +var_dump($a, $b); + +echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnFunctionCallByRef('returnConstantByRef'); +$a++; +var_dump($a, $b); + +echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n"; +unset($a, $b); +$a = 4; +$b = &$c->returnFunctionCallByRef('returnVariableByRef'); +$a++; +var_dump($a, $b); + +?> +--EXPECTF-- + +---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value: + +Notice: Only variable references should be returned by reference in %s on line 16 +int(5) +int(100) + +---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref: + +Notice: Only variable references should be returned by reference in %s on line 8 +int(5) +int(100) + +---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref: +int(5) int(5) diff --git a/tests/lang/returnByReference.009.phpt b/tests/lang/returnByReference.009.phpt index 63203757de..9e7470edbc 100644 --- a/tests/lang/returnByReference.009.phpt +++ b/tests/lang/returnByReference.009.phpt @@ -1,39 +1,39 @@ ---TEST--
-Returning a references returned by another function
---FILE--
-<?php
-
-
-function &returnVarByRef () {
- $b=1;
- return $b;
-}
-
-function &testReturnVarByRef() {
- return returnVarByRef();
-}
-
-function returnVal () {
-return 1;
-}
-
-function &testReturnValByRef() {
- return returnVal();
-}
-
-echo "\n---> 1. Return a variable by reference -> No warning:\n";
-
-var_dump (testReturnVarByRef());
-
-echo "\n---> 2. Return a value by reference -> Warning:\n";
-
-var_dump (testReturnValByRef());
-
---EXPECTF--
----> 1. Return a variable by reference -> No warning:
-int(1)
-
----> 2. Return a value by reference -> Warning:
-
-Notice: Only variable references should be returned by reference in %s on line %d
-int(1)
+--TEST-- +Returning a references returned by another function +--FILE-- +<?php + + +function &returnVarByRef () { + $b=1; + return $b; +} + +function &testReturnVarByRef() { + return returnVarByRef(); +} + +function returnVal () { +return 1; +} + +function &testReturnValByRef() { + return returnVal(); +} + +echo "\n---> 1. Return a variable by reference -> No warning:\n"; + +var_dump (testReturnVarByRef()); + +echo "\n---> 2. Return a value by reference -> Warning:\n"; + +var_dump (testReturnValByRef()); + +--EXPECTF-- +---> 1. Return a variable by reference -> No warning: +int(1) + +---> 2. Return a value by reference -> Warning: + +Notice: Only variable references should be returned by reference in %s on line %d +int(1) |