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
|