negate_variationStr.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Test -N 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. foreach ($strVals as $strVal) {
  10. echo "--- testing: '$strVal' ---\n";
  11. var_dump(-$strVal);
  12. }
  13. ?>
  14. ===DONE===
  15. --EXPECTF--
  16. --- testing: '0' ---
  17. int(0)
  18. --- testing: '65' ---
  19. int(-65)
  20. --- testing: '-44' ---
  21. int(44)
  22. --- testing: '1.2' ---
  23. float(-1.2)
  24. --- testing: '-7.7' ---
  25. float(7.7)
  26. --- testing: 'abc' ---
  27. Warning: A non-numeric value encountered in %s on line %d
  28. int(0)
  29. --- testing: '123abc' ---
  30. Notice: A non well formed numeric value encountered in %s on line %d
  31. int(-123)
  32. --- testing: '123e5' ---
  33. float(-12300000)
  34. --- testing: '123e5xyz' ---
  35. Notice: A non well formed numeric value encountered in %s on line %d
  36. float(-12300000)
  37. --- testing: ' 123abc' ---
  38. Notice: A non well formed numeric value encountered in %s on line %d
  39. int(-123)
  40. --- testing: '123 abc' ---
  41. Notice: A non well formed numeric value encountered in %s on line %d
  42. int(-123)
  43. --- testing: '123abc ' ---
  44. Notice: A non well formed numeric value encountered in %s on line %d
  45. int(-123)
  46. --- testing: '3.4a' ---
  47. Notice: A non well formed numeric value encountered in %s on line %d
  48. float(-3.4)
  49. --- testing: 'a5.9' ---
  50. Warning: A non-numeric value encountered in %s on line %d
  51. int(0)
  52. ===DONE===