/test/language/unclassified/ac/test_ac02.e

http://github.com/tybor/Liberty · Specman e · 93 lines · 58 code · 9 blank · 26 comment · 0 complexity · 554486ceee93643053850812a3e527a0 MD5 · raw file

  1. -- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2. -- See the Copyright notice at the end of this file.
  3. --
  4. class TEST_AC02
  5. -- From a bug report of Alex Cozzi
  6. insert
  7. EIFFELTEST_TOOLS
  8. creation {ANY}
  9. make
  10. feature {ANY}
  11. Test_count: INTEGER is 10
  12. make is
  13. local
  14. c1: AUX_AC_COMPLEX; c2: AUX_AC_COMPLEX; c3: AUX_AC_COMPLEX; rnd_generator: PRESS_RANDOM_NUMBER_GENERATOR
  15. i: INTEGER
  16. do
  17. from
  18. create rnd_generator.make
  19. i := 0
  20. variant
  21. Test_count - i
  22. until
  23. i = Test_count
  24. loop
  25. c1 := random_complex(rnd_generator)
  26. c2 := random_complex(rnd_generator)
  27. c3 := random_complex(rnd_generator)
  28. test_plus(c1, c2, c3)
  29. test_times(c1, c2, c3)
  30. test_plus_and_times(c1, c2, c3)
  31. i := i + 1
  32. end
  33. end
  34. random_complex (rnd: RANDOM_NUMBER_GENERATOR): AUX_AC_COMPLEX is
  35. local
  36. re: REAL; im: REAL
  37. do
  38. rnd.next
  39. re := rnd.last_real
  40. rnd.next
  41. im := rnd.last_real
  42. Result.set_item(re, im)
  43. end
  44. test_plus (x, y, z: AUX_AC_COMPLEX) is
  45. local
  46. zero: AUX_AC_COMPLEX
  47. do
  48. zero := zero.zero
  49. assert(x + zero = x)
  50. assert(x + y = y + x)
  51. -- assert(((x + y) + z) = (x + (y + z)));
  52. end
  53. test_times (x, y, z: AUX_AC_COMPLEX) is
  54. local
  55. one: AUX_AC_COMPLEX
  56. do
  57. one := one.one
  58. assert(x * one = x)
  59. -- assert((x * y) = (y * x));
  60. -- assert(((x * y) * z) = (x * (y * z)));
  61. end
  62. test_plus_and_times (x, y, z: AUX_AC_COMPLEX) is
  63. do
  64. -- assert(((x + y) * z) = (x * z + y * z));
  65. end
  66. end -- class TEST_AC02
  67. --
  68. -- ------------------------------------------------------------------------------------------------------------------------------
  69. -- Copyright notice below. Please read.
  70. --
  71. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  72. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  73. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  74. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  75. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  76. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  77. --
  78. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  79. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  80. --
  81. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  82. --
  83. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  84. -- ------------------------------------------------------------------------------------------------------------------------------