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
c2f98a96
Commit
c2f98a96
authored
Jan 06, 2014
by
Eyal Dechter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed tests.
parent
938478ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
Hspec.hs
src/Hspec.hs
+23
-17
No files found.
src/Hspec.hs
View file @
c2f98a96
...
...
@@ -71,9 +71,9 @@ completes string expected = completionTarget newString cursorloc `shouldBe` expe
Nothing
->
error
"Expected cursor written as '!'."
Just
idx
->
(
replace
"!"
""
string
,
idx
)
completionHas
string
expected
=
do
completionHas
_
action
string
expected
=
do
(
matched
,
completions
)
<-
doGhc
$
do
initCompleter
initCompleter
action
complete
newString
cursorloc
let
existsInCompletion
=
(`
elem
`
completions
)
unmatched
=
filter
(
not
.
existsInCompletion
)
expected
...
...
@@ -82,25 +82,28 @@ completionHas string expected = do
Nothing
->
error
"Expected cursor written as '!'."
Just
idx
->
(
replace
"!"
""
string
,
idx
)
initCompleter
::
GhcMonad
m
=>
m
()
initCompleter
=
do
completionHas
=
completionHas_
(
return
()
)
initCompleter
::
GhcMonad
m
=>
m
a
->
m
a
initCompleter
action
=
do
flags
<-
getSessionDynFlags
setSessionDynFlags
$
flags
{
hscTarget
=
HscInterpreted
,
ghcLink
=
LinkInMemory
}
-- Import modules.
imports
<-
mapM
parseImportDecl
[
"import Prelude"
,
"import qualified Control.Monad"
,
"import qualified Data.List as List"
,
"import Data.Maybe as Maybe"
]
"import qualified Control.Monad"
,
"import qualified Data.List as List"
,
"import Data.Maybe as Maybe"
]
setContext
$
map
IIDecl
imports
action
withHsDirectory
::
Sh
(
)
->
IO
()
withHsDirectory
::
(
FilePath
->
Sh
()
)
->
IO
()
withHsDirectory
f
=
shelly
$
withTmpDir
$
\
dirPath
->
do
cd
dirPath
cmd
"mkdir"
$
""
</>
"dir"
cmd
"mkdir"
$
"dir"
</>
"dir1"
cmd
"touch"
"file1.hs"
"dir/file2.hs"
"file1.lhs"
"dir/file2.lhs"
f
f
$
encodeString
dirPath
main
::
IO
()
main
=
hspec
$
do
...
...
@@ -156,14 +159,17 @@ completionTests = do
"import Prel!"
`
completionHas
`
[
"Prelude"
]
it
"properly completes haskell file paths on :load directive"
$
withHsDirectory
$
let
loading
xs
=
":load "
++
encodeString
xs
paths
xs
=
map
encodeString
xs
in
liftIO
$
do
loading
(
"dir"
</>
"file!"
)
`
completionHas
`
paths
[
"dir"
</>
"file2.hs"
,
"dir"
</>
"file2.lhs"
]
loading
(
""
</>
"file1!"
)
`
completionHas
`
paths
[
""
</>
"file1.hs"
,
""
</>
"file1.lhs"
]
withHsDirectory
$
\
dirPath
->
let
loading
xs
=
":load "
++
encodeString
xs
paths
xs
=
map
encodeString
xs
completionHas'
=
completionHas_
$
Eval
.
evaluate
defaultKernelState
(
":! cd "
++
dirPath
)
(
\
b
d
->
return
()
)
in
liftIO
$
do
loading
(
"dir"
</>
"file!"
)
`
completionHas'
`
paths
[
"dir"
</>
"file2.hs"
,
"dir"
</>
"file2.lhs"
]
loading
(
""
</>
"file1!"
)
`
completionHas'
`
paths
[
""
</>
"file1.hs"
,
""
</>
"file1.lhs"
]
evalTests
=
do
describe
"Code Evaluation"
$
do
...
...
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