File: tokenize.test.lua

package info (click to toggle)
tarantool 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 85,364 kB
  • sloc: ansic: 513,760; cpp: 69,489; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,173; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (187 lines) | stat: -rwxr-xr-x 4,163 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/env tarantool
test = require("sqltester")
test:plan(16)

--!./tcltestrunner.lua
-- 2008 July 7
--
-- The author disclaims copyright to this source code.  In place of
-- a legal notice, here is a blessing:
--
--    May you do good and not evil.
--    May you find forgiveness for yourself and forgive others.
--    May you share freely, never taking more than you give.
--
-------------------------------------------------------------------------
-- This file implements regression tests for sql library.  The
-- focus of this script testing the tokenizer
--
-- $Id: tokenize.test,v 1.1 2008/07/08 00:06:51 drh Exp $
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]
test:do_catchsql_test(
    "tokenize-1.1",
    [[
        SELECT 1.0e+
    ]], {
        -- <tokenize-1.1>
        1, [[At line 1 at or near position 16: unrecognized token '1.0e']]
        -- </tokenize-1.1>
    })

test:do_catchsql_test(
    "tokenize-1.2",
    [[
        SELECT 1.0E+
    ]], {
        -- <tokenize-1.2>
        1, [[At line 1 at or near position 16: unrecognized token '1.0E']]
        -- </tokenize-1.2>
    })

test:do_catchsql_test(
    "tokenize-1.3",
    [[
        SELECT 1.0e-
    ]], {
        -- <tokenize-1.3>
        1, [[At line 1 at or near position 16: unrecognized token '1.0e']]
        -- </tokenize-1.3>
    })

test:do_catchsql_test(
    "tokenize-1.4",
    [[
        SELECT 1.0E-
    ]], {
        -- <tokenize-1.4>
        1, [[At line 1 at or near position 16: unrecognized token '1.0E']]
        -- </tokenize-1.4>
    })

test:do_catchsql_test(
    "tokenize-1.5",
    [[
        SELECT 1.0e+/
    ]], {
        -- <tokenize-1.5>
        1, [[At line 1 at or near position 16: unrecognized token '1.0e']]
        -- </tokenize-1.5>
    })

test:do_catchsql_test(
    "tokenize-1.6",
    [[
        SELECT 1.0E+:
    ]], {
        -- <tokenize-1.6>
        1, [[At line 1 at or near position 16: unrecognized token '1.0E']]
        -- </tokenize-1.6>
    })

test:do_catchsql_test(
    "tokenize-1.7",
    [[
        SELECT 1.0e-:
    ]], {
        -- <tokenize-1.7>
        1, [[At line 1 at or near position 16: unrecognized token '1.0e']]
        -- </tokenize-1.7>
    })

test:do_catchsql_test(
    "tokenize-1.8",
    [[
        SELECT 1.0E-/
    ]], {
        -- <tokenize-1.8>
        1, [[At line 1 at or near position 16: unrecognized token '1.0E']]
        -- </tokenize-1.8>
    })

test:do_catchsql_test(
    "tokenize-1.9",
    [[
        SELECT 1.0F+5
    ]], {
        -- <tokenize-1.9>
        1, [[At line 1 at or near position 16: unrecognized token '1.0F']]
        -- </tokenize-1.9>
    })

test:do_catchsql_test(
    "tokenize-1.10",
    [[
        SELECT 1.0d-10
    ]], {
        -- <tokenize-1.10>
        1, [[At line 1 at or near position 16: unrecognized token '1.0d']]
        -- </tokenize-1.10>
    })

test:do_catchsql_test(
    "tokenize-1.11",
    [[
        SELECT 1.0e,5
    ]], {
        -- <tokenize-1.11>
        1, [[At line 1 at or near position 16: unrecognized token '1.0e']]
        -- </tokenize-1.11>
    })

test:do_catchsql_test(
    "tokenize-1.12",
    [[
        SELECT 1.0E.10
    ]], {
        -- <tokenize-1.12>
        1, [[At line 1 at or near position 16: unrecognized token '1.0E']]
        -- </tokenize-1.12>
    })

test:do_catchsql_test(
    "tokenize-2.1",
    [[
        SELECT 1, 2 /*]], {
        -- <tokenize-2.1>
        1, [[Syntax error at line 1 near '*']]
        -- </tokenize-2.1>
    })

test:do_catchsql_test(
    "tokenize-2.2",
    [[
        SELECT 1, 2 /* 
    ]], {
        -- <tokenize-2.2>
        0, {1, 2}
        -- </tokenize-2.2>
    })

--
--gh-2611 Check the correct parsing of single-line comments.
--
test:do_execsql_test(
    "tokenize-3.1",
    [[
        SELECT 1 + -- 1 + 1.
        1
    ]], {
        -- <tokenize-2.2>
        2
        -- </tokenize-2.2>
    })

test:do_catchsql_test(
    "tokenize-3.2",
    [[
        SELECT 1 + -- Syntax error.
        *
    ]], {
        -- <tokenize-2.2>
        1,"Syntax error at line 2 near '*'"
        -- </tokenize-2.2>
    })

test:finish_test()