1
1
using FileIO, Compat
2
- using FactCheck
2
+ if VERSION >= v " 0.5.0-dev+7720"
3
+ using Base. Test
4
+ else
5
+ using BaseTestNext
6
+ const Test = BaseTestNext
7
+ end
3
8
4
9
# Stub readers---these might bork any existing readers, so don't
5
10
# run these tests while doing other things!
18
23
empty! (FileIO. sym2loader)
19
24
empty! (FileIO. sym2saver)
20
25
file_dir = joinpath (dirname (@__FILE__ ), " files" )
21
- context ( " Load" ) do
26
+ @testset " Load" begin
22
27
23
28
add_loader (format " PBMText" , :TestLoadSave )
24
29
add_loader (format " PBMBinary" , :TestLoadSave )
25
30
add_loader (format " HDF5" , :TestLoadSave )
26
31
add_loader (format " JLD" , :TestLoadSave )
27
32
28
- @fact load (joinpath (file_dir, " file1.pbm" )) --> " PBMText"
29
- @fact load (joinpath (file_dir, " file2.pbm" )) --> " PBMBinary"
33
+ @test load (joinpath (file_dir," file1.pbm" )) == " PBMText"
34
+ @test load (joinpath (file_dir," file2.pbm" )) == " PBMBinary"
30
35
# Regular HDF5 file with magic bytes starting at position 0
31
- @fact load (joinpath (file_dir, " file1.h5" )) --> " HDF5"
36
+ @test load (joinpath (file_dir," file1.h5" )) == " HDF5"
32
37
# This one is actually a JLD file saved with an .h5 extension,
33
38
# and the JLD magic bytes edited to prevent it from being recognized
34
39
# as JLD.
35
40
# JLD files are also HDF5 files, so this should be recognized as
36
41
# HDF5. However, what makes this more interesting is that the
37
42
# magic bytes start at position 512.
38
- @fact load (joinpath (file_dir, " file2.h5" )) --> " HDF5"
43
+ @test load (joinpath (file_dir," file2.h5" )) == " HDF5"
39
44
# JLD file saved with .jld extension
40
- @fact load (joinpath (file_dir, " file.jld" )) --> " JLD"
45
+ @test load (joinpath (file_dir," file.jld" )) == " JLD"
41
46
42
- @fact_throws load (" missing.fmt" )
47
+ @test_throws Exception load (" missing.fmt" )
43
48
end
44
49
finally
45
50
merge! (FileIO. sym2loader, sym2loader)
87
92
add_loader (format " DUMMY" , :Dummy )
88
93
add_saver (format " DUMMY" , :Dummy )
89
94
90
- context ( " Save" ) do
95
+ @testset " Save" begin
91
96
a = [0x01 ,0x02 ,0x03 ]
92
97
fn = string (tempname (), " .dmy" )
93
98
save (fn, a)
@@ -96,46 +101,46 @@ context("Save") do
96
101
cd (dirname (fn)) do
97
102
fnrel = basename (fn)
98
103
f = query (fnrel)
99
- @fact isabspath (filename (f)) --> true
100
- @fact endswith (filename (f), fn) --> true # TravisOSX prepends "/private"
104
+ @test isabspath (filename (f))
105
+ @test endswith (filename (f),fn) # TravisOSX prepends "/private"
101
106
f = File (format " DUMMY" , fnrel)
102
- @fact isabspath (filename (f)) --> false
107
+ @test ! ( isabspath (filename (f)))
103
108
open (f) do s
104
- @fact isabspath (get (filename (s))) --> true
105
- @fact endswith (get (filename (s)), fn) --> true
109
+ @test isabspath (get (filename (s)))
110
+ @test endswith (get (filename (s)),fn)
106
111
end
107
112
end
108
113
109
114
# Test IO
110
115
b = load (query (fn))
111
- @fact a --> b
116
+ @test a == b
112
117
113
118
b = open (query (fn)) do s
114
119
skipmagic (s)
115
120
load (s)
116
121
end
117
- @fact a --> b
122
+ @test a == b
118
123
119
124
# low-level I/O test
120
125
open (query (fn)) do s
121
- @fact position (s) --> 0
126
+ @test position (s) == 0
122
127
skipmagic (s)
123
- @fact position (s) --> length (magic (format " DUMMY" ))
128
+ @test position (s) == length (magic (format " DUMMY" ))
124
129
seek (s, 1 )
125
- @fact position (s) --> 1
130
+ @test position (s) == 1
126
131
seekstart (s)
127
- @fact position (s) --> 0
132
+ @test position (s) == 0
128
133
seekend (s)
129
- @fact eof (s) --> true
134
+ @test eof (s)
130
135
skip (s, - position (s)+ 1 )
131
- @fact position (s) --> 1
132
- @fact isreadonly (s) --> true
133
- @fact isopen (s) --> true
134
- @fact read (s, 2 ) --> b " UM"
136
+ @test position (s) == 1
137
+ @test isreadonly (s)
138
+ @test isopen (s)
139
+ @test read (s,2 ) == b " UM"
135
140
end
136
141
rm (fn)
137
142
138
- @fact_throws save (" missing.fmt" , 5 )
143
+ @test_throws Exception save (" missing.fmt" ,5 )
139
144
end
140
145
141
146
del_format (format " DUMMY" )
@@ -167,7 +172,7 @@ save(f::File{format"AmbigExt2"}, testdata) = open(f, "w") do io
167
172
end
168
173
end
169
174
170
- context ( " Ambiguous extension" ) do
175
+ @testset " Ambiguous extension" begin
171
176
add_format (format " AmbigExt1" , " ambigext1" , " .aext" , [:AmbigExt ])
172
177
add_format (format " AmbigExt2" , " ambigext2" , " .aext" , [:AmbigExt ])
173
178
A = " this is a test"
@@ -179,18 +184,18 @@ context("Ambiguous extension") do
179
184
save (format " AmbigExt2" , fn, A)
180
185
181
186
B = load (fn)
182
- @fact B --> A
183
- @fact typeof (query (fn)) --> File{format " AmbigExt2" }
187
+ @test B == A
188
+ @test typeof (query (fn)) == File{format " AmbigExt2" }
184
189
rm (fn)
185
190
186
191
save (fn, A)
187
192
B = load (fn)
188
- @fact B --> A
189
- @fact typeof (query (fn)) --> File{format " AmbigExt1" }
193
+ @test B == A
194
+ @test typeof (query (fn)) == File{format " AmbigExt1" }
190
195
191
196
rm (fn)
192
197
end
193
198
194
- context ( " Absent file" ) do
195
- @fact_throws SystemError load (" nonexistent.oops" )
196
- end
199
+ @testset " Absent file" begin
200
+ @test_throws SystemError load (" nonexistent.oops" )
201
+ end
0 commit comments