Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
18b8fd0b
Commit
18b8fd0b
authored
Jun 09, 2016
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read from printed output as UTF-8 (fixes #671).
parent
db351598
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
3 deletions
+24
-3
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+11
-3
Completion.hs
src/tests/IHaskell/Test/Completion.hs
+5
-0
Eval.hs
src/tests/IHaskell/Test/Eval.hs
+4
-0
Parser.hs
src/tests/IHaskell/Test/Parser.hs
+4
-0
No files found.
src/IHaskell/Eval/Evaluate.hs
View file @
18b8fd0b
...
...
@@ -8,6 +8,7 @@ This module exports all functions used for evaluation of IHaskell input.
module
IHaskell.Eval.Evaluate
(
interpret
,
testInterpret
,
testEvaluate
,
evaluate
,
flushWidgetMessages
,
Interpreter
,
...
...
@@ -37,7 +38,7 @@ import System.Directory
import
System.Posix.IO
(
createPipe
)
#
endif
import
System.Posix.IO
(
fdToHandle
)
import
System.IO
(
hGetChar
,
hFlush
)
import
System.IO
(
hGetChar
,
h
SetEncoding
,
utf8
,
h
Flush
)
import
System.Random
(
getStdGen
,
randomRs
)
import
Unsafe.Coerce
import
Control.Monad
(
guard
)
...
...
@@ -147,10 +148,15 @@ ihaskellGlobalImports =
,
"import qualified IHaskell.Eval.Widgets"
]
-- |
Evaluation
function for testing.
-- |
Interpreting
function for testing.
testInterpret
::
Interpreter
a
->
IO
a
testInterpret
val
=
interpret
GHC
.
Paths
.
libdir
False
(
const
val
)
-- | Evaluation function for testing.
testEvaluate
::
String
->
IO
()
testEvaluate
str
=
void
$
testInterpret
$
evaluate
defaultKernelState
str
(
const
$
return
()
)
(
\
state
_
->
return
state
)
-- | Run an interpreting action. This is effectively runGhc with initialization and importing. First
-- argument indicates whether `stdin` is handled specially, which cannot be done in a testing
-- environment. The argument passed to the action indicates whether Haskell support libraries are
...
...
@@ -1134,7 +1140,9 @@ capturedEval output stmt = do
-- Then convert the HValue into an executable bit, and read the value.
pipe
<-
liftIO
$
do
fd
<-
head
<$>
unsafeCoerce
hValues
fdToHandle
fd
handle
<-
fdToHandle
fd
hSetEncoding
handle
utf8
return
handle
-- Keep track of whether execution has completed.
completed
<-
liftIO
$
newMVar
False
...
...
src/tests/IHaskell/Test/Completion.hs
View file @
18b8fd0b
{-# LANGUAGE CPP #-}
module
IHaskell.Test.Completion
(
testCompletions
)
where
import
Prelude
...
...
@@ -21,6 +22,10 @@ import IHaskell.Eval.Completion (complete, CompletionType(..), complet
completionTarget
)
import
IHaskell.Test.Util
(
replace
,
shouldBeAmong
,
ghc
)
#
if
!
MIN_VERSION_base
(
4
,
8
,
0
)
import
Control.Applicative
((
<$>
))
#
endif
-- | @readCompletePrompt "xs*ys"@ return @(xs, i)@ where i is the location of
-- @'*'@ in the input string.
readCompletePrompt
::
String
->
(
String
,
Int
)
...
...
src/tests/IHaskell/Test/Eval.hs
View file @
18b8fd0b
...
...
@@ -143,6 +143,10 @@ testEval =
"import qualified Control.Monad as CM"
`
becomes
`
[]
"import Control.Monad (when)"
`
becomes
`
[]
it
"prints Unicode characters correctly"
$
do
"putStrLn
\"
Héllö, Üñiço∂e!
\"
"
`
becomes
`
[
"Héllö, Üñiço∂e!"
]
"putStrLn
\"
Привет!
\"
"
`
becomes
`
[
"Привет!"
]
it
"evaluates directives"
$
do
":typ 3"
`
becomes
`
[
"3 :: forall a. Num a => a"
]
":k Maybe"
`
becomes
`
[
"Maybe :: * -> *"
]
...
...
src/tests/IHaskell/Test/Parser.hs
View file @
18b8fd0b
...
...
@@ -15,6 +15,10 @@ import IHaskell.Eval.Parser (parseString, getModuleName, unloc, layout
CodeBlock
(
..
),
DirectiveType
(
..
),
StringLoc
(
..
))
import
IHaskell.Eval.ParseShell
(
parseShell
)
#
if
!
MIN_VERSION_base
(
4
,
8
,
0
)
import
Control.Applicative
((
<$>
))
#
endif
parses
::
String
->
IO
[
CodeBlock
]
parses
str
=
map
unloc
<$>
ghc
(
parseString
str
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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