@@ -6,20 +6,20 @@ s = open(file, "w") do f
66end
77t = " Hello World" . data
88@test Mmap. mmap (file, Array{UInt8,3 }, (11 ,1 ,1 )) == reshape (t,(11 ,1 ,1 ))
9- gc ()
9+ gc (); gc ()
1010@test Mmap. mmap (file, Array{UInt8,3 }, (1 ,11 ,1 )) == reshape (t,(1 ,11 ,1 ))
11- gc ()
11+ gc (); gc ()
1212@test Mmap. mmap (file, Array{UInt8,3 }, (1 ,1 ,11 )) == reshape (t,(1 ,1 ,11 ))
13- gc ()
13+ gc (); gc ()
1414@test_throws ArgumentError Mmap. mmap (file, Array{UInt8,3 }, (11 ,0 ,1 )) # 0-dimension results in len=0
1515@test Mmap. mmap (file, Vector{UInt8}, (11 ,)) == t
16- gc ()
16+ gc (); gc ()
1717@test Mmap. mmap (file, Array{UInt8,2 }, (1 ,11 )) == t'
18- gc ()
18+ gc (); gc ()
1919@test_throws ArgumentError Mmap. mmap (file, Array{UInt8,2 }, (0 ,12 ))
2020m = Mmap. mmap (file, Array{UInt8,3 }, (1 ,2 ,1 ))
2121@test m == reshape (" He" . data,(1 ,2 ,1 ))
22- m= nothing ; gc ()
22+ finalize (m); m= nothing ; gc ()
2323
2424# constructors
2525@test length (Mmap. mmap (file)) == 12
@@ -45,15 +45,15 @@ s = open(file)
4545@test length (Mmap. mmap (s, Vector{Int8}, 12 , 0 ; shared= false )) == 12
4646close (s)
4747@test_throws ErrorException Mmap. mmap (file, Vector{Ref}) # must be bit-type
48- gc ()
48+ gc (); gc ()
4949
5050s = open (f-> f,file," w" )
5151@test_throws ArgumentError Mmap. mmap (file) # requested len=0 on empty file
5252@test_throws ArgumentError Mmap. mmap (file,Vector{UInt8},0 )
5353m = Mmap. mmap (file,Vector{UInt8},12 )
5454m[:] = " Hello World\n " . data
5555Mmap. sync! (m)
56- m= nothing ; gc ()
56+ finalize (m); m= nothing ; gc ()
5757@test open (readall,file) == " Hello World\n "
5858
5959s = open (file, " r" )
@@ -70,30 +70,30 @@ close(s)
7070for i = 0x01 : 0x0c
7171 @test length (Mmap. mmap (file, Vector{UInt8}, i)) == Int (i)
7272end
73- gc ()
73+ gc (); gc ()
7474
7575sz = filesize (file)
7676m = Mmap. mmap (file, Vector{UInt8}, sz+ 1 )
7777@test length (m) == sz+ 1 # test growing
7878@test m[end ] == 0x00
79- m= nothing ; gc ()
79+ finalize (m); m= nothing ; gc ()
8080sz = filesize (file)
8181m = Mmap. mmap (file, Vector{UInt8}, 1 , sz)
8282@test length (m) == 1
8383@test m[1 ] == 0x00
84- m= nothing ; gc ()
84+ finalize (m); m= nothing ; gc ()
8585sz = filesize (file)
8686# test where offset is actually > than size of file; file is grown with zeroed bytes
8787m = Mmap. mmap (file, Vector{UInt8}, 1 , sz+ 1 )
8888@test length (m) == 1
8989@test m[1 ] == 0x00
90- m= nothing ; gc ()
90+ finalize (m); m= nothing ; gc ()
9191
9292# Uncomment out once #11351 is resolved
9393# s = open(file, "r")
9494# m = Mmap.mmap(s)
9595# @test_throws ReadOnlyMemoryError m[5] = Vector{UInt8}('x') # tries to setindex! on read-only array
96- # m=nothing; gc()
96+ # finalize(m); m=nothing; gc()
9797
9898s = open (file, " w" ) do f
9999 write (f, " Hello World\n " )
102102s = open (file, " r" )
103103m = Mmap. mmap (s)
104104close (s)
105- m= nothing ; gc ()
105+ finalize (m); m= nothing ; gc ()
106106m = Mmap. mmap (file)
107107s = open (file, " r+" )
108108c = Mmap. mmap (s)
@@ -112,6 +112,7 @@ Mmap.sync!(c)
112112close (s)
113113@test m[1 ] == UInt8 (' J' )
114114@test d[1 ] == UInt8 (' J' )
115+ finalize (m); finalize (c); finalize (d)
115116m= nothing ; c= nothing ; d= nothing ; gc ()
116117
117118s = open (file, " w" ) do f
@@ -122,10 +123,10 @@ s = open(file, "r")
122123@test isreadonly (s) == true
123124c = Mmap. mmap (s, Vector{UInt8}, (11 ,))
124125@test c == " Hello World" . data
125- c= nothing ; gc ()
126+ finalize (c); c= nothing ; gc ()
126127c = Mmap. mmap (s, Vector{UInt8}, (UInt16 (11 ),))
127128@test c == " Hello World" . data
128- c= nothing ; gc ()
129+ finalize (c); c= nothing ; gc ()
129130@test_throws ArgumentError Mmap. mmap (s, Vector{UInt8}, (Int16 (- 11 ),))
130131@test_throws ArgumentError Mmap. mmap (s, Vector{UInt8}, (typemax (UInt),))
131132close (s)
@@ -139,22 +140,22 @@ s = open(file, "r")
139140str = readline (s)
140141close (s)
141142@test startswith (str, " Hellx World" )
142- c= nothing ; gc ()
143+ finalize (c); c= nothing ; gc ()
143144
144145c = Mmap. mmap (file)
145146@test c == " Hellx World\n " . data
146- c= nothing ; gc ()
147+ finalize (c); c= nothing ; gc ()
147148c = Mmap. mmap (file, Vector{UInt8}, 3 )
148149@test c == " Hel" . data
149- c= nothing ; gc ()
150+ finalize (c); c= nothing ; gc ()
150151s = open (file, " r" )
151152c = Mmap. mmap (s, Vector{UInt8}, 6 )
152153@test c == " Hellx " . data
153154close (s)
154- c= nothing ; gc ()
155+ finalize (c); c= nothing ; gc ()
155156c = Mmap. mmap (file, Vector{UInt8}, 5 , 6 )
156157@test c == " World" . data
157- c= nothing ; gc ()
158+ finalize (c); c= nothing ; gc ()
158159
159160s = open (file, " w" )
160161write (s, " Hello World\n " )
@@ -167,7 +168,7 @@ for i = 1:12
167168 @test m[i] == t. data[i]
168169end
169170@test_throws BoundsError m[13 ]
170- m= nothing ; gc ()
171+ finalize (m); m= nothing ; gc ()
171172
172173m = Mmap. mmap (file,Vector{UInt8},6 )
173174@test m[1 ] == " H" . data[1 ]
@@ -177,7 +178,7 @@ m = Mmap.mmap(file,Vector{UInt8},6)
177178@test m[5 ] == " o" . data[1 ]
178179@test m[6 ] == " " . data[1 ]
179180@test_throws BoundsError m[7 ]
180- m= nothing ; gc ()
181+ finalize (m); m= nothing ; gc ()
181182
182183m = Mmap. mmap (file,Vector{UInt8},2 ,6 )
183184@test m[1 ] == " W" . data[1 ]
@@ -283,3 +284,4 @@ n = similar(m, (2,2))
283284n = similar (m, 12 )
284285@test length (n) == 12
285286@test size (n) == (12 ,)
287+ finalize (m); m = nothing ; gc ()
0 commit comments