tools: add easytest (github) as an extra dep, for experiments
This commit is contained in:
		
							parent
							
								
									93d2e1b7ac
								
							
						
					
					
						commit
						9a5d9c6235
					
				| @ -7,11 +7,14 @@ nix: | |||||||
|   pure: false |   pure: false | ||||||
|   packages: [perl gmp ncurses zlib] |   packages: [perl gmp ncurses zlib] | ||||||
| 
 | 
 | ||||||
| extra-deps: [] |  | ||||||
| 
 |  | ||||||
| packages: | packages: | ||||||
| - hledger-lib | - hledger-lib | ||||||
| - hledger | - hledger | ||||||
| - hledger-ui | - hledger-ui | ||||||
| - hledger-web | - hledger-web | ||||||
| - hledger-api | - hledger-api | ||||||
|  | 
 | ||||||
|  | extra-deps: | ||||||
|  | # for tools/easytest.hs. Should be harmless otherwise. | ||||||
|  | - git: git@github.com:joelburget/easytest.git | ||||||
|  |   commit: 5d5b851e77368071b5727cd366af9c6ecd288add | ||||||
|  | |||||||
							
								
								
									
										36
									
								
								tools/easytest.hs
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								tools/easytest.hs
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | #!/usr/bin/env stack | ||||||
|  | -- stack runghc --install-ghc --package easytest | ||||||
|  | -- (use project's resolver) | ||||||
|  | 
 | ||||||
|  | -- stack script --resolver lts-10.3 --package easytest | ||||||
|  | -- (use specific resolver, be more self-contained) | ||||||
|  | 
 | ||||||
|  | -- Examples of https://github.com/joelburget/easytest, an easier testing framework. | ||||||
|  | 
 | ||||||
|  | {-# LANGUAGE OverloadedStrings #-} | ||||||
|  | 
 | ||||||
|  | import EasyTest | ||||||
|  | import Control.Applicative | ||||||
|  | import Control.Monad | ||||||
|  | 
 | ||||||
|  | suite1 :: Test () | ||||||
|  | suite1 = tests | ||||||
|  |   [ scope "a" ok | ||||||
|  |   , scope "b.c" ok | ||||||
|  |   , scope "b" ok | ||||||
|  |   , scope "b" . scope "c" . scope "d" $ ok | ||||||
|  |   , scope "c" ok ] | ||||||
|  | 
 | ||||||
|  | reverseTest :: Test () | ||||||
|  | reverseTest = scope "list reversal" $ do | ||||||
|  |   nums <- listsOf [0..100] (int' 0 99) | ||||||
|  |   nums `forM_` \nums -> expect (reverse (reverse nums) == nums) | ||||||
|  | 
 | ||||||
|  | main :: IO () | ||||||
|  | main = do | ||||||
|  |   run suite1 | ||||||
|  |   runOnly "a" suite1 | ||||||
|  |   runOnly "b" suite1 | ||||||
|  |   runOnly "b" $ tests [suite1, scope "xyz" (crash "never run")] | ||||||
|  |   runOnly "b.c" $ tests [suite1, scope "b" (crash "never run")] | ||||||
|  |   run reverseTest | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user