on master help sign in
Implement verify_debug_terminal as Cabal test.
8e1ea8eCorey O'Connor
src/Data/Terminfo/Eval.hs−1
@@ -5,7 +5,6 @@
5{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE NoMonomorphismRestriction #-}
6{-# LANGUAGE NoMonomorphismRestriction #-}
7{-# LANGUAGE NamedFieldPuns #-}
7{-# LANGUAGE NamedFieldPuns #-}
8−{-# LANGUAGE MonoPatBinds #-}
9{-# OPTIONS_GHC -funbox-strict-fields #-}
8{-# OPTIONS_GHC -funbox-strict-fields #-}
10{- Evaluates the paramaterized terminfo string capability with the given parameters.
9{- Evaluates the paramaterized terminfo string capability with the given parameters.
11 -
10 -
src/Graphics/Vty/Terminal/TerminfoBased.hs+1−1
@@ -23,7 +23,7 @@ import Data.Bits ( (.&.) )
23import Data.Maybe ( isJust, isNothing, fromJust )
23import Data.Maybe ( isJust, isNothing, fromJust )
24import Data.Word
24import Data.Word
25
25
26−import Foreign.C.Types ( CLong )
26+import Foreign.C.Types ( CLong(..) )
27
27
28import GHC.IO.Handle
28import GHC.IO.Handle
29
29
test/Verify.hs+23−31
@@ -1,3 +1,4 @@
1+{-# LANGUAGE RecordWildCards #-}
1{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
3{-# LANGUAGE TypeSynonymInstances #-}
4{-# LANGUAGE TypeSynonymInstances #-}
@@ -10,16 +11,21 @@ module Verify ( module Verify
10 , succeeded
11 , succeeded
11 , failed
12 , failed
12 , result
13 , result
13− , Result(..)
14 , monadicIO
14 , monadicIO
15 , liftIO
15 , liftIO
16 , liftBool
16 , liftBool
17+ , Test(..)
18+ , Prop.Result(..)
17 )
19 )
18 where
20 where
19
21
22+import Distribution.TestSuite hiding ( Result(..) )
23+import qualified Distribution.TestSuite as TS
24+
20import Test.QuickCheck hiding ( Result(..) )
25import Test.QuickCheck hiding ( Result(..) )
21import qualified Test.QuickCheck as QC
26import qualified Test.QuickCheck as QC
22−import Test.QuickCheck.Property
27+import Test.QuickCheck.Property hiding ( Result(..) )
28+import qualified Test.QuickCheck.Property as Prop
23import Test.QuickCheck.Monadic ( monadicIO )
29import Test.QuickCheck.Monadic ( monadicIO )
24
30
25import qualified Codec.Binary.UTF8.String as UTF8
31import qualified Codec.Binary.UTF8.String as UTF8
@@ -34,31 +40,18 @@ import Numeric ( showHex )
34import System.IO
40import System.IO
35import System.Random
41import System.Random
36
42
37−type Test = StateT TestState IO
38−
39−data TestState = TestState
40− { results_ref :: IORef [QC.Result]
41− }
42−
43−run_test :: Test () -> IO ()
44−run_test t = do
45− s <- newIORef [] >>= return . TestState
46− s' <- runStateT t s >>= return . snd
47− results <- readIORef $ results_ref s'
48− let fail_results = [ fail_result | fail_result@(QC.Failure {}) <- results ]
49− case fail_results of
50− [] -> putStrLn "state: PASS"
51− rs -> do
52− putStrLn "state: FAIL"
53− putStrLn $ "fail_count: " ++ show (length rs)
54−
55−verify :: Testable prop => String -> prop -> Test QC.Result
43+verify :: Testable t => String -> t -> Test
56−verify prop_name prop = do
44+verify test_name p = Test $ TestInstance
57− liftIO $ putStrLn $ "verify " ++ prop_name
45+ { name = test_name
58− get >>= \s -> do
46+ , run = do
59− r <- liftIO $ quickCheckResult prop
47+ qc_result <- quickCheckResult p
60− liftIO $ modifyIORef (results_ref s) (\rs -> r : rs)
48+ case qc_result of
61− return r
49+ QC.Success {..} -> return $ Finished TS.Pass
50+ _ -> return $ Finished $ TS.Fail "TODO(corey): add failure message"
51+ , tags = []
52+ , options = []
53+ , setOption = \_ _ -> Left "no options supported"
54+ }
62
55
63data SingleColumnChar = SingleColumnChar Char
56data SingleColumnChar = SingleColumnChar Char
64 deriving (Show, Eq)
57 deriving (Show, Eq)
@@ -73,10 +66,9 @@ instance Show DoubleColumnChar where
73 show (DoubleColumnChar c) = "(0x" ++ showHex (fromEnum c) "" ++ ") ->" ++ UTF8.encodeString [c]
66 show (DoubleColumnChar c) = "(0x" ++ showHex (fromEnum c) "" ++ ") ->" ++ UTF8.encodeString [c]
74
67
75instance Arbitrary DoubleColumnChar where
68instance Arbitrary DoubleColumnChar where
76− arbitrary = elements $ map DoubleColumnChar $
69+ arbitrary = elements $ map DoubleColumnChar $
77− [ toEnum 0x3040 .. toEnum 0x3098 ]
70+ [ toEnum 0x3040 .. toEnum 0x3098 ]
78− ++ [ toEnum 0x309B .. toEnum 0xA4CF]
71+ ++ [ toEnum 0x309B .. toEnum 0xA4CF ]
79−
80
72
81liftIOResult :: Testable prop => IO prop -> Property
73liftIOResult :: Testable prop => IO prop -> Property
82liftIOResult = morallyDubiousIOProperty
74liftIOResult = morallyDubiousIOProperty
test/VerifyAttributeOps.hsnew file+9
@@ -0,0 +1,9 @@
1+module VerifyAttributeOps where
2+
3+import Verify.Graphics.Vty.Attributes
4+
5+import Verify
6+
7+tests :: IO [Test]
8+tests = return []
9+
test/verify_debug_terminal.hs → test/VerifyMockTerminal.hsrenamed+9−9
@@ -1,5 +1,5 @@
1{-# LANGUAGE ScopedTypeVariables #-}
1{-# LANGUAGE ScopedTypeVariables #-}
2−module Main where
2+module VerifyMockTerminal where
3
3
4import Verify.Graphics.Vty.DisplayRegion
4import Verify.Graphics.Vty.DisplayRegion
5import Verify.Graphics.Vty.Picture
5import Verify.Graphics.Vty.Picture
@@ -104,12 +104,12 @@ many_T_rows_cropped_height (DebugWindow w h) = liftIOResult $ do
104 then return $ failed { reason = "\n" ++ show out_bytes ++ "\n\n" ++ show expected_bytes }
104 then return $ failed { reason = "\n" ++ show out_bytes ++ "\n\n" ++ show expected_bytes }
105 else return succeeded
105 else return succeeded
106
106
107−main = run_test $ do
107+tests :: IO [Test]
108− verify "unit_image_unit_bounds" unit_image_unit_bounds
108+tests = return [ verify "unit_image_unit_bounds" unit_image_unit_bounds
109− verify "unit_image_arb_bounds" unit_image_arb_bounds
109+ , verify "unit_image_arb_bounds" unit_image_arb_bounds
110− verify "single_T_row" single_T_row
110+ , verify "single_T_row" single_T_row
111− verify "many_T_rows" many_T_rows
111+ , verify "many_T_rows" many_T_rows
112− verify "many_T_rows_cropped_width" many_T_rows_cropped_width
112+ , verify "many_T_rows_cropped_width" many_T_rows_cropped_width
113− verify "many_T_rows_cropped_height" many_T_rows_cropped_height
113+ , verify "many_T_rows_cropped_height" many_T_rows_cropped_height
114− return ()
114+ ]
115
115
test/verify_attribute_ops.hsdeleted−8
@@ -1,8 +0,0 @@
1−module Main where
2−
3−import Verify.Graphics.Vty.Attributes
4−
5−import Verify
6−
7−main = run_test $ do
8− return ()
vty.cabal+174−90
@@ -1,13 +1,13 @@
1−Name: vty
1+name: vty
2−Version: 4.7.0.15
2+version: 4.7.0.17
3−License: BSD3
3+license: BSD3
4−License-file: LICENSE
4+license-file: LICENSE
5−Author: Stefan O'Rear, Corey O'Connor
5+author: AUTHORS
6−Maintainer: Corey O'Connor (coreyoconnor@gmail.com)
6+maintainer: Corey O'Connor (coreyoconnor@gmail.com)
7−Homepage: https://github.com/coreyoconnor/vty
7+homepage: https://github.com/coreyoconnor/vty
8−Category: User Interfaces
8+category: User Interfaces
9−Synopsis: A simple terminal access library
9+synopsis: A simple terminal UI library
10−Description:
10+description:
11 vty is terminal GUI library in the niche of ncurses. It is intended to be easy to use, have no
11 vty is terminal GUI library in the niche of ncurses. It is intended to be easy to use, have no
12 confusing corner cases, and good support for common terminal types.
12 confusing corner cases, and good support for common terminal types.
13 .
13 .
@@ -26,83 +26,167 @@ Description:
26 .
26 .
27 &#169; 2006-2007 Stefan O'Rear; BSD3 license.
27 &#169; 2006-2007 Stefan O'Rear; BSD3 license.
28 .
28 .
29− &#169; 2008-2011 Corey O'Connor; BSD3 license.
29+ &#169; 2008-2012 Corey O'Connor; BSD3 license.
30−
30+-- the test suites require >= 1.17.0
31−Build-Depends: base >= 4 && < 5, ghc-prim, bytestring, containers, unix
31+cabal-version: >= 1.14.0
32−Build-Depends: terminfo >= 0.3 && < 0.4
33−Build-Depends: utf8-string >= 0.3 && < 0.4
34−Build-Depends: mtl >= 1.1.1.0 && < 2.2
35−Build-Depends: parallel >= 2.2 && < 3.3, deepseq >= 1.1 && < 1.4
36−Build-Depends: vector >= 0.7
37−Build-Depends: parsec >= 2 && < 4
38−Build-Type: Simple
32+build-type: Simple
39−Data-Files: README, TODO
33+data-files: README,
34+ TODO,
35+ AUTHORS,
36+ CHANGELOG,
37+ LICENSE
38+
39+
40+library
41+ default-language: Haskell2010
42+ build-depends: base >= 4 && < 5,
43+ bytestring,
44+ containers,
45+ deepseq >= 1.1 && < 1.4,
46+ ghc-prim,
47+ mtl >= 1.1.1.0 && < 2.2,
48+ parallel >= 2.2 && < 3.3,
49+ parsec >= 2 && < 4,
50+ terminfo >= 0.3 && < 0.4,
51+ unix,
52+ utf8-string >= 0.3 && < 0.4,
53+ vector >= 0.7
54+
40−Exposed-Modules: Graphics.Vty
55+ exposed-modules: Graphics.Vty
41− Graphics.Vty.Terminal
56+ Graphics.Vty.Terminal
42− Graphics.Vty.LLInput
57+ Graphics.Vty.LLInput
43− Graphics.Vty.Attributes
58+ Graphics.Vty.Attributes
44− Graphics.Vty.Image
59+ Graphics.Vty.Image
45− Graphics.Vty.Inline
60+ Graphics.Vty.Inline
46− Graphics.Vty.Picture
61+ Graphics.Vty.Picture
47− Graphics.Vty.DisplayRegion
62+ Graphics.Vty.DisplayRegion
48−
63+
49−other-modules: Codec.Binary.UTF8.Width
64+ other-modules: Codec.Binary.UTF8.Width
50− Data.Marshalling
65+ Data.Marshalling
51− Data.Terminfo.Parse
66+ Data.Terminfo.Parse
52− Data.Terminfo.Eval
67+ Data.Terminfo.Eval
53− Graphics.Vty.DisplayAttributes
68+ Graphics.Vty.DisplayAttributes
54− Graphics.Vty.Span
69+ Graphics.Vty.Span
55− Graphics.Vty.Terminal.Generic
70+ Graphics.Vty.Terminal.Generic
56− Graphics.Vty.Terminal.MacOSX
71+ Graphics.Vty.Terminal.MacOSX
57− Graphics.Vty.Terminal.XTermColor
72+ Graphics.Vty.Terminal.XTermColor
58− Graphics.Vty.Terminal.TerminfoBased
73+ Graphics.Vty.Terminal.TerminfoBased
59−
74+
60−C-Sources: cbits/gwinsz.c
75+ c-sources: cbits/gwinsz.c
61− cbits/set_term_timing.c
76+ cbits/set_term_timing.c
62− cbits/mk_wcwidth.c
77+ cbits/mk_wcwidth.c
63−
78+
64−Include-Dirs: cbits
79+ include-dirs: cbits
80+
65−hs-source-dirs: src
81+ hs-source-dirs: src
66−Extra-Source-Files: test/Makefile
82+
67− test/Bench.hs
83+ ghc-options: -O2 -funbox-strict-fields -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
68− test/Bench2.hs
84+
69− test/BenchRenderChar.hs
85+ ghc-prof-options: -O2 -funbox-strict-fields -caf-all -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
70− test/ControlTable.hs
86+
71− test/HereDoc.hs
87+ cc-options: -O2
72− test/Test.hs
88+
73− test/Test2.hs
89+test-suite verify-attribute-ops
74− test/Verify.hs
90+ default-language: Haskell2010
75− test/Verify/Data/Terminfo/Parse.hs
91+ type: detailed-0.9
76− test/Verify/Graphics/Vty/Attributes.hs
92+ hs-source-dirs: src test
77− test/Verify/Graphics/Vty/DisplayRegion.hs
93+ test-module: VerifyAttributeOps
94+ build-depends: Cabal == 1.17.*,
95+ QuickCheck == 2.4.*,
96+ random == 1.0.*,
97+ base >= 4 && < 5,
98+ bytestring,
99+ containers,
100+ deepseq >= 1.1 && < 1.4,
101+ ghc-prim,
102+ mtl >= 1.1.1.0 && < 2.2,
103+ parallel >= 2.2 && < 3.3,
104+ parsec >= 2 && < 4,
105+ terminfo >= 0.3 && < 0.4,
106+ unix,
107+ utf8-string >= 0.3 && < 0.4,
108+ vector >= 0.7
109+
110+test-suite verify-using-mock-terminal
111+ default-language: Haskell2010
112+
113+ type: detailed-0.9
114+
115+ hs-source-dirs: src test
116+
117+ test-module: VerifyMockTerminal
118+
78− test/Verify/Graphics/Vty/Image.hs
119+ other-modules: Graphics.Vty
79− test/Verify/Graphics/Vty/Picture.hs
120+ Graphics.Vty.Attributes
121+ Graphics.Vty.DisplayAttributes
122+ Graphics.Vty.DisplayRegion
123+ Graphics.Vty.Image
124+ Graphics.Vty.Picture
125+ Graphics.Vty.Span
126+ Graphics.Vty.Terminal
127+ Graphics.Vty.Terminal.Generic
128+ Graphics.Vty.Terminal.Debug
129+ Graphics.Vty.Debug
130+ Graphics.Vty.Debug.Image
131+ Codec.Binary.UTF8.Width
132+ Verify
133+ Verify.Graphics.Vty.Attributes
134+ Verify.Graphics.Vty.DisplayRegion
135+ Verify.Graphics.Vty.Picture
136+ Verify.Graphics.Vty.Image
80− test/Verify/Graphics/Vty/Span.hs
137+ Verify.Graphics.Vty.Span
81− test/interactive_terminal_test.hs
138+
82− test/verify_attribute_ops.hs
139+ c-sources: cbits/gwinsz.c
140+ cbits/set_term_timing.c
141+ cbits/mk_wcwidth.c
142+
143+ include-dirs: cbits
144+
145+ build-depends: Cabal == 1.17.*,
146+ QuickCheck == 2.4.*,
147+ random == 1.0.*,
148+ base >= 4 && < 5,
149+ bytestring,
150+ containers,
151+ deepseq >= 1.1 && < 1.4,
152+ ghc-prim,
153+ mtl >= 1.1.1.0 && < 2.2,
154+ parallel >= 2.2 && < 3.3,
155+ parsec >= 2 && < 4,
156+ terminfo >= 0.3 && < 0.4,
157+ unix,
158+ utf8-string >= 0.3 && < 0.4,
159+ vector >= 0.7
160+
83− test/verify_debug_terminal.hs
161+-- verify_debug_terminal.hs
84− test/verify_display_attributes.hs
162+-- verify_display_attributes.hs
85− test/verify_empty_image_props.hs
163+-- verify_empty_image_props.hs
86− test/verify_eval_terminfo_caps.hs
164+-- verify_eval_terminfo_caps.hs
87− test/verify_image_ops.hs
165+-- verify_image_ops.hs
88− test/verify_image_trans.hs
166+-- verify_image_trans.hs
89− test/verify_inline.hs
167+-- verify_inline.hs
90− test/verify_parse_terminfo_caps.hs
168+-- verify_parse_terminfo_caps.hs
91− test/verify_picture_ops.hs
169+-- verify_picture_ops.hs
92− test/verify_picture_to_span.hs
170+-- verify_picture_to_span.hs
93− test/verify_span_ops.hs
171+-- verify_span_ops.hs
94− test/verify_utf8_width.hs
172+-- verify_utf8_width.hs
173+-- test suites
174+-- Bench.hs
175+-- Bench2.hs
176+-- BenchRenderChar.hs
177+-- ControlTable.hs
178+-- HereDoc.hs
179+-- Test.hs
180+-- Test2.hs
181+-- Verify.hs
182+-- Verify/Data/Terminfo/Parse.hs
183+-- Verify/Graphics/Vty/Attributes.hs
184+-- Verify/Graphics/Vty/DisplayRegion.hs
185+-- Verify/Graphics/Vty/Image.hs
186+-- Verify/Graphics/Vty/Picture.hs
187+-- Verify/Graphics/Vty/Span.hs
188+-- interactive_terminal_test.hs
95− test/vty_inline_example.hs
189+-- vty_inline_example.hs
96− test/vty_issue_18.hs
190+-- vty_issue_18.hs
97− test/yi_issue_264.hs
191+-- yi_issue_264.hs
98− src/Codec/Binary/UTF8/Debug.hs
192+
99− src/Graphics/Vty/Terminal/Debug.hs
100− src/Graphics/Vty/Debug.hs
101− cbits/gwinsz.c
102− cbits/mk_wcwidth.c
103− cbits/set_term_timing.c
104− cbits/gwinsz.h
105−
106−ghc-options: -O2 -funbox-strict-fields -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
107−ghc-prof-options: -O2 -funbox-strict-fields -caf-all -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
108−cc-options: -O2