Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tobias Decking
GHC
Commits
ae959ec4
Commit
ae959ec4
authored
Nov 25, 2010
by
Simon Marlow
Browse files
Add a test for reliable encoding errors
parent
acf9517f
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/ghc-regress/lib/IO/all.T
View file @
ae959ec4
...
...
@@ -156,3 +156,5 @@ test('openTempFile001', normal, compile_and_run, [''])
test
('
T4113
',
normal
,
compile_and_run
,
[''])
test
('
T4144
',
normal
,
compile_and_run
,
[''])
test
('
encodingerror001
',
normal
,
compile_and_run
,
[''])
testsuite/tests/ghc-regress/lib/IO/encodingerror001.hs
0 → 100644
View file @
ae959ec4
import
System.IO
import
System.IO.Error
import
Text.Printf
import
Control.Monad
main
=
do
hSetEncoding
stdout
latin1
forM
[
NoBuffering
,
LineBuffering
,
BlockBuffering
Nothing
,
BlockBuffering
(
Just
3
),
BlockBuffering
(
Just
9
),
BlockBuffering
(
Just
32
)]
$
\
b
->
do
hSetBuffering
stdout
b
checkedPutStr
"test 1
\n
"
checkedPutStr
"ě
\n
"
-- nothing gets written
checkedPutStr
"test 2
\n
"
checkedPutStr
"Hέllo
\n
"
-- we should write at least the 'H'
checkedPutStr
"test 3
\n
"
checkedPutStr
"Hello αβγ
\n
"
-- we should write at least the "Hello "
checkedPutStr
str
=
do
r
<-
try
$
putStr
str
case
r
of
Right
_
->
return
()
Left
e
->
printf
"Caught %s while trying to write %s
\n
"
(
show
e
)
(
show
str
)
testsuite/tests/ghc-regress/lib/IO/encodingerror001.stdout
0 → 100644
View file @
ae959ec4
test 1
Caught <stdout>: hPutChar: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: hPutChar: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: hPutChar: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
test 1
Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
test 1
Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
test 1
Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
test 1
Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
test 1
Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "\283\n"
test 2
HCaught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "H\941llo\n"
test 3
Hello Caught <stdout>: commitBuffer: invalid argument (character is out of range for this encoding) while trying to write "Hello \945\946\947\n"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment