You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 line
1.8 KiB

  1. #! /usr/bin/env escript
  2. main([]) ->
  3. code:add_pathz("ebin"),
  4. code:add_pathz("test"),
  5. etap:plan(57),
  6. util:test_good(good()),
  7. util:test_errors(errors()),
  8. etap:end_tests().
  9. good() ->
  10. [
  11. {<<"0">>, 0},
  12. {<<"-0">>, 0, <<"0">>},
  13. {<<"1">>, 1},
  14. {<<"12">>, 12},
  15. {<<"-3">>, -3},
  16. {<<"1234567890123456789012345">>, 1234567890123456789012345},
  17. {
  18. <<"1234567890123456789012345.0">>,
  19. 1.23456789012345678e24,
  20. <<"1.2345678901234568245e+24">>
  21. },
  22. {
  23. <<"1234567890123456789012345.0E3">>,
  24. 1.2345678901234569e27,
  25. <<"1.2345678901234568502e+27">>
  26. },
  27. {
  28. <<"1234567890123456789012345E2">>,
  29. 123456789012345678901234500,
  30. <<"123456789012345678901234500">>
  31. },
  32. {
  33. <<"0.000000000000000000000000000000000001">>,
  34. 1.0E-36,
  35. <<"9.9999999999999994104e-37">>
  36. },
  37. {<<"1.0">>, 1.0, <<"1">>},
  38. {<<"0.75">>, 0.75},
  39. {<<"2.0123456789">>, 2.0123456789, <<"2.0123456789000000455">>},
  40. {<<"2.4234324E24">>, 2.4234324E24, <<"2.4234323999999998107e+24">>},
  41. {<<"-3.1416">>, -3.1416, <<"-3.1415999999999999481">>},
  42. {<<"1E4">>, 10000.0, <<"10000">>},
  43. {<<"1.0E+01">>, 10.0, <<"10">>},
  44. {<<"1e1">>, 10.0, <<"10">>},
  45. {<<"3.0E2">>, 300.0, <<"300">>},
  46. {<<"0E3">>, 0.0, <<"0">>},
  47. {<<"1.5E3">>, 1500.0, <<"1500">>},
  48. {<<"2.5E-1">>, 0.25, <<"0.25">>},
  49. {<<"-0.325E+2">>, -32.5, <<"-32.5">>}
  50. ].
  51. errors() ->
  52. [
  53. <<"02">>,
  54. <<"-01">>,
  55. <<"+12">>,
  56. <<"-">>,
  57. <<"1.">>,
  58. <<".1">>,
  59. <<"1.-1">>,
  60. <<"1E">>,
  61. <<"1-E2">>,
  62. <<"2E +3">>,
  63. <<"1EA">>
  64. ].