2 !TODO: Move these testcases to gfortran testsuite
3 ! once compilation with pthreads is supported there
4 ! PR55818 Reading a REAL from a file which doesn't end in a new line fails
5 ! Test case from PR reporter.
8 !integer :: var ! << works
10 character(len
=10) :: cvar
! << fails
14 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
15 write(99) "1", new_line("")
16 write(99) "2", new_line("")
21 open(99, file
="test.dat")
22 read (99,*, iostat
=stat
) cvar
23 if (stat
/= 0 .or
. cvar
/= "1") stop 1
24 read (99,*, iostat
=stat
) cvar
25 if (stat
/= 0 .or
. cvar
/= "2") stop 2
26 read (99,*, iostat
=stat
) cvar
! << FAILS: stat /= 0
27 if (stat
/= 0 .or
. cvar
/= "3") stop 3 ! << aborts here
31 read (99,*, iostat
=stat
) var
32 if (stat
/= 0 .or
. var
/= 1.0) stop 4
33 read (99,*, iostat
=stat
) var
34 if (stat
/= 0 .or
. var
/= 2.0) stop 5
35 read (99,*, iostat
=stat
) var
! << FAILS: stat /= 0
36 if (stat
/= 0 .or
. var
/= 3.0) stop 6
37 close(99, status
="delete")
39 ! Test real kind with exponents
40 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
41 write(99) "1.0e3", new_line("")
42 write(99) "2.0e-03", new_line("")
46 open(99, file
="test.dat")
47 read (99,*, iostat
=stat
) var
49 read (99,*, iostat
=stat
) var
51 read (99,*) var
! << FAILS: stat /= 0
53 close(99, status
="delete")
56 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
57 write(99) "Tru", new_line("")
58 write(99) "fal", new_line("")
62 open(99, file
="test.dat")
63 read (99,*, iostat
=stat
) lvar
64 if (stat
/= 0 .or
. (.not
.lvar
)) stop 10
65 read (99,*, iostat
=stat
) lvar
66 if (stat
/= 0 .or
. lvar
) stop 11
67 read (99,*) lvar
! << FAILS: stat /= 0
68 if (stat
/= 0 .or
. (.not
.lvar
)) stop 12
69 close(99, status
="delete")
71 ! Test combinations of Inf and Nan
72 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
73 write(99) "infinity", new_line("")
74 write(99) "nan", new_line("")
78 open(99, file
="test.dat")
79 read (99,*, iostat
=stat
) var
80 if (stat
/= 0) stop 13
81 read (99,*, iostat
=stat
) var
82 if (stat
/= 0) stop 14
83 read (99,*) var
! << FAILS: stat /= 0
84 if (stat
/= 0) stop 1! << aborts here
85 close(99, status
="delete")
87 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
88 write(99) "infinity", new_line("")
89 write(99) "inf", new_line("")
93 open(99, file
="test.dat")
94 read (99,*, iostat
=stat
) var
95 if (stat
/= 0) stop 15
96 read (99,*, iostat
=stat
) var
97 if (stat
/= 0) stop 16
98 read (99,*) var
! << FAILS: stat /= 0
99 if (stat
/= 0) stop 2! << aborts here
100 close(99, status
="delete")
102 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
103 write(99) "infinity", new_line("")
104 write(99) "nan", new_line("")
108 open(99, file
="test.dat")
109 read (99,*, iostat
=stat
) var
110 if (stat
/= 0) stop 17
111 read (99,*, iostat
=stat
) var
112 if (stat
/= 0) stop 18
113 read (99,*) var
! << FAILS: stat /= 0
114 if (stat
/= 0) stop 3! << aborts here
115 close(99, status
="delete")
118 open(99, file
="test.dat", access
="stream", form
="unformatted", status
="new")
119 write(99) "(1,2)", new_line("")
120 write(99) "(2,3)", new_line("")
124 open(99, file
="test.dat")
125 read (99,*, iostat
=stat
) cval
126 if (stat
/= 0 .or
. cval
/= cmplx(1,2)) stop 19
127 read (99,*, iostat
=stat
) cval
128 if (stat
/= 0 .or
. cval
/= cmplx(2,3)) stop 20
129 read (99,*, iostat
=stat
) cval
! << FAILS: stat /= 0, value is okay
130 if (stat
/= 0 .or
. cval
/= cmplx(4,5)) stop 21
131 close(99, status
="delete")