add_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(130)
  54. --- testing: '65' + '-44' ---
  55. int(21)
  56. --- testing: '65' + '1.2' ---
  57. float(66.2)
  58. --- testing: '65' + '-7.7' ---
  59. float(57.3)
  60. --- testing: '65' + 'abc' ---
  61. Unsupported operand types: string + string
  62. --- testing: '65' + '123abc' ---
  63. int(188)
  64. --- testing: '65' + '123e5' ---
  65. float(12300065)
  66. --- testing: '65' + '123e5xyz' ---
  67. float(12300065)
  68. --- testing: '65' + ' 123abc' ---
  69. int(188)
  70. --- testing: '65' + '123 abc' ---
  71. int(188)
  72. --- testing: '65' + '123abc ' ---
  73. int(188)
  74. --- testing: '65' + '3.4a' ---
  75. float(68.4)
  76. --- testing: '65' + 'a5.9' ---
  77. Unsupported operand types: string + string
  78. --- testing: '-44' + '0' ---
  79. int(-44)
  80. --- testing: '-44' + '65' ---
  81. int(21)
  82. --- testing: '-44' + '-44' ---
  83. int(-88)
  84. --- testing: '-44' + '1.2' ---
  85. float(-42.8)
  86. --- testing: '-44' + '-7.7' ---
  87. float(-51.7)
  88. --- testing: '-44' + 'abc' ---
  89. Unsupported operand types: string + string
  90. --- testing: '-44' + '123abc' ---
  91. int(79)
  92. --- testing: '-44' + '123e5' ---
  93. float(12299956)
  94. --- testing: '-44' + '123e5xyz' ---
  95. float(12299956)
  96. --- testing: '-44' + ' 123abc' ---
  97. int(79)
  98. --- testing: '-44' + '123 abc' ---
  99. int(79)
  100. --- testing: '-44' + '123abc ' ---
  101. int(79)
  102. --- testing: '-44' + '3.4a' ---
  103. float(-40.6)
  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(66.2)
  110. --- testing: '1.2' + '-44' ---
  111. float(-42.8)
  112. --- testing: '1.2' + '1.2' ---
  113. float(2.4)
  114. --- testing: '1.2' + '-7.7' ---
  115. float(-6.5)
  116. --- testing: '1.2' + 'abc' ---
  117. Unsupported operand types: string + string
  118. --- testing: '1.2' + '123abc' ---
  119. float(124.2)
  120. --- testing: '1.2' + '123e5' ---
  121. float(12300001.2)
  122. --- testing: '1.2' + '123e5xyz' ---
  123. float(12300001.2)
  124. --- testing: '1.2' + ' 123abc' ---
  125. float(124.2)
  126. --- testing: '1.2' + '123 abc' ---
  127. float(124.2)
  128. --- testing: '1.2' + '123abc ' ---
  129. float(124.2)
  130. --- testing: '1.2' + '3.4a' ---
  131. float(4.6)
  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(57.3)
  138. --- testing: '-7.7' + '-44' ---
  139. float(-51.7)
  140. --- testing: '-7.7' + '1.2' ---
  141. float(-6.5)
  142. --- testing: '-7.7' + '-7.7' ---
  143. float(-15.4)
  144. --- testing: '-7.7' + 'abc' ---
  145. Unsupported operand types: string + string
  146. --- testing: '-7.7' + '123abc' ---
  147. float(115.3)
  148. --- testing: '-7.7' + '123e5' ---
  149. float(12299992.3)
  150. --- testing: '-7.7' + '123e5xyz' ---
  151. float(12299992.3)
  152. --- testing: '-7.7' + ' 123abc' ---
  153. float(115.3)
  154. --- testing: '-7.7' + '123 abc' ---
  155. float(115.3)
  156. --- testing: '-7.7' + '123abc ' ---
  157. float(115.3)
  158. --- testing: '-7.7' + '3.4a' ---
  159. float(-4.300000000000001)
  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(188)
  194. --- testing: '123abc' + '-44' ---
  195. int(79)
  196. --- testing: '123abc' + '1.2' ---
  197. float(124.2)
  198. --- testing: '123abc' + '-7.7' ---
  199. float(115.3)
  200. --- testing: '123abc' + 'abc' ---
  201. Unsupported operand types: string + string
  202. --- testing: '123abc' + '123abc' ---
  203. int(246)
  204. --- testing: '123abc' + '123e5' ---
  205. float(12300123)
  206. --- testing: '123abc' + '123e5xyz' ---
  207. float(12300123)
  208. --- testing: '123abc' + ' 123abc' ---
  209. int(246)
  210. --- testing: '123abc' + '123 abc' ---
  211. int(246)
  212. --- testing: '123abc' + '123abc ' ---
  213. int(246)
  214. --- testing: '123abc' + '3.4a' ---
  215. float(126.4)
  216. --- testing: '123abc' + 'a5.9' ---
  217. Unsupported operand types: string + string
  218. --- testing: '123e5' + '0' ---
  219. float(12300000)
  220. --- testing: '123e5' + '65' ---
  221. float(12300065)
  222. --- testing: '123e5' + '-44' ---
  223. float(12299956)
  224. --- testing: '123e5' + '1.2' ---
  225. float(12300001.2)
  226. --- testing: '123e5' + '-7.7' ---
  227. float(12299992.3)
  228. --- testing: '123e5' + 'abc' ---
  229. Unsupported operand types: string + string
  230. --- testing: '123e5' + '123abc' ---
  231. float(12300123)
  232. --- testing: '123e5' + '123e5' ---
  233. float(24600000)
  234. --- testing: '123e5' + '123e5xyz' ---
  235. float(24600000)
  236. --- testing: '123e5' + ' 123abc' ---
  237. float(12300123)
  238. --- testing: '123e5' + '123 abc' ---
  239. float(12300123)
  240. --- testing: '123e5' + '123abc ' ---
  241. float(12300123)
  242. --- testing: '123e5' + '3.4a' ---
  243. float(12300003.4)
  244. --- testing: '123e5' + 'a5.9' ---
  245. Unsupported operand types: string + string
  246. --- testing: '123e5xyz' + '0' ---
  247. float(12300000)
  248. --- testing: '123e5xyz' + '65' ---
  249. float(12300065)
  250. --- testing: '123e5xyz' + '-44' ---
  251. float(12299956)
  252. --- testing: '123e5xyz' + '1.2' ---
  253. float(12300001.2)
  254. --- testing: '123e5xyz' + '-7.7' ---
  255. float(12299992.3)
  256. --- testing: '123e5xyz' + 'abc' ---
  257. Unsupported operand types: string + string
  258. --- testing: '123e5xyz' + '123abc' ---
  259. float(12300123)
  260. --- testing: '123e5xyz' + '123e5' ---
  261. float(24600000)
  262. --- testing: '123e5xyz' + '123e5xyz' ---
  263. float(24600000)
  264. --- testing: '123e5xyz' + ' 123abc' ---
  265. float(12300123)
  266. --- testing: '123e5xyz' + '123 abc' ---
  267. float(12300123)
  268. --- testing: '123e5xyz' + '123abc ' ---
  269. float(12300123)
  270. --- testing: '123e5xyz' + '3.4a' ---
  271. float(12300003.4)
  272. --- testing: '123e5xyz' + 'a5.9' ---
  273. Unsupported operand types: string + string
  274. --- testing: ' 123abc' + '0' ---
  275. int(123)
  276. --- testing: ' 123abc' + '65' ---
  277. int(188)
  278. --- testing: ' 123abc' + '-44' ---
  279. int(79)
  280. --- testing: ' 123abc' + '1.2' ---
  281. float(124.2)
  282. --- testing: ' 123abc' + '-7.7' ---
  283. float(115.3)
  284. --- testing: ' 123abc' + 'abc' ---
  285. Unsupported operand types: string + string
  286. --- testing: ' 123abc' + '123abc' ---
  287. int(246)
  288. --- testing: ' 123abc' + '123e5' ---
  289. float(12300123)
  290. --- testing: ' 123abc' + '123e5xyz' ---
  291. float(12300123)
  292. --- testing: ' 123abc' + ' 123abc' ---
  293. int(246)
  294. --- testing: ' 123abc' + '123 abc' ---
  295. int(246)
  296. --- testing: ' 123abc' + '123abc ' ---
  297. int(246)
  298. --- testing: ' 123abc' + '3.4a' ---
  299. float(126.4)
  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(188)
  306. --- testing: '123 abc' + '-44' ---
  307. int(79)
  308. --- testing: '123 abc' + '1.2' ---
  309. float(124.2)
  310. --- testing: '123 abc' + '-7.7' ---
  311. float(115.3)
  312. --- testing: '123 abc' + 'abc' ---
  313. Unsupported operand types: string + string
  314. --- testing: '123 abc' + '123abc' ---
  315. int(246)
  316. --- testing: '123 abc' + '123e5' ---
  317. float(12300123)
  318. --- testing: '123 abc' + '123e5xyz' ---
  319. float(12300123)
  320. --- testing: '123 abc' + ' 123abc' ---
  321. int(246)
  322. --- testing: '123 abc' + '123 abc' ---
  323. int(246)
  324. --- testing: '123 abc' + '123abc ' ---
  325. int(246)
  326. --- testing: '123 abc' + '3.4a' ---
  327. float(126.4)
  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(188)
  334. --- testing: '123abc ' + '-44' ---
  335. int(79)
  336. --- testing: '123abc ' + '1.2' ---
  337. float(124.2)
  338. --- testing: '123abc ' + '-7.7' ---
  339. float(115.3)
  340. --- testing: '123abc ' + 'abc' ---
  341. Unsupported operand types: string + string
  342. --- testing: '123abc ' + '123abc' ---
  343. int(246)
  344. --- testing: '123abc ' + '123e5' ---
  345. float(12300123)
  346. --- testing: '123abc ' + '123e5xyz' ---
  347. float(12300123)
  348. --- testing: '123abc ' + ' 123abc' ---
  349. int(246)
  350. --- testing: '123abc ' + '123 abc' ---
  351. int(246)
  352. --- testing: '123abc ' + '123abc ' ---
  353. int(246)
  354. --- testing: '123abc ' + '3.4a' ---
  355. float(126.4)
  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(68.4)
  362. --- testing: '3.4a' + '-44' ---
  363. float(-40.6)
  364. --- testing: '3.4a' + '1.2' ---
  365. float(4.6)
  366. --- testing: '3.4a' + '-7.7' ---
  367. float(-4.300000000000001)
  368. --- testing: '3.4a' + 'abc' ---
  369. Unsupported operand types: string + string
  370. --- testing: '3.4a' + '123abc' ---
  371. float(126.4)
  372. --- testing: '3.4a' + '123e5' ---
  373. float(12300003.4)
  374. --- testing: '3.4a' + '123e5xyz' ---
  375. float(12300003.4)
  376. --- testing: '3.4a' + ' 123abc' ---
  377. float(126.4)
  378. --- testing: '3.4a' + '123 abc' ---
  379. float(126.4)
  380. --- testing: '3.4a' + '123abc ' ---
  381. float(126.4)
  382. --- testing: '3.4a' + '3.4a' ---
  383. float(6.8)
  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