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