2
2
BcMath\Number compare by operator with non-sense
3
3
--EXTENSIONS--
4
4
bcmath
5
- --XFAIL--
6
- Leaks and conversion issues
7
5
--FILE--
8
6
<?php
9
7
@@ -12,25 +10,26 @@ $values2 = [
12
10
['string ' , 'string ' ],
13
11
[new stdClass (), 'object ' ],
14
12
[[], 'array ' ],
13
+ [STDERR , 'resource ' ],
15
14
];
16
15
17
16
$ value1 = new BcMath \Number ('100.0000 ' );
18
17
19
18
foreach ($ values2 as [$ value2 , $ type2 ]) {
20
19
try {
21
- echo "========== with {$ type2 } { $ value2 } ========== \n" ;
22
- echo "{$ value1 } > {$ value2 }: " . ($ value1 > $ value2 ? 'true ' : 'false ' ) . "\n" ;
23
- echo "{$ value1 } >= {$ value2 }: " . ($ value1 >= $ value2 ? 'true ' : 'false ' ) . "\n" ;
24
- echo "{$ value1 } == {$ value2 }: " . ($ value1 == $ value2 ? 'true ' : 'false ' ) . "\n" ;
25
- echo "{$ value1 } <= {$ value2 }: " . ($ value1 <= $ value2 ? 'true ' : 'false ' ) . "\n" ;
26
- echo "{$ value1 } < {$ value2 }: " . ($ value1 < $ value2 ? 'true ' : 'false ' ) . "\n" ;
20
+ echo "========== with {$ type2 } ========== \n" ;
21
+ echo "{$ value1 } > {$ type2 }: " . ($ value1 > $ value2 ? 'true ' : 'false ' ) . "\n" ;
22
+ echo "{$ value1 } >= {$ type2 }: " . ($ value1 >= $ value2 ? 'true ' : 'false ' ) . "\n" ;
23
+ echo "{$ value1 } == {$ type2 }: " . ($ value1 == $ value2 ? 'true ' : 'false ' ) . "\n" ;
24
+ echo "{$ value1 } <= {$ type2 }: " . ($ value1 <= $ value2 ? 'true ' : 'false ' ) . "\n" ;
25
+ echo "{$ value1 } < {$ type2 }: " . ($ value1 < $ value2 ? 'true ' : 'false ' ) . "\n" ;
27
26
28
27
echo "\ninversion \n" ;
29
- echo "{$ value2 } > {$ value1 }: " . ($ value2 > $ value1 ? 'true ' : 'false ' ) . "\n" ;
30
- echo "{$ value2 } >= {$ value1 }: " . ($ value2 >= $ value1 ? 'true ' : 'false ' ) . "\n" ;
31
- echo "{$ value2 } == {$ value1 }: " . ($ value2 == $ value1 ? 'true ' : 'false ' ) . "\n" ;
32
- echo "{$ value2 } <= {$ value1 }: " . ($ value2 <= $ value1 ? 'true ' : 'false ' ) . "\n" ;
33
- echo "{$ value2 } < {$ value1 }: " . ($ value2 < $ value1 ? 'true ' : 'false ' ) . "\n" ;
28
+ echo "{$ type2 } > {$ value1 }: " . ($ value2 > $ value1 ? 'true ' : 'false ' ) . "\n" ;
29
+ echo "{$ type2 } >= {$ value1 }: " . ($ value2 >= $ value1 ? 'true ' : 'false ' ) . "\n" ;
30
+ echo "{$ type2 } == {$ value1 }: " . ($ value2 == $ value1 ? 'true ' : 'false ' ) . "\n" ;
31
+ echo "{$ type2 } <= {$ value1 }: " . ($ value2 <= $ value1 ? 'true ' : 'false ' ) . "\n" ;
32
+ echo "{$ type2 } < {$ value1 }: " . ($ value2 < $ value1 ? 'true ' : 'false ' ) . "\n" ;
34
33
35
34
echo "\n" ;
36
35
} catch (Throwable $ e ) {
@@ -39,21 +38,21 @@ foreach ($values2 as [$value2, $type2]) {
39
38
}
40
39
?>
41
40
--EXPECT--
42
- ========== with null ==========
43
- 100.0000 > : true
44
- 100.0000 >= : true
45
- 100.0000 == : false
46
- 100.0000 <= : false
47
- 100.0000 < : false
41
+ ========== with null ==========
42
+ 100.0000 > null : true
43
+ 100.0000 >= null : true
44
+ 100.0000 == null : false
45
+ 100.0000 <= null : false
46
+ 100.0000 < null : false
48
47
49
48
inversion
50
- > 100.0000: false
51
- >= 100.0000: false
52
- == 100.0000: false
53
- <= 100.0000: true
54
- < 100.0000: true
49
+ null > 100.0000: false
50
+ null >= 100.0000: false
51
+ null == 100.0000: false
52
+ null <= 100.0000: true
53
+ null < 100.0000: true
55
54
56
- ========== with string string ==========
55
+ ========== with string ==========
57
56
100.0000 > string: false
58
57
100.0000 >= string: false
59
58
100.0000 == string: false
@@ -67,65 +66,44 @@ string == 100.0000: false
67
66
string <= 100.0000: false
68
67
string < 100.0000: false
69
68
70
- Error: Object of class stdClass could not be converted to string
71
-
72
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 14
73
- ========== with array Array ==========
74
-
75
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 15
76
- 100.0000 > Array: false
77
-
78
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 16
79
- 100.0000 >= Array: false
80
-
81
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 17
82
- 100.0000 == Array: false
83
-
84
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 18
85
- 100.0000 <= Array: false
86
-
87
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 19
88
- 100.0000 < Array: false
69
+ ========== with object ==========
70
+ 100.0000 > object: false
71
+ 100.0000 >= object: false
72
+ 100.0000 == object: false
73
+ 100.0000 <= object: false
74
+ 100.0000 < object: false
89
75
90
76
inversion
77
+ object > 100.0000: false
78
+ object >= 100.0000: false
79
+ object == 100.0000: false
80
+ object <= 100.0000: false
81
+ object < 100.0000: false
82
+
83
+ ========== with array ==========
84
+ 100.0000 > array: false
85
+ 100.0000 >= array: false
86
+ 100.0000 == array: false
87
+ 100.0000 <= array: false
88
+ 100.0000 < array: false
91
89
92
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 22
93
- Array > 100.0000: false
94
-
95
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 23
96
- Array >= 100.0000: false
97
-
98
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 24
99
- Array == 100.0000: false
100
-
101
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 25
102
- Array <= 100.0000: false
103
-
104
- Warning: Array to string conversion in /home/girgias/dev/php-src/ext/bcmath/tests/number/operators/compare_with_invalid_types.php on line 26
105
- Array < 100.0000: false
106
-
107
-
108
- =================================================================
109
- ==563635==ERROR: LeakSanitizer: detected memory leaks
110
-
111
- Direct leak of 40 byte(s) in 1 object(s) allocated from:
112
- #0 0x69e593 in malloc (/home/girgias/dev/php-src/sapi/cli/php+0x69e593) (BuildId: 2f7a6003d470bd5f737972d1b6f5e078f877bdbe)
113
- #1 0x16e0183 in __zend_malloc /home/girgias/dev/php-src/Zend/zend_alloc.c:3280:14
114
- #2 0x9c18a9 in _bc_new_num_nonzeroed_ex_internal /home/girgias/dev/php-src/ext/bcmath/libbcmath/src/init.c:50:10
115
- #3 0x9c114b in _bc_new_num_ex /home/girgias/dev/php-src/ext/bcmath/libbcmath/src/init.c:64:16
116
- #4 0x9c1cdd in bc_init_numbers /home/girgias/dev/php-src/ext/bcmath/libbcmath/src/init.c:93:16
117
- #5 0x9a20ed in zm_globals_ctor_bcmath /home/girgias/dev/php-src/ext/bcmath/bcmath.c:105:2
118
- #6 0x147516b in tsrm_update_active_threads /home/girgias/dev/php-src/TSRM/TSRM.c:265:7
119
- #7 0x1474cab in ts_allocate_id /home/girgias/dev/php-src/TSRM/TSRM.c:306:2
120
- #8 0x170320b in zend_startup_module_ex /home/girgias/dev/php-src/Zend/zend_API.c:2422:3
121
- #9 0x1704f01 in zend_startup_module_zval /home/girgias/dev/php-src/Zend/zend_API.c:2446:10
122
- #10 0x1b577d2 in zend_hash_apply /home/girgias/dev/php-src/Zend/zend_hash.c:2085:13
123
- #11 0x1704aeb in zend_startup_modules /home/girgias/dev/php-src/Zend/zend_API.c:2569:2
124
- #12 0x148c070 in php_module_startup /home/girgias/dev/php-src/main/main.c:2290:2
125
- #13 0x1d3b3c8 in php_cli_startup /home/girgias/dev/php-src/sapi/cli/php_cli.c:397:9
126
- #14 0x1d36aa6 in main /home/girgias/dev/php-src/sapi/cli/php_cli.c:1276:6
127
- #15 0x7fc9982b9087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: 77c77fee058b19c6f001cf2cb0371ce3b8341211)
128
- #16 0x7fc9982b914a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2a14a) (BuildId: 77c77fee058b19c6f001cf2cb0371ce3b8341211)
129
- #17 0x603744 in _start (/home/girgias/dev/php-src/sapi/cli/php+0x603744) (BuildId: 2f7a6003d470bd5f737972d1b6f5e078f877bdbe)
90
+ inversion
91
+ array > 100.0000: false
92
+ array >= 100.0000: false
93
+ array == 100.0000: false
94
+ array <= 100.0000: false
95
+ array < 100.0000: false
96
+
97
+ ========== with resource ==========
98
+ 100.0000 > resource: false
99
+ 100.0000 >= resource: false
100
+ 100.0000 == resource: false
101
+ 100.0000 <= resource: false
102
+ 100.0000 < resource: false
130
103
131
- SUMMARY: AddressSanitizer: 40 byte(s) leaked in 1 allocation(s).
104
+ inversion
105
+ resource > 100.0000: false
106
+ resource >= 100.0000: false
107
+ resource == 100.0000: false
108
+ resource <= 100.0000: false
109
+ resource < 100.0000: false
0 commit comments