PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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