@@ -2,27 +2,19 @@ module Test.Parse where
2
2
3
3
import Prelude
4
4
5
- import Control.Monad.Eff (Eff )
6
-
7
5
import Data.Either as E
8
6
import Data.Foldable as F
9
- import SqlSquared (printQuery , parseQuery )
7
+ import SqlSquared (parseQuery , SqlQuery )
10
8
9
+ import Test.Unit (suite , test , TestSuite )
10
+ import Test.Unit.Assert as Assert
11
11
import Test.Unit.Console as Console
12
12
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
26
18
27
19
inputs ∷ Array String
28
20
inputs =
@@ -34,11 +26,11 @@ inputs =
34
26
, """ select date("12-12-12") from `/fo` cross join `/bar`"""
35
27
, """ Select foo as bar from `/test/db/collection`"""
36
28
, """ 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"""
38
30
, """ select 1"""
39
31
, """ 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 [] """
42
34
, """ select foo from `/bar` order by zoo desc"""
43
35
, """ select distinct a from `/f`"""
44
36
, """ select a from /* trololo */ `/db`"""
@@ -49,8 +41,7 @@ select 12
49
41
, """ create function foo(:bar) begin :bar + 2 end; select * from `/test` where foo = foo(42)"""
50
42
]
51
43
52
-
53
- testSuite ∷ ∀ e . Eff (testOutput ∷ Console.TESTOUTPUT |e ) Unit
44
+ testSuite ∷ ∀ e . TestSuite (testOutput ∷ Console.TESTOUTPUT | e )
54
45
testSuite = 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