/test/lib/io/test_basic_directory.e

http://github.com/tybor/Liberty · Specman e · 211 lines · 175 code · 14 blank · 22 comment · 1 complexity · 8da0090c7e4a763ddce132db7f30cbba 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_BASIC_DIRECTORY
  5. insert
  6. DIRECTORY_NOTATION_HANDLER
  7. EIFFELTEST_TOOLS
  8. create {}
  9. make
  10. feature {}
  11. bd: BASIC_DIRECTORY
  12. make
  13. -- To test BASIC_DIRECTORY.try_to_compute_notation:
  14. do
  15. bd.reset_notation_using("SOMEDISK:[SmartEiffel.sys]system.se")
  16. assert(bd.openvms_notation)
  17. bd.reset_notation_using("/home/SmartEiffel/sys/system.se")
  18. assert(bd.unix_notation)
  19. unix_test
  20. bd.reset_notation_using("//D/SmartEiffel/sys/system.se")
  21. assert(bd.cygwin_notation)
  22. cygwin_test
  23. bd.reset_notation_using("D:\SmartEiffel\sys\system.se")
  24. assert(bd.windows_notation)
  25. windows_test
  26. open_vms_test
  27. end
  28. unix_test
  29. do
  30. assert(bd.unix_notation)
  31. parent_dir("?", "U", "/SmartEiffel/sys/system.se", "/SmartEiffel/sys/")
  32. parent_dir("?", "U", "/SmartEiffel/sys/", "/SmartEiffel/")
  33. parent_dir("?", "U", "/SmartEiffel/sys", "/SmartEiffel/")
  34. parent_dir("?", "U", "/SmartEiffel/", "/")
  35. parent_dir("?", "U", "/SmartEiffel", "/")
  36. parent_dir("?", "U", "/", "")
  37. sub_direct("?", "U", "/", "SmartEiffel", "/SmartEiffel/")
  38. sub_direct("?", "U", "/SmartEiffel/", "sys", "/SmartEiffel/sys/")
  39. sub_direct("?", "U", "/SmartEiffel", "sys", "/SmartEiffel/sys/")
  40. add_filena("U", "U", "SmartEiffel", "system.se", "SmartEiffel/system.se")
  41. add_filena("?", "U", "SmartEiffel/", "system.se", "SmartEiffel/system.se")
  42. add_filena("?", "U", "/SmartEiffel", "system.se", "/SmartEiffel/system.se")
  43. add_filena("?", "U", "/SmartEiffel/", "system.se", "/SmartEiffel/system.se")
  44. add_filena("?", "U", "/", "system.se", "/system.se")
  45. end
  46. windows_test
  47. do
  48. set_notation_using_old_implementation_name("W")
  49. assert(bd.windows_notation)
  50. parent_dir("?", "W", "C:\SmartEiffel\sys\system.se", "C:\SmartEiffel\sys")
  51. parent_dir("?", "W", "C:\SmartEiffel\sys\", "C:\SmartEiffel")
  52. parent_dir("?", "W", "C:\SmartEiffel\sys", "C:\SmartEiffel")
  53. parent_dir("?", "W", "C:\SmartEiffel\", "C:")
  54. parent_dir("?", "W", "C:\SmartEiffel", "C:")
  55. parent_dir("?", "W", "C:", "")
  56. sub_direct("?", "W", "C:", "SmartEiffel", "C:\SmartEiffel")
  57. sub_direct("?", "W", "C:\", "SmartEiffel", "C:\SmartEiffel")
  58. sub_direct("?", "W", "C:\", "SmartEiffel\", "C:\SmartEiffel")
  59. sub_direct("?", "W", "C:\SmartEiffel", "sys", "C:\SmartEiffel\sys")
  60. sub_direct("?", "W", "C:\SmartEiffel\", "sys", "C:\SmartEiffel\sys")
  61. add_filena("?", "W", "C:\SmartEiffel\sys", "system.se", "C:\SmartEiffel\sys\system.se")
  62. add_filena("?", "W", "C:\SmartEiffel\sys\", "system.se", "C:\SmartEiffel\sys\system.se")
  63. add_filena("?", "W", "C:", "system.se", "C:\system.se")
  64. add_filena("?", "W", "C:\", "system.se", "C:\system.se")
  65. end
  66. cygwin_test
  67. do
  68. bd.reset_notation_using("//D/SmartEiffel/sys/system.se")
  69. assert(bd.cygwin_notation)
  70. parent_dir("?", "C", "//D/SmartEiffel/sys/system.se", "//D/SmartEiffel/sys/")
  71. parent_dir("?", "C", "//D/SmartEiffel/sys/", "//D/SmartEiffel/")
  72. parent_dir("?", "C", "//D/SmartEiffel/sys", "//D/SmartEiffel/")
  73. parent_dir("?", "C", "//D/SmartEiffel/", "//D/")
  74. parent_dir("?", "C", "//D/SmartEiffel", "//D/")
  75. parent_dir("?", "C", "//D/", "/")
  76. parent_dir("C", "C", "//D", "/")
  77. sub_direct("C", "C", "//D/", "SmartEiffel", "//D/SmartEiffel/")
  78. sub_direct("C", "C", "//D", "SmartEiffel", "//D/SmartEiffel/")
  79. sub_direct("?", "C", "//D/SmartEiffel/", "sys", "//D/SmartEiffel/sys/")
  80. sub_direct("?", "C", "//D/SmartEiffel", "sys", "//D/SmartEiffel/sys/")
  81. add_filena("C", "C", "SmartEiffel", "system.se", "SmartEiffel/system.se")
  82. add_filena("C", "C", "SmartEiffel/", "system.se", "SmartEiffel/system.se")
  83. add_filena("?", "C", "//D/SmartEiffel", "system.se", "//D/SmartEiffel/system.se")
  84. add_filena("?", "C", "//D/SmartEiffel/", "system.se", "//D/SmartEiffel/system.se")
  85. add_filena("C", "C", "/", "system.se", "/system.se")
  86. parent_dir("C", "C", "D:/SmartEiffel/sys/system.se", "D:/SmartEiffel/sys/")
  87. parent_dir("C", "C", "D:/SmartEiffel/sys/", "D:/SmartEiffel/")
  88. parent_dir("C", "C", "D:/SmartEiffel/sys", "D:/SmartEiffel/")
  89. parent_dir("C", "C", "D:/SmartEiffel/", "D:/")
  90. parent_dir("C", "C", "D:/SmartEiffel", "D:/")
  91. sub_direct("C", "C", "D:/", "SmartEiffel", "D:/SmartEiffel/")
  92. sub_direct("C", "C", "D:", "SmartEiffel", "D:/SmartEiffel/")
  93. sub_direct("C", "C", "D:/SmartEiffel/", "sys", "D:/SmartEiffel/sys/")
  94. sub_direct("C", "C", "D:/SmartEiffel", "sys", "D:/SmartEiffel/sys/")
  95. add_filena("C", "C", "SmartEiffel", "system.se", "SmartEiffel/system.se")
  96. add_filena("C", "C", "SmartEiffel/", "system.se", "SmartEiffel/system.se")
  97. add_filena("C", "C", "D:/SmartEiffel", "system.se", "D:/SmartEiffel/system.se")
  98. add_filena("C", "C", "D:/SmartEiffel/", "system.se", "D:/SmartEiffel/system.se")
  99. add_filena("C", "C", "/", "system.se", "/system.se")
  100. end
  101. open_vms_test
  102. do
  103. set_notation_using_old_implementation_name("V")
  104. assert(bd.openvms_notation)
  105. parent_dir("?", "V", "DISK:[SmartEiffel.sys]system.se", "DISK:[SmartEiffel.sys]")
  106. parent_dir("?", "V", "DISK:[SmartEiffel.sys]", "DISK:[SmartEiffel]")
  107. parent_dir("?", "V", "DISK:[SmartEiffel]", "DISK:[]")
  108. sub_direct("V", "V", "DISK:", "SmartEiffel", "DISK:[SmartEiffel]")
  109. sub_direct("?", "V", "DISK:[]", "SmartEiffel", "DISK:[SmartEiffel]")
  110. sub_direct("?", "V", "DISK:[SmartEiffel]", "sys", "DISK:[SmartEiffel.sys]")
  111. add_filena("?", "V", "DISK:[SmartEiffel.sys]", "system.se", "DISK:[SmartEiffel.sys]system.se")
  112. end
  113. parent_dir (n1, n2, p1, p2: STRING)
  114. local
  115. view: STRING
  116. do
  117. set_notation_using_old_implementation_name(n1)
  118. bd.compute_parent_directory_of(p1)
  119. view := bd.last_entry
  120. assert(to_old_implementation_name.is_equal(n2))
  121. assert(view.is_equal(p2))
  122. end
  123. sub_direct (n1, n2, p1, p2, p3: STRING)
  124. local
  125. view: STRING
  126. do
  127. set_notation_using_old_implementation_name(n1)
  128. bd.compute_subdirectory_with(p1, p2)
  129. view := bd.last_entry
  130. assert(to_old_implementation_name.is_equal(n2))
  131. assert(view.is_equal(p3))
  132. end
  133. add_filena (n1, n2, p1, f, p2: STRING)
  134. local
  135. view: STRING
  136. do
  137. set_notation_using_old_implementation_name(n1)
  138. bd.compute_file_path_with(p1, f)
  139. view := bd.last_entry
  140. assert(to_old_implementation_name.is_equal(n2))
  141. assert(view.is_equal(p2))
  142. end
  143. to_old_implementation_name: STRING
  144. do
  145. if bd.unix_notation then
  146. Result := once "U"
  147. elseif bd.windows_notation then
  148. Result := once "W"
  149. elseif bd.cygwin_notation then
  150. Result := once "C"
  151. elseif bd.openvms_notation then
  152. Result := once "V"
  153. else
  154. not_yet_implemented
  155. end
  156. end
  157. set_notation_using_old_implementation_name (old_implementation_name: STRING)
  158. do
  159. inspect
  160. old_implementation_name
  161. when "?" then
  162. bd.system_notation_buffer.set_item(Void)
  163. when "U" then
  164. bd.reset_notation_using("/users/local/tex")
  165. assert(bd.unix_notation)
  166. when "C" then
  167. bd.reset_notation_using("//D/SmartEiffel/sys/system.se")
  168. assert(bd.cygwin_notation)
  169. when "W" then
  170. bd.reset_notation_using("C:\WINNT")
  171. assert(bd.windows_notation)
  172. when "V" then
  173. bd.system_notation_buffer.set_item(create {OPENVMS_DIRECTORY_NOTATION})
  174. assert(bd.openvms_notation)
  175. else
  176. not_yet_implemented
  177. end
  178. end
  179. end -- class TEST_BASIC_DIRECTORY
  180. --
  181. -- ------------------------------------------------------------------------------------------------------------------------------
  182. -- Copyright notice below. Please read.
  183. --
  184. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  185. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  186. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  187. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  188. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  189. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  190. --
  191. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  192. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  193. --
  194. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  195. --
  196. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  197. -- ------------------------------------------------------------------------------------------------------------------------------