divide_variationStr.phpt 12 KB

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