@@ -2,27 +2,19 @@ module Test.Parse where
22
33import Prelude
44
5- import Control.Monad.Eff (Eff )
6-
75import Data.Either as E
86import Data.Foldable as F
9- import SqlSquared (printQuery , parseQuery )
7+ import SqlSquared (parseQuery , SqlQuery )
108
9+ import Test.Unit (suite , test , TestSuite )
10+ import Test.Unit.Assert as Assert
1111import Test.Unit.Console as Console
1212
13- import Debug.Trace as DT
14-
15- testPrintParse ∷ ∀ e . String → Eff (testOutput ∷ Console.TESTOUTPUT |e ) Unit
16- testPrintParse s = do
17- Console .printLabel $ " Testing: \n " <> s <> " \n "
18- let parsed = parseQuery s
19- case parsed of
20- E.Left e → Console .printFail $ " Fail: " <> show e <> " \n "
21- E.Right sql → do
22- Console .printPass " Success: \n "
23- DT .traceAnyA sql
24- Console .printPass $ printQuery sql
25- Console .printPass " \n "
13+ testPrintParse ∷ ∀ e . String → TestSuite (testOutput ∷ Console.TESTOUTPUT | e )
14+ testPrintParse s =
15+ test s case parseQuery s of
16+ E.Left err → Assert .assert (show err) false
17+ E.Right (sql ∷ SqlQuery ) → pure unit
2618
2719inputs ∷ Array String
2820inputs =
@@ -34,11 +26,11 @@ inputs =
3426 , """ select date("12-12-12") from `/fo` cross join `/bar`"""
3527 , """ Select foo as bar from `/test/db/collection`"""
3628 , """ Select `foo`, `bar`[*] from `/test` join `/test2` on baz where doo = (12 + 23)"""
37- , """ : foo := 12; select * from `/test` group by baz"""
29+ , """ foo := 12; select * from `/test` group by baz"""
3830 , """ select 1"""
3931 , """ select (1, 2)"""
40- , """ : foo := [1, 2]; select 1"""
41- , """ : foo := 1; : bar := 2; select [] """
32+ , """ foo := [1, 2]; select 1"""
33+ , """ foo := 1; bar := 2; select [] """
4234 , """ select foo from `/bar` order by zoo desc"""
4335 , """ select distinct a from `/f`"""
4436 , """ select a from /* trololo */ `/db`"""
@@ -49,8 +41,7 @@ select 12
4941 , """ create function foo(:bar) begin :bar + 2 end; select * from `/test` where foo = foo(42)"""
5042 ]
5143
52-
53- testSuite ∷ ∀ e . Eff (testOutput ∷ Console.TESTOUTPUT |e ) Unit
44+ testSuite ∷ ∀ e . TestSuite (testOutput ∷ Console.TESTOUTPUT | e )
5445testSuite = do
55- Console .printLabel " \n\n :::::::::: TESTING PARSER :::::::::: \n\n "
56- F .for_ inputs testPrintParse
46+ suite " parsers " do
47+ F .traverse_ testPrintParse inputs
0 commit comments