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.

70 lines
1.9 KiB

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