on master help sign in
Implement verify_debug_terminal as Cabal test.
commit8e1ea8e153a8bdde198e78a55f5691c6a1e35d09 authorCorey O'Connor <corey@ooyala.com> dateSun 7 Oct 2012, 18:26 (14 years ago) parent78d990f
7 files changed+216−140
src/Data/Terminfo/Eval.hs−1 src/Graphics/Vty/Terminal/TerminfoBased.hs+1−1 test/Verify.hs+23−31 test/VerifyAttributeOps.hs+9 test/verify_debug_terminal.hs → test/VerifyMockTerminal.hs+9−9 test/verify_attribute_ops.hs−8 vty.cabal+174−90
src/Data/Terminfo/Eval.hs−1
@@ -5,7 +5,6 @@
55{-# LANGUAGE FlexibleContexts #-}
66{-# LANGUAGE NoMonomorphismRestriction #-}
77{-# LANGUAGE NamedFieldPuns #-}
8−{-# LANGUAGE MonoPatBinds #-}
98{-# OPTIONS_GHC -funbox-strict-fields #-}
109{- Evaluates the paramaterized terminfo string capability with the given parameters.
1110 -
src/Graphics/Vty/Terminal/TerminfoBased.hs+1−1
@@ -23,7 +23,7 @@ import Data.Bits ( (.&.) )
2323import Data.Maybe ( isJust, isNothing, fromJust )
2424import Data.Word
2525
26−import Foreign.C.Types ( CLong )
26+import Foreign.C.Types ( CLong(..) )
2727
2828import GHC.IO.Handle
2929
test/Verify.hs+23−31
@@ -1,3 +1,4 @@
1+{-# LANGUAGE RecordWildCards #-}
12{-# LANGUAGE ScopedTypeVariables #-}
23{-# LANGUAGE CPP #-}
34{-# LANGUAGE TypeSynonymInstances #-}
@@ -10,16 +11,21 @@ module Verify ( module Verify
1011 , succeeded
1112 , failed
1213 , result
13− , Result(..)
1414 , monadicIO
1515 , liftIO
1616 , liftBool
17+ , Test(..)
18+ , Prop.Result(..)
1719 )
1820 where
1921
22+import Distribution.TestSuite hiding ( Result(..) )
23+import qualified Distribution.TestSuite as TS
24+
2025import Test.QuickCheck hiding ( Result(..) )
2126import 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
2329import Test.QuickCheck.Monadic ( monadicIO )
2430
2531import qualified Codec.Binary.UTF8.String as UTF8
@@ -34,31 +40,18 @@ import Numeric ( showHex )
3440import System.IO
3541import System.Random
3642
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
56−verify prop_name prop = do
57− liftIO $ putStrLn $ "verify " ++ prop_name
58− get >>= \s -> do
59− r <- liftIO $ quickCheckResult prop
60− liftIO $ modifyIORef (results_ref s) (\rs -> r : rs)
61− return r
43+verify :: Testable t => String -> t -> Test
44+verify test_name p = Test $ TestInstance
45+ { name = test_name
46+ , run = do
47+ qc_result <- quickCheckResult p
48+ case qc_result of
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+ }
6255
6356data SingleColumnChar = SingleColumnChar Char
6457 deriving (Show, Eq)
@@ -73,10 +66,9 @@ instance Show DoubleColumnChar where
7366 show (DoubleColumnChar c) = "(0x" ++ showHex (fromEnum c) "" ++ ") ->" ++ UTF8.encodeString [c]
7467
7568instance Arbitrary DoubleColumnChar where
76− arbitrary = elements $ map DoubleColumnChar $
77− [ toEnum 0x3040 .. toEnum 0x3098 ]
78− ++ [ toEnum 0x309B .. toEnum 0xA4CF]
79−
69+ arbitrary = elements $ map DoubleColumnChar $
70+ [ toEnum 0x3040 .. toEnum 0x3098 ]
71+ ++ [ toEnum 0x309B .. toEnum 0xA4CF ]
8072
8173liftIOResult :: Testable prop => IO prop -> Property
8274liftIOResult = 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 @@
11{-# LANGUAGE ScopedTypeVariables #-}
2−module Main where
2+module VerifyMockTerminal where
33
44import Verify.Graphics.Vty.DisplayRegion
55import Verify.Graphics.Vty.Picture
@@ -104,12 +104,12 @@ many_T_rows_cropped_height (DebugWindow w h) = liftIOResult $ do
104104 then return $ failed { reason = "\n" ++ show out_bytes ++ "\n\n" ++ show expected_bytes }
105105 else return succeeded
106106
107−main = run_test $ do
108− verify "unit_image_unit_bounds" unit_image_unit_bounds
109− verify "unit_image_arb_bounds" unit_image_arb_bounds
110− verify "single_T_row" single_T_row
111− verify "many_T_rows" many_T_rows
112− verify "many_T_rows_cropped_width" many_T_rows_cropped_width
113− verify "many_T_rows_cropped_height" many_T_rows_cropped_height
114− return ()
107+tests :: IO [Test]
108+tests = return [ verify "unit_image_unit_bounds" unit_image_unit_bounds
109+ , verify "unit_image_arb_bounds" unit_image_arb_bounds
110+ , verify "single_T_row" single_T_row
111+ , verify "many_T_rows" many_T_rows
112+ , verify "many_T_rows_cropped_width" many_T_rows_cropped_width
113+ , verify "many_T_rows_cropped_height" many_T_rows_cropped_height
114+ ]
115115
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
2−Version: 4.7.0.15
3−License: BSD3
4−License-file: LICENSE
5−Author: Stefan O'Rear, Corey O'Connor
6−Maintainer: Corey O'Connor (coreyoconnor@gmail.com)
7−Homepage: https://github.com/coreyoconnor/vty
8−Category: User Interfaces
9−Synopsis: A simple terminal access library
10−Description:
1+name: vty
2+version: 4.7.0.17
3+license: BSD3
4+license-file: LICENSE
5+author: AUTHORS
6+maintainer: Corey O'Connor (coreyoconnor@gmail.com)
7+homepage: https://github.com/coreyoconnor/vty
8+category: User Interfaces
9+synopsis: A simple terminal UI library
10+description:
1111 vty is terminal GUI library in the niche of ncurses. It is intended to be easy to use, have no
1212 confusing corner cases, and good support for common terminal types.
1313 .
@@ -26,83 +26,167 @@ Description:
2626 .
2727 &#169; 2006-2007 Stefan O'Rear; BSD3 license.
2828 .
29− &#169; 2008-2011 Corey O'Connor; BSD3 license.
30−
31−Build-Depends: base >= 4 && < 5, ghc-prim, bytestring, containers, unix
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
39−Data-Files: README, TODO
40−Exposed-Modules: Graphics.Vty
41− Graphics.Vty.Terminal
42− Graphics.Vty.LLInput
43− Graphics.Vty.Attributes
44− Graphics.Vty.Image
45− Graphics.Vty.Inline
46− Graphics.Vty.Picture
47− Graphics.Vty.DisplayRegion
48−
49−other-modules: Codec.Binary.UTF8.Width
50− Data.Marshalling
51− Data.Terminfo.Parse
52− Data.Terminfo.Eval
53− Graphics.Vty.DisplayAttributes
54− Graphics.Vty.Span
55− Graphics.Vty.Terminal.Generic
56− Graphics.Vty.Terminal.MacOSX
57− Graphics.Vty.Terminal.XTermColor
58− Graphics.Vty.Terminal.TerminfoBased
59−
60−C-Sources: cbits/gwinsz.c
61− cbits/set_term_timing.c
62− cbits/mk_wcwidth.c
63−
64−Include-Dirs: cbits
65−hs-source-dirs: src
66−Extra-Source-Files: test/Makefile
67− test/Bench.hs
68− test/Bench2.hs
69− test/BenchRenderChar.hs
70− test/ControlTable.hs
71− test/HereDoc.hs
72− test/Test.hs
73− test/Test2.hs
74− test/Verify.hs
75− test/Verify/Data/Terminfo/Parse.hs
76− test/Verify/Graphics/Vty/Attributes.hs
77− test/Verify/Graphics/Vty/DisplayRegion.hs
78− test/Verify/Graphics/Vty/Image.hs
79− test/Verify/Graphics/Vty/Picture.hs
80− test/Verify/Graphics/Vty/Span.hs
81− test/interactive_terminal_test.hs
82− test/verify_attribute_ops.hs
83− test/verify_debug_terminal.hs
84− test/verify_display_attributes.hs
85− test/verify_empty_image_props.hs
86− test/verify_eval_terminfo_caps.hs
87− test/verify_image_ops.hs
88− test/verify_image_trans.hs
89− test/verify_inline.hs
90− test/verify_parse_terminfo_caps.hs
91− test/verify_picture_ops.hs
92− test/verify_picture_to_span.hs
93− test/verify_span_ops.hs
94− test/verify_utf8_width.hs
95− test/vty_inline_example.hs
96− test/vty_issue_18.hs
97− test/yi_issue_264.hs
98− src/Codec/Binary/UTF8/Debug.hs
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
29+ &#169; 2008-2012 Corey O'Connor; BSD3 license.
30+-- the test suites require >= 1.17.0
31+cabal-version: >= 1.14.0
32+build-type: Simple
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+
55+ exposed-modules: Graphics.Vty
56+ Graphics.Vty.Terminal
57+ Graphics.Vty.LLInput
58+ Graphics.Vty.Attributes
59+ Graphics.Vty.Image
60+ Graphics.Vty.Inline
61+ Graphics.Vty.Picture
62+ Graphics.Vty.DisplayRegion
63+
64+ other-modules: Codec.Binary.UTF8.Width
65+ Data.Marshalling
66+ Data.Terminfo.Parse
67+ Data.Terminfo.Eval
68+ Graphics.Vty.DisplayAttributes
69+ Graphics.Vty.Span
70+ Graphics.Vty.Terminal.Generic
71+ Graphics.Vty.Terminal.MacOSX
72+ Graphics.Vty.Terminal.XTermColor
73+ Graphics.Vty.Terminal.TerminfoBased
74+
75+ c-sources: cbits/gwinsz.c
76+ cbits/set_term_timing.c
77+ cbits/mk_wcwidth.c
78+
79+ include-dirs: cbits
80+
81+ hs-source-dirs: src
82+
83+ ghc-options: -O2 -funbox-strict-fields -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
84+
85+ ghc-prof-options: -O2 -funbox-strict-fields -caf-all -Wall -fno-full-laziness -fspec-constr -fspec-constr-count=10
86+
87+ cc-options: -O2
88+
89+test-suite verify-attribute-ops
90+ default-language: Haskell2010
91+ type: detailed-0.9
92+ hs-source-dirs: src test
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+
119+ other-modules: Graphics.Vty
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
137+ Verify.Graphics.Vty.Span
138+
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+
161+-- verify_debug_terminal.hs
162+-- verify_display_attributes.hs
163+-- verify_empty_image_props.hs
164+-- verify_eval_terminfo_caps.hs
165+-- verify_image_ops.hs
166+-- verify_image_trans.hs
167+-- verify_inline.hs
168+-- verify_parse_terminfo_caps.hs
169+-- verify_picture_ops.hs
170+-- verify_picture_to_span.hs
171+-- verify_span_ops.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
189+-- vty_inline_example.hs
190+-- vty_issue_18.hs
191+-- yi_issue_264.hs
192+