subtract_variationStr.phpt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. --TEST--
  2. Test - operator : various numbers as strings
  3. --FILE--
  4. <?php
  5. $strVals = array(
  6. "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
  7. "a5.9"
  8. );
  9. error_reporting(E_ERROR);
  10. foreach ($strVals as $strVal) {
  11. foreach($strVals as $otherVal) {
  12. echo "--- testing: '$strVal' - '$otherVal' ---\n";
  13. try {
  14. var_dump($strVal-$otherVal);
  15. } catch (\TypeError $e) {
  16. echo $e->getMessage() . \PHP_EOL;
  17. }
  18. }
  19. }
  20. ?>
  21. --EXPECT--
  22. --- testing: '0' - '0' ---
  23. int(0)
  24. --- testing: '0' - '65' ---
  25. int(-65)
  26. --- testing: '0' - '-44' ---
  27. int(44)
  28. --- testing: '0' - '1.2' ---
  29. float(-1.2)
  30. --- testing: '0' - '-7.7' ---
  31. float(7.7)
  32. --- testing: '0' - 'abc' ---
  33. Unsupported operand types: string - string
  34. --- testing: '0' - '123abc' ---
  35. int(-123)
  36. --- testing: '0' - '123e5' ---
  37. float(-12300000)
  38. --- testing: '0' - '123e5xyz' ---
  39. float(-12300000)
  40. --- testing: '0' - ' 123abc' ---
  41. int(-123)
  42. --- testing: '0' - '123 abc' ---
  43. int(-123)
  44. --- testing: '0' - '123abc ' ---
  45. int(-123)
  46. --- testing: '0' - '3.4a' ---
  47. float(-3.4)
  48. --- testing: '0' - 'a5.9' ---
  49. Unsupported operand types: string - string
  50. --- testing: '65' - '0' ---
  51. int(65)
  52. --- testing: '65' - '65' ---
  53. int(0)
  54. --- testing: '65' - '-44' ---
  55. int(109)
  56. --- testing: '65' - '1.2' ---
  57. float(63.8)
  58. --- testing: '65' - '-7.7' ---
  59. float(72.7)
  60. --- testing: '65' - 'abc' ---
  61. Unsupported operand types: string - string
  62. --- testing: '65' - '123abc' ---
  63. int(-58)
  64. --- testing: '65' - '123e5' ---
  65. float(-12299935)
  66. --- testing: '65' - '123e5xyz' ---
  67. float(-12299935)
  68. --- testing: '65' - ' 123abc' ---
  69. int(-58)
  70. --- testing: '65' - '123 abc' ---
  71. int(-58)
  72. --- testing: '65' - '123abc ' ---
  73. int(-58)
  74. --- testing: '65' - '3.4a' ---
  75. float(61.6)
  76. --- testing: '65' - 'a5.9' ---
  77. Unsupported operand types: string - string
  78. --- testing: '-44' - '0' ---
  79. int(-44)
  80. --- testing: '-44' - '65' ---
  81. int(-109)
  82. --- testing: '-44' - '-44' ---
  83. int(0)
  84. --- testing: '-44' - '1.2' ---
  85. float(-45.2)
  86. --- testing: '-44' - '-7.7' ---
  87. float(-36.3)
  88. --- testing: '-44' - 'abc' ---
  89. Unsupported operand types: string - string
  90. --- testing: '-44' - '123abc' ---
  91. int(-167)
  92. --- testing: '-44' - '123e5' ---
  93. float(-12300044)
  94. --- testing: '-44' - '123e5xyz' ---
  95. float(-12300044)
  96. --- testing: '-44' - ' 123abc' ---
  97. int(-167)
  98. --- testing: '-44' - '123 abc' ---
  99. int(-167)
  100. --- testing: '-44' - '123abc ' ---
  101. int(-167)
  102. --- testing: '-44' - '3.4a' ---
  103. float(-47.4)
  104. --- testing: '-44' - 'a5.9' ---
  105. Unsupported operand types: string - string
  106. --- testing: '1.2' - '0' ---
  107. float(1.2)
  108. --- testing: '1.2' - '65' ---
  109. float(-63.8)
  110. --- testing: '1.2' - '-44' ---
  111. float(45.2)
  112. --- testing: '1.2' - '1.2' ---
  113. float(0)
  114. --- testing: '1.2' - '-7.7' ---
  115. float(8.9)
  116. --- testing: '1.2' - 'abc' ---
  117. Unsupported operand types: string - string
  118. --- testing: '1.2' - '123abc' ---
  119. float(-121.8)
  120. --- testing: '1.2' - '123e5' ---
  121. float(-12299998.8)
  122. --- testing: '1.2' - '123e5xyz' ---
  123. float(-12299998.8)
  124. --- testing: '1.2' - ' 123abc' ---
  125. float(-121.8)
  126. --- testing: '1.2' - '123 abc' ---
  127. float(-121.8)
  128. --- testing: '1.2' - '123abc ' ---
  129. float(-121.8)
  130. --- testing: '1.2' - '3.4a' ---
  131. float(-2.2)
  132. --- testing: '1.2' - 'a5.9' ---
  133. Unsupported operand types: string - string
  134. --- testing: '-7.7' - '0' ---
  135. float(-7.7)
  136. --- testing: '-7.7' - '65' ---
  137. float(-72.7)
  138. --- testing: '-7.7' - '-44' ---
  139. float(36.3)
  140. --- testing: '-7.7' - '1.2' ---
  141. float(-8.9)
  142. --- testing: '-7.7' - '-7.7' ---
  143. float(0)
  144. --- testing: '-7.7' - 'abc' ---
  145. Unsupported operand types: string - string
  146. --- testing: '-7.7' - '123abc' ---
  147. float(-130.7)
  148. --- testing: '-7.7' - '123e5' ---
  149. float(-12300007.7)
  150. --- testing: '-7.7' - '123e5xyz' ---
  151. float(-12300007.7)
  152. --- testing: '-7.7' - ' 123abc' ---
  153. float(-130.7)
  154. --- testing: '-7.7' - '123 abc' ---
  155. float(-130.7)
  156. --- testing: '-7.7' - '123abc ' ---
  157. float(-130.7)
  158. --- testing: '-7.7' - '3.4a' ---
  159. float(-11.1)
  160. --- testing: '-7.7' - 'a5.9' ---
  161. Unsupported operand types: string - string
  162. --- testing: 'abc' - '0' ---
  163. Unsupported operand types: string - string
  164. --- testing: 'abc' - '65' ---
  165. Unsupported operand types: string - string
  166. --- testing: 'abc' - '-44' ---
  167. Unsupported operand types: string - string
  168. --- testing: 'abc' - '1.2' ---
  169. Unsupported operand types: string - string
  170. --- testing: 'abc' - '-7.7' ---
  171. Unsupported operand types: string - string
  172. --- testing: 'abc' - 'abc' ---
  173. Unsupported operand types: string - string
  174. --- testing: 'abc' - '123abc' ---
  175. Unsupported operand types: string - string
  176. --- testing: 'abc' - '123e5' ---
  177. Unsupported operand types: string - string
  178. --- testing: 'abc' - '123e5xyz' ---
  179. Unsupported operand types: string - string
  180. --- testing: 'abc' - ' 123abc' ---
  181. Unsupported operand types: string - string
  182. --- testing: 'abc' - '123 abc' ---
  183. Unsupported operand types: string - string
  184. --- testing: 'abc' - '123abc ' ---
  185. Unsupported operand types: string - string
  186. --- testing: 'abc' - '3.4a' ---
  187. Unsupported operand types: string - string
  188. --- testing: 'abc' - 'a5.9' ---
  189. Unsupported operand types: string - string
  190. --- testing: '123abc' - '0' ---
  191. int(123)
  192. --- testing: '123abc' - '65' ---
  193. int(58)
  194. --- testing: '123abc' - '-44' ---
  195. int(167)
  196. --- testing: '123abc' - '1.2' ---
  197. float(121.8)
  198. --- testing: '123abc' - '-7.7' ---
  199. float(130.7)
  200. --- testing: '123abc' - 'abc' ---
  201. Unsupported operand types: string - string
  202. --- testing: '123abc' - '123abc' ---
  203. int(0)
  204. --- testing: '123abc' - '123e5' ---
  205. float(-12299877)
  206. --- testing: '123abc' - '123e5xyz' ---
  207. float(-12299877)
  208. --- testing: '123abc' - ' 123abc' ---
  209. int(0)
  210. --- testing: '123abc' - '123 abc' ---
  211. int(0)
  212. --- testing: '123abc' - '123abc ' ---
  213. int(0)
  214. --- testing: '123abc' - '3.4a' ---
  215. float(119.6)
  216. --- testing: '123abc' - 'a5.9' ---
  217. Unsupported operand types: string - string
  218. --- testing: '123e5' - '0' ---
  219. float(12300000)
  220. --- testing: '123e5' - '65' ---
  221. float(12299935)
  222. --- testing: '123e5' - '-44' ---
  223. float(12300044)
  224. --- testing: '123e5' - '1.2' ---
  225. float(12299998.8)
  226. --- testing: '123e5' - '-7.7' ---
  227. float(12300007.7)
  228. --- testing: '123e5' - 'abc' ---
  229. Unsupported operand types: string - string
  230. --- testing: '123e5' - '123abc' ---
  231. float(12299877)
  232. --- testing: '123e5' - '123e5' ---
  233. float(0)
  234. --- testing: '123e5' - '123e5xyz' ---
  235. float(0)
  236. --- testing: '123e5' - ' 123abc' ---
  237. float(12299877)
  238. --- testing: '123e5' - '123 abc' ---
  239. float(12299877)
  240. --- testing: '123e5' - '123abc ' ---
  241. float(12299877)
  242. --- testing: '123e5' - '3.4a' ---
  243. float(12299996.6)
  244. --- testing: '123e5' - 'a5.9' ---
  245. Unsupported operand types: string - string
  246. --- testing: '123e5xyz' - '0' ---
  247. float(12300000)
  248. --- testing: '123e5xyz' - '65' ---
  249. float(12299935)
  250. --- testing: '123e5xyz' - '-44' ---
  251. float(12300044)
  252. --- testing: '123e5xyz' - '1.2' ---
  253. float(12299998.8)
  254. --- testing: '123e5xyz' - '-7.7' ---
  255. float(12300007.7)
  256. --- testing: '123e5xyz' - 'abc' ---
  257. Unsupported operand types: string - string
  258. --- testing: '123e5xyz' - '123abc' ---
  259. float(12299877)
  260. --- testing: '123e5xyz' - '123e5' ---
  261. float(0)
  262. --- testing: '123e5xyz' - '123e5xyz' ---
  263. float(0)
  264. --- testing: '123e5xyz' - ' 123abc' ---
  265. float(12299877)
  266. --- testing: '123e5xyz' - '123 abc' ---
  267. float(12299877)
  268. --- testing: '123e5xyz' - '123abc ' ---
  269. float(12299877)
  270. --- testing: '123e5xyz' - '3.4a' ---
  271. float(12299996.6)
  272. --- testing: '123e5xyz' - 'a5.9' ---
  273. Unsupported operand types: string - string
  274. --- testing: ' 123abc' - '0' ---
  275. int(123)
  276. --- testing: ' 123abc' - '65' ---
  277. int(58)
  278. --- testing: ' 123abc' - '-44' ---
  279. int(167)
  280. --- testing: ' 123abc' - '1.2' ---
  281. float(121.8)
  282. --- testing: ' 123abc' - '-7.7' ---
  283. float(130.7)
  284. --- testing: ' 123abc' - 'abc' ---
  285. Unsupported operand types: string - string
  286. --- testing: ' 123abc' - '123abc' ---
  287. int(0)
  288. --- testing: ' 123abc' - '123e5' ---
  289. float(-12299877)
  290. --- testing: ' 123abc' - '123e5xyz' ---
  291. float(-12299877)
  292. --- testing: ' 123abc' - ' 123abc' ---
  293. int(0)
  294. --- testing: ' 123abc' - '123 abc' ---
  295. int(0)
  296. --- testing: ' 123abc' - '123abc ' ---
  297. int(0)
  298. --- testing: ' 123abc' - '3.4a' ---
  299. float(119.6)
  300. --- testing: ' 123abc' - 'a5.9' ---
  301. Unsupported operand types: string - string
  302. --- testing: '123 abc' - '0' ---
  303. int(123)
  304. --- testing: '123 abc' - '65' ---
  305. int(58)
  306. --- testing: '123 abc' - '-44' ---
  307. int(167)
  308. --- testing: '123 abc' - '1.2' ---
  309. float(121.8)
  310. --- testing: '123 abc' - '-7.7' ---
  311. float(130.7)
  312. --- testing: '123 abc' - 'abc' ---
  313. Unsupported operand types: string - string
  314. --- testing: '123 abc' - '123abc' ---
  315. int(0)
  316. --- testing: '123 abc' - '123e5' ---
  317. float(-12299877)
  318. --- testing: '123 abc' - '123e5xyz' ---
  319. float(-12299877)
  320. --- testing: '123 abc' - ' 123abc' ---
  321. int(0)
  322. --- testing: '123 abc' - '123 abc' ---
  323. int(0)
  324. --- testing: '123 abc' - '123abc ' ---
  325. int(0)
  326. --- testing: '123 abc' - '3.4a' ---
  327. float(119.6)
  328. --- testing: '123 abc' - 'a5.9' ---
  329. Unsupported operand types: string - string
  330. --- testing: '123abc ' - '0' ---
  331. int(123)
  332. --- testing: '123abc ' - '65' ---
  333. int(58)
  334. --- testing: '123abc ' - '-44' ---
  335. int(167)
  336. --- testing: '123abc ' - '1.2' ---
  337. float(121.8)
  338. --- testing: '123abc ' - '-7.7' ---
  339. float(130.7)
  340. --- testing: '123abc ' - 'abc' ---
  341. Unsupported operand types: string - string
  342. --- testing: '123abc ' - '123abc' ---
  343. int(0)
  344. --- testing: '123abc ' - '123e5' ---
  345. float(-12299877)
  346. --- testing: '123abc ' - '123e5xyz' ---
  347. float(-12299877)
  348. --- testing: '123abc ' - ' 123abc' ---
  349. int(0)
  350. --- testing: '123abc ' - '123 abc' ---
  351. int(0)
  352. --- testing: '123abc ' - '123abc ' ---
  353. int(0)
  354. --- testing: '123abc ' - '3.4a' ---
  355. float(119.6)
  356. --- testing: '123abc ' - 'a5.9' ---
  357. Unsupported operand types: string - string
  358. --- testing: '3.4a' - '0' ---
  359. float(3.4)
  360. --- testing: '3.4a' - '65' ---
  361. float(-61.6)
  362. --- testing: '3.4a' - '-44' ---
  363. float(47.4)
  364. --- testing: '3.4a' - '1.2' ---
  365. float(2.2)
  366. --- testing: '3.4a' - '-7.7' ---
  367. float(11.1)
  368. --- testing: '3.4a' - 'abc' ---
  369. Unsupported operand types: string - string
  370. --- testing: '3.4a' - '123abc' ---
  371. float(-119.6)
  372. --- testing: '3.4a' - '123e5' ---
  373. float(-12299996.6)
  374. --- testing: '3.4a' - '123e5xyz' ---
  375. float(-12299996.6)
  376. --- testing: '3.4a' - ' 123abc' ---
  377. float(-119.6)
  378. --- testing: '3.4a' - '123 abc' ---
  379. float(-119.6)
  380. --- testing: '3.4a' - '123abc ' ---
  381. float(-119.6)
  382. --- testing: '3.4a' - '3.4a' ---
  383. float(0)
  384. --- testing: '3.4a' - 'a5.9' ---
  385. Unsupported operand types: string - string
  386. --- testing: 'a5.9' - '0' ---
  387. Unsupported operand types: string - string
  388. --- testing: 'a5.9' - '65' ---
  389. Unsupported operand types: string - string
  390. --- testing: 'a5.9' - '-44' ---
  391. Unsupported operand types: string - string
  392. --- testing: 'a5.9' - '1.2' ---
  393. Unsupported operand types: string - string
  394. --- testing: 'a5.9' - '-7.7' ---
  395. Unsupported operand types: string - string
  396. --- testing: 'a5.9' - 'abc' ---
  397. Unsupported operand types: string - string
  398. --- testing: 'a5.9' - '123abc' ---
  399. Unsupported operand types: string - string
  400. --- testing: 'a5.9' - '123e5' ---
  401. Unsupported operand types: string - string
  402. --- testing: 'a5.9' - '123e5xyz' ---
  403. Unsupported operand types: string - string
  404. --- testing: 'a5.9' - ' 123abc' ---
  405. Unsupported operand types: string - string
  406. --- testing: 'a5.9' - '123 abc' ---
  407. Unsupported operand types: string - string
  408. --- testing: 'a5.9' - '123abc ' ---
  409. Unsupported operand types: string - string
  410. --- testing: 'a5.9' - '3.4a' ---
  411. Unsupported operand types: string - string
  412. --- testing: 'a5.9' - 'a5.9' ---
  413. Unsupported operand types: string - string