File: subst.inter

package info (click to toggle)
hsqldb1.8.0 1.8.0.10%2Bdfsg-10
  • links: PTS
  • area: main
  • in suites: buster
  • size: 13,432 kB
  • sloc: java: 75,802; xml: 11,392; sql: 1,556; sh: 847; makefile: 57
file content (77 lines) | stat: -rw-r--r-- 1,801 bytes parent folder | download | duplicates (10)
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
/*
 * $Id: subst.inter,v 1.1 2007/08/09 03:28:38 unsaved Exp $
 *
 * Tests interactive commands :s*.
 */

\c false
/* Since running interactively, need to either invoke with --abortOnErr switch,
 * or use "\c false" Special command, to detect failures. */

CREATE TABLE t(id INTEGER GENERATED BY DEFAULT AS IDENTITY, vc VARCHAR);

INSERT INTO t(vc) VALUES('one')

/* In interactive mode, the blank line above will move the command to the
 * edit buffer without executing it. */

:s/n/MM/;
/*Since this executes, command #3 in history will become "INSERT... 'oMMe'".*/

SELECT count(*) FROM t;
*if (*? != 1)
    \q Blank lines not behaving right in Interactive mode
*end if

SELECT count(*) FROM t WHERE vc = 'oMMe';
*if (*? != 1)
    \q Simple substitution of edit buffer failed.
*end if

/* Tailing white space in line below, on purpose. */
:3   s@M@.@g;  

SELECT count(*) FROM t;
*if (*? != 2)
    \q Recall + subst. + exec failed / 1
*end if

SELECT count(*) FROM t WHERE vc = 'o..e';
*if (*? != 1)
    \q Recall + subst. + exec failed / 2
*end if

:3
/* Purposeful trailing white space in following line */
:s:MM:x:g   
:;

SELECT count(*) FROM t;
*if (*? != 3)
    \q Recall + subst., then exec failed / 1
*end if

SELECT count(*) FROM t WHERE vc = 'oxe';
*if (*? != 1)
    \q Recall + subst., then exec failed / 2
*end if

:/INSERT.*MM/
:s/Me/End/;
\q
:/INSERT.*MM/s/(?-i)o/Begin/;

SELECT count(*) FROM t;
*if (*? != 5)
    \q Regex Recall + subst., then exec failed / 1
*end if

SELECT count(*) FROM t WHERE vc = 'oMEnd';
*if (*? != 1)
    \q Regex Recall + subst., then exec failed / 2
*end if

SELECT count(*) FROM t WHERE vc = 'Begin..e';
*if (*? != 1)
    \q Regex Recall + subst., then exec failed / 3
*end if