4848 (\ weight ->
4949 if weightGCs weight > 0
5050 then Just " Non-zero number of garbage collections!"
51- else if weightAllocatedBytes weight > 3000
51+ else if weightAllocatedBytes weight > 4000
5252 then Just
53- " Allocated >3KB ! Allocations should be constant."
53+ " Allocated >4KB ! Allocations should be constant."
5454 else Nothing )
5555 | i <- [1 , 10 , 100 , 1000 ]
5656 ]
@@ -62,12 +62,27 @@ main =
6262 (\ weight ->
6363 if weightGCs weight > 0
6464 then Just " Non-zero number of garbage collections!"
65- else if weightAllocatedBytes weight > 3000
65+ else if weightAllocatedBytes weight > 4000
6666 then Just
67- " Allocated >3KB ! Allocations should be constant."
67+ " Allocated >KB ! Allocations should be constant."
6868 else Nothing )
6969 | i <- [1 , 10 , 100 , 1000 , 2000 ]
70- ])
70+ ]
71+ sequence_
72+ [ validateAction
73+ (" pollEvent + drawRect " ++ show i)
74+ pollEventDrawRectTest
75+ i
76+ (\ weight ->
77+ if weightGCs weight > 0
78+ then Just " Non-zero number of garbage collections!"
79+ else if weightAllocatedBytes weight > 4000
80+ then Just
81+ " Allocated >4KB! Allocations should be constant."
82+ else Nothing )
83+ | i <- [1 , 10 , 100 , 1000 ]
84+ ]
85+ )
7186
7287-- | Test that merely polling does not allocate or engage the GC.
7388-- <https://github.com/haskell-game/sdl2/issues/178>
@@ -101,7 +116,7 @@ pollEventClearTest iters = do
101116pollEventPresentTest :: Int -> IO ()
102117pollEventPresentTest iters = do
103118 initializeAll
104- window <- createWindow " pollEventClearTest " defaultWindow
119+ window <- createWindow " pollEventPresentTest " defaultWindow
105120 renderer <- createRenderer window (- 1 ) defaultRenderer
106121 let go :: Int -> IO ()
107122 go 0 = pure ()
@@ -117,7 +132,7 @@ pollEventPresentTest iters = do
117132pollEventDrawColorTest :: Int -> IO ()
118133pollEventDrawColorTest iters = do
119134 initializeAll
120- window <- createWindow " pollEventClearTest " defaultWindow
135+ window <- createWindow " pollEventDrawColorTest " defaultWindow
121136 renderer <- createRenderer window (- 1 ) defaultRenderer
122137 let go :: Int -> IO ()
123138 go 0 = pure ()
@@ -128,3 +143,21 @@ pollEventDrawColorTest iters = do
128143 present renderer
129144 go (i - 1 )
130145 go iters
146+
147+ -- | Draw a rectangle on screen.
148+ pollEventDrawRectTest :: Int -> IO ()
149+ pollEventDrawRectTest iters = do
150+ initializeAll
151+ window <- createWindow " pollEventDrawRectTest" defaultWindow
152+ renderer <- createRenderer window (- 1 ) defaultRenderer
153+ let go :: Int -> IO ()
154+ go 0 = pure ()
155+ go i = do
156+ _ <- pollEvent
157+ rendererDrawColor renderer $= V4 40 40 40 255
158+ clear renderer
159+ rendererDrawColor renderer $= V4 255 255 255 255
160+ fillRect renderer (Just (Rectangle (P (V2 40 40 )) (V2 80 80 )))
161+ present renderer
162+ go (i - 1 )
163+ go iters
0 commit comments