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