File: tokenize.test

package info (click to toggle)
tdbc 1.1.1-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 928 kB
  • sloc: sh: 2,256; tcl: 1,146; ansic: 886; makefile: 61
file content (69 lines) | stat: -rw-r--r-- 1,783 bytes parent folder | download | duplicates (2)
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
# tokenize.test --
#
#	Tests for the tokenizer in TDBC

package require tcltest 2
namespace import -force ::tcltest::*
tcltest::loadTestedCommands
package require tdbc

test tokenize-1.0 {wrong args} \
    -body {
	::tdbc::tokenize
    } \
    -returnCodes error \
    -result {wrong # args: should be "::tdbc::tokenize statement"}

test tokenize-1.1 {wrong args} \
    -body {
	::tdbc::tokenize foo bar
    } \
    -returnCodes error \
    -result {wrong # args: should be "::tdbc::tokenize statement"}

test tokenize-2.0 {colon substitution, unquoted and quoted} {
    ::tdbc::tokenize {SELECT :a, ':b' FROM y}
} [list {SELECT } {:a} {, ':b' FROM y}]

test tokenize-2.1 {PostgreSQL cast syntax, not a colon substitution} {
    ::tdbc::tokenize {SELECT :foo::VARCHAR}
} [list {SELECT } :foo {::VARCHAR}]

test tokenize-3.0 {complex set of statements} {
    ::tdbc::tokenize {-- begin with a comment :hi;
	SELECT :a, ':b', ":c", [:d], /* :e, */ :f FROM y;
	INSERT INTO y VALUES(1,2,oracle$name,:g);}
} [list \
       "-- begin with a comment :hi;\n\tSELECT " \
       :a \
       {, ':b', ":c", [:d], /* :e, */ } \
       :f \
       { FROM y} \
       \; \
       "\n\tINSERT INTO y VALUES(1,2,oracle\$name," \
       :g \
       ")" \
       ";"]

test tokenize-4.0 {unterminated comment} {
    ::tdbc::tokenize {-- unterminated comment}
} {{-- unterminated comment}}

test tokenize-4.1 {unterminated quote} {
    ::tdbc::tokenize {' unterminated quote}
} {{' unterminated quote}}

test tokenize-4.2 {unterminated quote} {
    ::tdbc::tokenize "\" unterminated quote"
} [list "\" unterminated quote"]

test tokenize-4.3 {unterminated quote} {
    ::tdbc::tokenize "\[ unterminated quote"
} [list "\[ unterminated quote"]

cleanupTests
return

# Local Variables:
# mode: tcl
# End: