@@ -10,36 +10,43 @@ import Test.Unit (suite, test, TestSuite)
10
10
import Test.Unit.Assert as Assert
11
11
import Test.Unit.Console as Console
12
12
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
13
+ testPrintParse ∷ ∀ e . E.Either String String → TestSuite (testOutput ∷ Console.TESTOUTPUT | e )
14
+ testPrintParse = case _ of
15
+ E.Left s → do
16
+ test s case parseQuery s of
17
+ E.Left err → pure unit
18
+ E.Right (sql ∷ SqlQuery ) → Assert .assert " Parse succeeded" false
19
+ E.Right s → do
20
+ test s case parseQuery s of
21
+ E.Left err → Assert .assert (show err) false
22
+ E.Right (sql ∷ SqlQuery ) → pure unit
18
23
19
- inputs ∷ Array String
24
+ inputs ∷ Array ( E.Either String String )
20
25
inputs =
21
- [ """ select a from `/f` where b is not between 1 and (2..3)"""
22
- , """ select foo, bar from (select foo, bar from (select foo, bar from `/baz`)as t) as d"""
23
- , """ select (1 + 2) * 3 + 2"""
24
- , """ select 1 + 2 * 3 ^ 1.2 / 14 + Minimum(12, 23)"""
25
- , """ select ("12" || "12" || "12")"""
26
- , """ select date("12-12-12") from `/fo` cross join `/bar`"""
27
- , """ Select foo as bar from `/test/db/collection`"""
28
- , """ Select `foo`, `bar`[*] from `/test` join `/test2` on baz where doo = (12 + 23)"""
29
- , """ foo := 12; select * from `/test` group by baz"""
30
- , """ select 1"""
31
- , """ select (1, 2)"""
32
- , """ foo := [1, 2]; select 1"""
33
- , """ foo := 1; bar := 2; select [] """
34
- , """ select foo from `/bar` order by zoo desc"""
35
- , """ select distinct a from `/f`"""
36
- , """ select a from /* trololo */ `/db`"""
37
- , """ -- comment
26
+ [ E.Right """ select a from `/f` where b is not between 1 and (2..3)"""
27
+ , E.Right """ select foo, bar from (select foo, bar from (select foo, bar from `/baz`)as t) as d"""
28
+ , E.Right """ select (1 + 2) * 3 + 2"""
29
+ , E.Right """ select 1 + 2 * 3 ^ 1.2 / 14 + Minimum(12, 23)"""
30
+ , E.Right """ select ("12" || "12" || "12")"""
31
+ , E.Right """ select date("12-12-12") from `/fo` cross join `/bar`"""
32
+ , E.Right """ Select foo as bar from `/test/db/collection`"""
33
+ , E.Right """ Select `foo`, `bar`[*] from `/test` join `/test2` on baz where doo = (12 + 23)"""
34
+ , E.Right """ foo := 12; select * from `/test` group by baz"""
35
+ , E.Right """ select 1"""
36
+ , E.Right """ select (1, 2)"""
37
+ , E.Right """ foo := [1, 2]; select 1"""
38
+ , E.Right """ foo := 1; bar := 2; select [] """
39
+ , E.Right """ select foo from `/bar` order by zoo desc"""
40
+ , E.Right """ select distinct a from `/f`"""
41
+ , E.Right """ select a from /* trololo */ `/db`"""
42
+ , E.Right """ -- comment
38
43
select 12
39
44
"""
40
- , """ import foo; select * from `/test`"""
41
- , """ create function foo(:bar) begin :bar + 2 end; select * from `/test` where foo = foo(42)"""
42
- , """ select :where"""
45
+ , E.Right """ import foo; select * from `/test`"""
46
+ , E.Right """ create function foo(:bar) begin :bar + 2 end; select * from `/test` where foo = foo(42)"""
47
+ , E.Right """ select :where"""
48
+ , E.Right """ foo.`_id`"""
49
+ , E.Left """ foo._id"""
43
50
]
44
51
45
52
testSuite ∷ ∀ e . TestSuite (testOutput ∷ Console.TESTOUTPUT | e )
0 commit comments