/test/language/unclassified/test_general1.e

http://github.com/tybor/Liberty · Specman e · 128 lines · 74 code · 12 blank · 42 comment · 1 complexity · ed9cbee64cd7c3306c1661f024e4a8d7 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_GENERAL1
  5. create {}
  6. make
  7. feature {ANY}
  8. any: ABSTRACT_STRING
  9. ai8: ARRAY[INTEGER_8]
  10. ai: ARRAY[INTEGER]
  11. ar: ARRAY[REAL]
  12. d: DICTIONARY[STRING, STRING]
  13. cat: CAT
  14. dog: DOG
  15. make
  16. local
  17. i: INTEGER
  18. do
  19. -- Testing `generating_type' ----------------------------- :
  20. assert(generating_type.is_equal("TEST_GENERAL1"))
  21. create ai.make(1, 2)
  22. assert(("ARRAY[INTEGER_32]").is_equal(ai.generating_type))
  23. create ai8.make(1, 2)
  24. assert(("ARRAY[INTEGER_8]").is_equal(ai8.generating_type))
  25. create ar.make(1, 2)
  26. assert(("ARRAY[REAL_64]").is_equal(ar.generating_type))
  27. create {HASHED_DICTIONARY[STRING, STRING]} d.make
  28. assert(d.generating_type.is_equal("HASHED_DICTIONARY[STRING,STRING]"))
  29. assert(i.generating_type.is_equal("INTEGER_32"))
  30. assert(i.force_to_real_32.generating_type.is_equal("REAL_32"))
  31. assert(i.to_real_64.generating_type.is_equal("REAL_64"))
  32. assert(i.digit.generating_type.is_equal("CHARACTER"))
  33. assert(i.to_string.generating_type.is_equal("STRING"))
  34. assert(i.to_string.to_integer.generating_type.is_equal("INTEGER_32"))
  35. any := i.to_string
  36. assert(any.generating_type.is_equal("STRING"))
  37. -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
  38. --any := i
  39. --assert(any.generating_type.has_prefix("reference INTEGER"))
  40. assert(i.generating_type.has_prefix("INTEGER"))
  41. -- Testing `generator' ----------------------------------- :
  42. assert(generator.is_equal("TEST_GENERAL1"))
  43. assert(("ARRAY").is_equal(ai.generator))
  44. assert(("ARRAY").is_equal(ar.generator))
  45. assert(d.generator.is_equal("HASHED_DICTIONARY"))
  46. assert(i.generator.is_equal("INTEGER_32"))
  47. assert(i.force_to_real_32.generator.is_equal("REAL_32"))
  48. assert(i.to_real_64.generator.is_equal("REAL_64"))
  49. assert(i.to_real_64.generating_type.is_equal("REAL_64"))
  50. assert(i.digit.generator.is_equal("CHARACTER"))
  51. assert(i.to_string.generator.is_equal("STRING"))
  52. any := i.to_string
  53. assert(any.generator.is_equal("STRING"))
  54. -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
  55. --any := i
  56. --assert(any.generator.is_equal("INTEGER_32"))
  57. --assert(any.generating_type.is_equal("reference INTEGER"))
  58. assert(i.generating_type.is_equal("INTEGER_32"))
  59. -- Testing `object_size' --------------------------------- :
  60. create cat
  61. create dog
  62. assert(1.object_size >= True.object_size)
  63. assert('a'.object_size = 1)
  64. assert(dog.object_size = cat.object_size)
  65. assert(object_size > i.object_size)
  66. -- *** Correctly rejected *** (Dom. nov 10th 2004) *** any := dog
  67. assert(dog.object_size /= any.object_size)
  68. -- Testing `same_dynamic_type' --------------------------- :
  69. assert(same_dynamic_type(Current))
  70. assert(ai8.same_dynamic_type({ARRAY[INTEGER_8] 1, << 1, 2 >> }))
  71. assert(ai.same_dynamic_type({ARRAY[INTEGER] 1, << 1, 2 >> }))
  72. assert(ar.same_dynamic_type({ARRAY[REAL] 1, << 0.5 >> }))
  73. -- *** ARRAY[INTEGER] doesn't conform to ARRAY[REAL] (Vincent Croizier, 05/11/2004) ***
  74. -- assert(not ar.same_dynamic_type(ai))
  75. assert(d.same_dynamic_type(d.twin))
  76. i := 7
  77. assert(i.to_string.same_dynamic_type("foo"))
  78. -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
  79. --any := i
  80. --assert(any.same_dynamic_type(i))
  81. -- ARRAY[REAL] does not conform to ANY
  82. --any := ar
  83. --assert(any.same_dynamic_type(ar))
  84. end
  85. assert (b: BOOLEAN)
  86. do
  87. cpt := cpt + 1
  88. if not b then
  89. sedb_breakpoint
  90. std_output.put_string("TEST_GENERAL1: ERROR Test # ")
  91. std_output.put_integer(cpt)
  92. std_output.put_string("%N")
  93. else
  94. --std_output.put_string("Yes%N")
  95. end
  96. end
  97. cpt: INTEGER
  98. end -- class TEST_GENERAL1
  99. --
  100. -- ------------------------------------------------------------------------------------------------------------------------------
  101. -- Copyright notice below. Please read.
  102. --
  103. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  104. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  105. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  106. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  107. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  108. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  109. --
  110. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  111. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  112. --
  113. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  114. --
  115. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  116. -- ------------------------------------------------------------------------------------------------------------------------------