Skip to content

Commit

Permalink
Add eval plugin info cmd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akrmn committed Jun 20, 2021
1 parent 366ce59 commit f7a54e5
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 4 deletions.
4 changes: 3 additions & 1 deletion plugins/hls-eval-plugin/hls-eval-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ extra-source-files:
test/testdata/*.hs
test/testdata/*.lhs
test/testdata/*.yaml
test/testdata/cabal.project
test/info-util/*.cabal
test/info-util/*.hs
test/cabal.project

flag pedantic
description: Enable -Werror
Expand Down
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ tests =
]
, goldenWithEval "Works with NoImplicitPrelude" "TNoImplicitPrelude" "hs"
, goldenWithEval "Variable 'it' works" "TIt" "hs"
, goldenWithEval ":info reports type, constructors and instances" "TInfo" "hs"
, goldenWithEval ":info reports type, constructors and instances for multiple types" "TInfoMany" "hs"
, goldenWithEval ":info! reports type, constructors and unfiltered instances" "TInfoBang" "hs"
, goldenWithEval ":info! reports type, constructors and unfiltered instances for multiple types" "TInfoBangMany" "hs"
, goldenWithEval ":i behaves exactly the same as :info" "TI_Info" "hs"
]

goldenWithEval :: TestName -> FilePath -> FilePath -> TestTree
Expand Down
3 changes: 3 additions & 0 deletions plugins/hls-eval-plugin/test/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
testdata/
info-util/
20 changes: 20 additions & 0 deletions plugins/hls-eval-plugin/test/info-util/InfoUtil.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module InfoUtil
( Eq
, Ord
, Foo (..)
, Bar (..)
, Baz
)
where

import Prelude (Eq, Ord)

data Foo = Foo1 | Foo2
deriving (Eq, Ord)

data Bar = Bar1 | Bar2 | Bar3
deriving (Eq, Ord)

class Baz t
instance Baz Foo
instance Baz Bar
18 changes: 18 additions & 0 deletions plugins/hls-eval-plugin/test/info-util/info-util.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: info-util
version: 0.1.0.0
-- synopsis:
-- description:
license: BSD3
author: Author name here
maintainer: [email protected]
copyright: 2017 Author name here
category: Web
build-type: Simple
cabal-version: >=1.10

library
exposed-modules:
InfoUtil
build-depends: base >= 4.7 && < 5
default-language: Haskell2010
ghc-options: -Wall -fwarn-unused-imports
10 changes: 10 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TI_Info.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module TI_Info (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :i Foo
-- type Foo :: *
-- data Foo = Foo1 | Foo2
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Foo -- Defined in ‘InfoUtil’
-- instance [safe] Ord Foo -- Defined in ‘InfoUtil’
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TI_Info.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TI_Info (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :i Foo
10 changes: 10 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfo.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module TInfo (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :info Foo
-- type Foo :: *
-- data Foo = Foo1 | Foo2
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Foo -- Defined in ‘InfoUtil’
-- instance [safe] Ord Foo -- Defined in ‘InfoUtil’
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TInfo (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :info Foo
11 changes: 11 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoBang.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module TInfoBang (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :info! Foo
-- type Foo :: *
-- data Foo = Foo1 | Foo2
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Foo -- Defined in ‘InfoUtil’
-- instance [safe] Ord Foo -- Defined in ‘InfoUtil’
-- instance [safe] Baz Foo -- Defined in ‘InfoUtil’
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoBang.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TInfoBang (Eq, Ord, Foo) where

import InfoUtil (Eq, Ord, Foo)

-- >>> :info! Foo
17 changes: 17 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoBangMany.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module TInfoBangMany (Eq, Ord, Foo, Bar) where

import InfoUtil (Eq, Ord, Foo, Bar)

-- >>> :info! Foo Bar
-- type Foo :: *
-- data Foo = Foo1 | Foo2
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Foo -- Defined in ‘InfoUtil’
-- instance [safe] Ord Foo -- Defined in ‘InfoUtil’
-- instance [safe] Baz Foo -- Defined in ‘InfoUtil’
-- type Bar :: *
-- data Bar = Bar1 | Bar2 | Bar3
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Bar -- Defined in ‘InfoUtil’
-- instance [safe] Ord Bar -- Defined in ‘InfoUtil’
-- instance [safe] Baz Bar -- Defined in ‘InfoUtil’
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoBangMany.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TInfoBangMany (Eq, Ord, Foo, Bar) where

import InfoUtil (Eq, Ord, Foo, Bar)

-- >>> :info! Foo Bar
15 changes: 15 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoMany.expected.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module TInfoMany (Eq, Ord, Foo, Bar) where

import InfoUtil (Eq, Ord, Foo, Bar)

-- >>> :info Foo Bar
-- type Foo :: *
-- data Foo = Foo1 | Foo2
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Foo -- Defined in ‘InfoUtil’
-- instance [safe] Ord Foo -- Defined in ‘InfoUtil’
-- type Bar :: *
-- data Bar = Bar1 | Bar2 | Bar3
-- -- Defined in ‘InfoUtil’
-- instance [safe] Eq Bar -- Defined in ‘InfoUtil’
-- instance [safe] Ord Bar -- Defined in ‘InfoUtil’
5 changes: 5 additions & 0 deletions plugins/hls-eval-plugin/test/testdata/TInfoMany.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module TInfoMany (Eq, Ord, Foo, Bar) where

import InfoUtil (Eq, Ord, Foo, Bar)

-- >>> :info Foo Bar
1 change: 0 additions & 1 deletion plugins/hls-eval-plugin/test/testdata/cabal.project

This file was deleted.

8 changes: 6 additions & 2 deletions plugins/hls-eval-plugin/test/testdata/test.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ library
TSetup
Util
TNested
TInfo
TInfoMany
TInfoBang
TInfoBangMany
TI_Info

build-depends: base >= 4.7 && < 5, QuickCheck
build-depends: base >= 4.7 && < 5, QuickCheck, info-util
default-language: Haskell2010
ghc-options: -Wall -fwarn-unused-imports

0 comments on commit f7a54e5

Please sign in to comment.