/ Hex Artifact Content
Login

Artifact 68532b32ca29cf399bbb951f46a906c452ada668:


0000: 23 20 32 30 31 30 20 4a 75 6c 79 20 31 36 0a 23  # 2010 July 16.#
0010: 0a 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69  .# The author di
0020: 73 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68  sclaims copyrigh
0030: 74 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65  t to this source
0040: 20 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65   code.  In place
0050: 20 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f   of.# a legal no
0060: 74 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20  tice, here is a 
0070: 62 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20  blessing:.#.#   
0080: 20 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64   May you do good
0090: 20 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23   and not evil..#
00a0: 20 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64      May you find
00b0: 20 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72   forgiveness for
00c0: 20 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f   yourself and fo
00d0: 72 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20  rgive others..# 
00e0: 20 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65     May you share
00f0: 20 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74   freely, never t
0100: 61 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20  aking more than 
0110: 79 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a  you give..#.#***
0120: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 0a 23 0a 23 20 54 68 69 73 20 66 69  ****.#.# This fi
0170: 6c 65 20 69 6d 70 6c 65 6d 65 6e 74 73 20 74 65  le implements te
0180: 73 74 73 20 74 6f 20 76 65 72 69 66 79 20 74 68  sts to verify th
0190: 61 74 20 74 68 65 20 22 74 65 73 74 61 62 6c 65  at the "testable
01a0: 20 73 74 61 74 65 6d 65 6e 74 73 22 20 69 6e 20   statements" in 
01b0: 0a 23 20 74 68 65 20 6c 61 6e 67 5f 65 78 70 72  .# the lang_expr
01c0: 2e 68 74 6d 6c 20 64 6f 63 75 6d 65 6e 74 20 61  .html document a
01d0: 72 65 20 63 6f 72 72 65 63 74 2e 0a 23 0a 0a 73  re correct..#..s
01e0: 65 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c 65  et testdir [file
01f0: 20 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30 5d   dirname $argv0]
0200: 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72  .source $testdir
0210: 2f 74 65 73 74 65 72 2e 74 63 6c 0a 73 6f 75 72  /tester.tcl.sour
0220: 63 65 20 24 74 65 73 74 64 69 72 2f 6d 61 6c 6c  ce $testdir/mall
0230: 6f 63 5f 63 6f 6d 6d 6f 6e 2e 74 63 6c 0a 0a 23  oc_common.tcl..#
0240: 20 53 65 74 20 75 70 20 74 68 72 65 65 20 67 6c   Set up three gl
0250: 6f 62 61 6c 20 76 61 72 69 61 62 6c 65 73 3a 0a  obal variables:.
0260: 23 0a 23 20 20 20 3a 3a 6f 70 6e 61 6d 65 20 20  #.#   ::opname  
0270: 20 20 20 20 20 20 20 41 6e 20 61 72 72 61 79 20         An array 
0280: 6d 61 70 70 69 6e 67 20 66 72 6f 6d 20 53 51 4c  mapping from SQL
0290: 20 6f 70 65 72 61 74 6f 72 20 74 6f 20 61 6e 20   operator to an 
02a0: 65 61 73 79 20 74 6f 20 70 61 72 73 65 0a 23 20  easy to parse.# 
02b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
02c0: 20 20 20 6e 61 6d 65 2e 20 54 68 65 20 6e 61 6d     name. The nam
02d0: 65 73 20 61 72 65 20 75 73 65 64 20 61 73 20 70  es are used as p
02e0: 61 72 74 20 6f 66 20 74 65 73 74 20 63 61 73 65  art of test case
02f0: 20 6e 61 6d 65 73 2e 0a 23 0a 23 20 20 20 3a 3a   names..#.#   ::
0300: 6f 70 70 72 65 63 20 20 20 20 20 20 20 20 20 41  opprec         A
0310: 6e 20 61 72 72 61 79 20 6d 61 70 70 69 6e 67 20  n array mapping 
0320: 66 72 6f 6d 20 53 51 4c 20 6f 70 65 72 61 74 6f  from SQL operato
0330: 72 20 74 6f 20 61 20 6e 75 6d 65 72 69 63 0a 23  r to a numeric.#
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0350: 20 20 20 20 70 72 65 63 65 64 65 6e 63 65 20 76      precedence v
0360: 61 6c 75 65 2e 20 4f 70 65 72 61 74 6f 72 73 20  alue. Operators 
0370: 74 68 61 74 20 67 72 6f 75 70 20 6d 6f 72 65 20  that group more 
0380: 74 69 67 68 74 6c 79 0a 23 20 20 20 20 20 20 20  tightly.#       
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76               hav
03a0: 65 20 6c 6f 77 65 72 20 6e 75 6d 65 72 69 63 20  e lower numeric 
03b0: 70 72 65 63 65 64 65 6e 63 65 73 2e 0a 23 0a 23  precedences..#.#
03c0: 20 20 20 3a 3a 6f 70 6c 69 73 74 20 20 20 20 20     ::oplist     
03d0: 20 20 20 20 41 20 6c 69 73 74 20 6f 66 20 61 6c      A list of al
03e0: 6c 20 53 51 4c 20 6f 70 65 72 61 74 6f 72 73 20  l SQL operators 
03f0: 73 75 70 70 6f 72 74 65 64 20 62 79 20 53 51 4c  supported by SQL
0400: 69 74 65 2e 0a 23 0a 66 6f 72 65 61 63 68 20 7b  ite..#.foreach {
0410: 6f 70 20 6f 70 6e 7d 20 7b 0a 20 20 20 20 20 20  op opn} {.      
0420: 7c 7c 20 20 20 63 61 74 20 20 20 20 20 2a 20 20  ||   cat     *  
0430: 20 6d 75 6c 20 20 20 20 20 20 20 2f 20 20 64 69   mul       /  di
0440: 76 20 20 20 20 20 20 20 25 20 20 20 20 20 6d 6f  v       %     mo
0450: 64 20 20 20 20 20 20 20 2b 20 20 20 20 20 20 61  d       +      a
0460: 64 64 0a 20 20 20 20 20 20 2d 20 20 20 20 73 75  dd.      -    su
0470: 62 20 20 20 20 20 3c 3c 20 20 6c 73 68 69 66 74  b     <<  lshift
0480: 20 20 20 20 3e 3e 20 72 73 68 69 66 74 20 20 20      >> rshift   
0490: 20 26 20 20 20 20 20 62 69 74 61 6e 64 20 20 20   &     bitand   
04a0: 20 7c 20 20 20 20 20 20 62 69 74 6f 72 0a 20 20   |      bitor.  
04b0: 20 20 20 20 3c 20 20 20 20 6c 65 73 73 20 20 20      <    less   
04c0: 20 3c 3d 20 20 6c 65 73 73 65 71 20 20 20 20 3e   <=  lesseq    >
04d0: 20 20 6d 6f 72 65 20 20 20 20 20 20 3e 3d 20 20    more      >=  
04e0: 20 20 6d 6f 72 65 65 71 20 20 20 20 3d 20 20 20    moreeq    =   
04f0: 20 20 20 65 71 31 0a 20 20 20 20 20 20 3d 3d 20     eq1.      == 
0500: 20 20 65 71 32 20 20 20 20 20 3c 3e 20 20 6e 65    eq2     <>  ne
0510: 31 20 20 20 20 20 20 20 21 3d 20 6e 65 32 20 20  1       != ne2  
0520: 20 20 20 20 20 49 53 20 20 20 20 69 73 20 20 20       IS    is   
0530: 20 20 20 20 20 4c 49 4b 45 20 20 20 6c 69 6b 65       LIKE   like
0540: 0a 20 20 20 20 20 20 47 4c 4f 42 20 67 6c 6f 62  .      GLOB glob
0550: 20 20 20 20 41 4e 44 20 61 6e 64 20 20 20 20 20      AND and     
0560: 20 20 4f 52 20 6f 72 20 20 20 20 20 20 20 20 4d    OR or        M
0570: 41 54 43 48 20 6d 61 74 63 68 20 20 20 20 20 52  ATCH match     R
0580: 45 47 45 58 50 20 72 65 67 65 78 70 0a 20 20 20  EGEXP regexp.   
0590: 20 20 20 7b 49 53 20 4e 4f 54 7d 20 69 73 6e 74     {IS NOT} isnt
05a0: 0a 7d 20 7b 0a 20 20 73 65 74 20 3a 3a 6f 70 6e  .} {.  set ::opn
05b0: 61 6d 65 28 24 6f 70 29 20 24 6f 70 6e 0a 7d 0a  ame($op) $opn.}.
05c0: 73 65 74 20 6f 70 6c 69 73 74 20 5b 6c 69 73 74  set oplist [list
05d0: 5d 0a 66 6f 72 65 61 63 68 20 7b 70 72 65 63 20  ].foreach {prec 
05e0: 6f 70 6c 7d 20 7b 0a 20 20 31 20 20 20 7c 7c 0a  opl} {.  1   ||.
05f0: 20 20 32 20 20 20 7b 2a 20 2f 20 25 7d 0a 20 20    2   {* / %}.  
0600: 33 20 20 20 7b 2b 20 2d 7d 0a 20 20 34 20 20 20  3   {+ -}.  4   
0610: 7b 3c 3c 20 3e 3e 20 26 20 7c 7d 0a 20 20 35 20  {<< >> & |}.  5 
0620: 20 20 7b 3c 20 3c 3d 20 3e 20 3e 3d 7d 0a 20 20    {< <= > >=}.  
0630: 36 20 20 20 7b 3d 20 3d 3d 20 21 3d 20 3c 3e 20  6   {= == != <> 
0640: 49 53 20 7b 49 53 20 4e 4f 54 7d 20 4c 49 4b 45  IS {IS NOT} LIKE
0650: 20 47 4c 4f 42 20 4d 41 54 43 48 20 52 45 47 45   GLOB MATCH REGE
0660: 58 50 7d 0a 20 20 37 20 20 20 41 4e 44 0a 20 20  XP}.  7   AND.  
0670: 38 20 20 20 4f 52 0a 7d 20 7b 0a 20 20 66 6f 72  8   OR.} {.  for
0680: 65 61 63 68 20 6f 70 20 24 6f 70 6c 20 7b 20 0a  each op $opl { .
0690: 20 20 20 20 73 65 74 20 3a 3a 6f 70 70 72 65 63      set ::opprec
06a0: 28 24 6f 70 29 20 24 70 72 65 63 20 0a 20 20 20  ($op) $prec .   
06b0: 20 6c 61 70 70 65 6e 64 20 6f 70 6c 69 73 74 20   lappend oplist 
06c0: 24 6f 70 0a 20 20 7d 0a 7d 0a 0a 0a 23 20 48 6f  $op.  }.}...# Ho
06d0: 6f 6b 20 69 6e 20 64 65 66 69 6e 69 74 69 6f 6e  ok in definition
06e0: 73 20 6f 66 20 4d 41 54 43 48 20 61 6e 64 20 52  s of MATCH and R
06f0: 45 47 45 58 2e 20 54 68 65 20 66 6f 6c 6c 6f 77  EGEX. The follow
0700: 69 6e 67 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69  ing implementati
0710: 6f 6e 73 0a 23 20 63 61 75 73 65 20 4d 41 54 43  ons.# cause MATC
0720: 48 20 61 6e 64 20 52 45 47 45 58 20 74 6f 20 62  H and REGEX to b
0730: 65 68 61 76 65 20 73 69 6d 69 6c 61 72 6c 79 20  ehave similarly 
0740: 74 6f 20 74 68 65 20 3d 3d 20 6f 70 65 72 61 74  to the == operat
0750: 6f 72 2e 0a 23 0a 70 72 6f 63 20 6d 61 74 63 68  or..#.proc match
0760: 66 75 6e 63 20 7b 61 20 62 7d 20 7b 20 72 65 74  func {a b} { ret
0770: 75 72 6e 20 5b 65 78 70 72 20 7b 24 61 3d 3d 24  urn [expr {$a==$
0780: 62 7d 5d 20 7d 0a 70 72 6f 63 20 72 65 67 65 78  b}] }.proc regex
0790: 66 75 6e 63 20 7b 61 20 62 7d 20 7b 20 72 65 74  func {a b} { ret
07a0: 75 72 6e 20 5b 65 78 70 72 20 7b 24 61 3d 3d 24  urn [expr {$a==$
07b0: 62 7d 5d 20 7d 0a 64 62 20 66 75 6e 63 20 6d 61  b}] }.db func ma
07c0: 74 63 68 20 20 2d 61 72 67 63 6f 75 6e 74 20 32  tch  -argcount 2
07d0: 20 6d 61 74 63 68 66 75 6e 63 0a 64 62 20 66 75   matchfunc.db fu
07e0: 6e 63 20 72 65 67 65 78 70 20 2d 61 72 67 63 6f  nc regexp -argco
07f0: 75 6e 74 20 32 20 72 65 67 65 78 66 75 6e 63 0a  unt 2 regexfunc.
0800: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
0810: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0820: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0830: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0840: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65  -----------.# Te
0850: 73 74 20 63 61 73 65 73 20 65 5f 65 78 70 72 2d  st cases e_expr-
0860: 31 2e 2a 20 61 74 74 65 6d 70 74 20 74 6f 20 76  1.* attempt to v
0870: 65 72 69 66 79 20 74 68 61 74 20 61 6c 6c 20 62  erify that all b
0880: 69 6e 61 72 79 20 6f 70 65 72 61 74 6f 72 73 20  inary operators 
0890: 6c 69 73 74 65 64 0a 23 20 69 6e 20 74 68 65 20  listed.# in the 
08a0: 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 65 78  documentation ex
08b0: 69 73 74 20 61 6e 64 20 74 68 61 74 20 74 68 65  ist and that the
08c0: 20 72 65 6c 61 74 69 76 65 20 70 72 65 63 65 64   relative preced
08d0: 65 6e 63 65 73 20 6f 66 20 74 68 65 0a 23 20 6f  ences of the.# o
08e0: 70 65 72 61 74 6f 72 73 20 61 72 65 20 61 6c 73  perators are als
08f0: 6f 20 61 73 20 74 68 65 20 64 6f 63 75 6d 65 6e  o as the documen
0900: 74 61 74 69 6f 6e 20 73 75 67 67 65 73 74 73 2e  tation suggests.
0910: 0a 23 0a 23 20 45 56 49 44 45 4e 43 45 2d 4f 46  .#.# EVIDENCE-OF
0920: 3a 20 52 2d 31 35 35 31 34 2d 36 35 31 36 33 20  : R-15514-65163 
0930: 53 51 4c 69 74 65 20 75 6e 64 65 72 73 74 61 6e  SQLite understan
0940: 64 73 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  ds the following
0950: 20 62 69 6e 61 72 79 0a 23 20 6f 70 65 72 61 74   binary.# operat
0960: 6f 72 73 2c 20 69 6e 20 6f 72 64 65 72 20 66 72  ors, in order fr
0970: 6f 6d 20 68 69 67 68 65 73 74 20 74 6f 20 6c 6f  om highest to lo
0980: 77 65 73 74 20 70 72 65 63 65 64 65 6e 63 65 3a  west precedence:
0990: 20 7c 7c 20 2a 20 2f 20 25 20 2b 20 2d 0a 23 20   || * / % + -.# 
09a0: 3c 3c 20 3e 3e 20 26 20 7c 20 3c 20 3c 3d 20 3e  << >> & | < <= >
09b0: 20 3e 3d 20 3d 20 3d 3d 20 21 3d 20 3c 3e 20 49   >= = == != <> I
09c0: 53 20 49 53 0a 23 20 4e 4f 54 20 49 4e 20 4c 49  S IS.# NOT IN LI
09d0: 4b 45 20 47 4c 4f 42 20 4d 41 54 43 48 20 52 45  KE GLOB MATCH RE
09e0: 47 45 58 50 20 41 4e 44 20 4f 52 0a 23 0a 23 20  GEXP AND OR.#.# 
09f0: 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d 33  EVIDENCE-OF: R-3
0a00: 38 37 35 39 2d 33 38 37 38 39 20 4f 70 65 72 61  8759-38789 Opera
0a10: 74 6f 72 73 20 49 53 20 61 6e 64 20 49 53 20 4e  tors IS and IS N
0a20: 4f 54 20 68 61 76 65 20 74 68 65 20 73 61 6d 65  OT have the same
0a30: 0a 23 20 70 72 65 63 65 64 65 6e 63 65 20 61 73  .# precedence as
0a40: 20 3d 2e 0a 23 0a 0a 0a 23 20 54 4f 44 4f 3a 20   =..#...# TODO: 
0a50: 54 68 65 73 65 20 74 65 73 74 73 20 61 72 65 20  These tests are 
0a60: 63 75 72 72 65 6e 74 6c 79 20 6f 6d 69 74 74 65  currently omitte
0a70: 64 20 62 65 63 61 75 73 65 20 6f 6e 65 20 6f 72  d because one or
0a80: 20 74 77 6f 20 63 61 73 65 73 0a 23 20 72 65 6c   two cases.# rel
0a90: 61 74 65 64 20 74 6f 20 4c 49 4b 45 2f 47 4c 4f  ated to LIKE/GLO
0aa0: 42 2f 4d 41 54 43 48 2f 52 45 47 45 58 50 20 66  B/MATCH/REGEXP f
0ab0: 61 69 6c 2e 20 41 66 74 65 72 20 74 68 69 73 20  ail. After this 
0ac0: 63 61 73 65 20 69 73 20 66 69 78 65 64 2c 0a 23  case is fixed,.#
0ad0: 20 72 65 69 6e 73 74 61 74 65 20 74 68 65 73 65   reinstate these
0ae0: 20 74 65 73 74 73 2e 0a 23 0a 69 66 20 30 20 7b   tests..#.if 0 {
0af0: 0a 0a 75 6e 73 65 74 20 2d 6e 6f 63 6f 6d 70 6c  ..unset -nocompl
0b00: 61 69 6e 20 75 6e 74 65 73 74 65 64 0a 66 6f 72  ain untested.for
0b10: 65 61 63 68 20 6f 70 31 20 24 6f 70 6c 69 73 74  each op1 $oplist
0b20: 20 7b 0a 20 20 66 6f 72 65 61 63 68 20 6f 70 32   {.  foreach op2
0b30: 20 24 6f 70 6c 69 73 74 20 7b 0a 20 20 20 20 73   $oplist {.    s
0b40: 65 74 20 75 6e 74 65 73 74 65 64 28 24 6f 70 31  et untested($op1
0b50: 2c 24 6f 70 32 29 20 31 0a 20 20 20 20 66 6f 72  ,$op2) 1.    for
0b60: 65 61 63 68 20 7b 74 6e 20 41 20 42 20 43 7d 20  each {tn A B C} 
0b70: 7b 0a 20 20 20 20 20 20 20 31 20 20 20 20 20 32  {.       1     2
0b80: 32 20 20 20 34 35 20 20 20 20 36 36 0a 20 20 20  2   45    66.   
0b90: 20 20 20 20 32 20 20 20 20 20 20 30 20 20 20 20      2      0    
0ba0: 30 20 20 20 20 20 30 0a 20 20 20 20 20 20 20 33  0     0.       3
0bb0: 20 20 20 20 20 20 30 20 20 20 20 30 20 20 20 20        0    0    
0bc0: 20 31 0a 20 20 20 20 20 20 20 34 20 20 20 20 20   1.       4     
0bd0: 20 30 20 20 20 20 31 20 20 20 20 20 30 0a 20 20   0    1     0.  
0be0: 20 20 20 20 20 35 20 20 20 20 20 20 30 20 20 20       5      0   
0bf0: 20 31 20 20 20 20 20 31 0a 20 20 20 20 20 20 20   1     1.       
0c00: 36 20 20 20 20 20 20 31 20 20 20 20 30 20 20 20  6      1    0   
0c10: 20 20 30 0a 20 20 20 20 20 20 20 37 20 20 20 20    0.       7    
0c20: 20 20 31 20 20 20 20 30 20 20 20 20 20 31 0a 20    1    0     1. 
0c30: 20 20 20 20 20 20 38 20 20 20 20 20 20 31 20 20        8      1  
0c40: 20 20 31 20 20 20 20 20 30 0a 20 20 20 20 20 20    1     0.      
0c50: 20 39 20 20 20 20 20 20 31 20 20 20 20 31 20 20   9      1    1  
0c60: 20 20 20 31 0a 20 20 20 20 20 20 31 30 20 20 20     1.      10   
0c70: 20 20 20 35 20 20 20 20 36 20 20 20 20 20 31 0a     5    6     1.
0c80: 20 20 20 20 20 20 31 31 20 20 20 20 20 20 31 20        11      1 
0c90: 20 20 20 35 20 20 20 20 20 36 0a 20 20 20 20 20     5     6.     
0ca0: 20 31 32 20 20 20 20 20 20 31 20 20 20 20 35 20   12      1    5 
0cb0: 20 20 20 20 35 0a 20 20 20 20 20 20 31 33 20 20      5.      13  
0cc0: 20 20 20 20 35 20 20 20 20 35 20 20 20 20 20 31      5    5     1
0cd0: 0a 0a 20 20 20 20 20 20 31 34 20 20 20 20 20 20  ..      14      
0ce0: 35 20 20 20 20 32 20 20 20 20 20 31 0a 20 20 20  5    2     1.   
0cf0: 20 20 20 31 35 20 20 20 20 20 20 31 20 20 20 20     15      1    
0d00: 34 20 20 20 20 20 31 0a 20 20 20 20 20 20 31 36  4     1.      16
0d10: 20 20 20 20 20 2d 31 20 20 20 20 30 20 20 20 20       -1    0    
0d20: 20 31 0a 20 20 20 20 20 20 31 37 20 20 20 20 20   1.      17     
0d30: 20 30 20 20 20 20 31 20 20 20 20 2d 31 0a 0a 20   0    1    -1.. 
0d40: 20 20 20 7d 20 7b 0a 20 20 20 20 20 20 73 65 74     } {.      set
0d50: 20 74 65 73 74 6e 61 6d 65 20 22 65 5f 65 78 70   testname "e_exp
0d60: 72 2d 31 2e 24 6f 70 6e 61 6d 65 28 24 6f 70 31  r-1.$opname($op1
0d70: 29 2e 24 6f 70 6e 61 6d 65 28 24 6f 70 32 29 2e  ).$opname($op2).
0d80: 24 74 6e 22 0a 0a 20 20 20 20 20 20 23 20 49 66  $tn"..      # If
0d90: 20 24 6f 70 32 20 67 72 6f 75 70 73 20 6d 6f 72   $op2 groups mor
0da0: 65 20 74 69 67 68 74 6c 79 20 74 68 61 6e 20 24  e tightly than $
0db0: 6f 70 31 2c 20 74 68 65 6e 20 74 68 65 20 72 65  op1, then the re
0dc0: 73 75 6c 74 0a 20 20 20 20 20 20 23 20 6f 66 20  sult.      # of 
0dd0: 65 78 65 63 75 74 69 6e 67 20 24 73 71 6c 31 20  executing $sql1 
0de0: 77 68 6f 75 6c 64 20 62 65 20 74 68 65 20 73 61  whould be the sa
0df0: 6d 65 20 61 73 20 65 78 65 63 75 74 69 6e 67 20  me as executing 
0e00: 24 73 71 6c 33 2e 0a 20 20 20 20 20 20 23 20 49  $sql3..      # I
0e10: 66 20 24 6f 70 31 20 67 72 6f 75 70 73 20 6d 6f  f $op1 groups mo
0e20: 72 65 20 74 69 67 68 74 6c 79 2c 20 6f 72 20 69  re tightly, or i
0e30: 66 20 24 6f 70 31 20 61 6e 64 20 24 6f 70 32 20  f $op1 and $op2 
0e40: 68 61 76 65 20 0a 20 20 20 20 20 20 23 20 74 68  have .      # th
0e50: 65 20 73 61 6d 65 20 70 72 65 63 65 64 65 6e 63  e same precedenc
0e60: 65 2c 20 74 68 65 6e 20 65 78 65 63 75 74 69 6e  e, then executin
0e70: 67 20 24 73 71 6c 31 20 73 68 6f 75 6c 64 20 72  g $sql1 should r
0e80: 65 74 75 72 6e 0a 20 20 20 20 20 20 23 20 74 68  eturn.      # th
0e90: 65 20 73 61 6d 65 20 76 61 6c 75 65 20 61 73 20  e same value as 
0ea0: 24 73 71 6c 32 2e 0a 20 20 20 20 20 20 23 0a 20  $sql2..      #. 
0eb0: 20 20 20 20 20 73 65 74 20 73 71 6c 31 20 22 53       set sql1 "S
0ec0: 45 4c 45 43 54 20 24 41 20 24 6f 70 31 20 24 42  ELECT $A $op1 $B
0ed0: 20 24 6f 70 32 20 24 43 22 0a 20 20 20 20 20 20   $op2 $C".      
0ee0: 73 65 74 20 73 71 6c 32 20 22 53 45 4c 45 43 54  set sql2 "SELECT
0ef0: 20 28 24 41 20 24 6f 70 31 20 24 42 29 20 24 6f   ($A $op1 $B) $o
0f00: 70 32 20 24 43 22 0a 20 20 20 20 20 20 73 65 74  p2 $C".      set
0f10: 20 73 71 6c 33 20 22 53 45 4c 45 43 54 20 24 41   sql3 "SELECT $A
0f20: 20 24 6f 70 31 20 28 24 42 20 24 6f 70 32 20 24   $op1 ($B $op2 $
0f30: 43 29 22 0a 0a 20 20 20 20 20 20 73 65 74 20 61  C)"..      set a
0f40: 32 20 5b 64 62 20 6f 6e 65 20 24 73 71 6c 32 5d  2 [db one $sql2]
0f50: 0a 20 20 20 20 20 20 73 65 74 20 61 33 20 5b 64  .      set a3 [d
0f60: 62 20 6f 6e 65 20 24 73 71 6c 33 5d 0a 0a 20 20  b one $sql3]..  
0f70: 20 20 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74      do_execsql_t
0f80: 65 73 74 20 24 74 65 73 74 6e 61 6d 65 20 24 73  est $testname $s
0f90: 71 6c 31 20 5b 6c 69 73 74 20 5b 0a 20 20 20 20  ql1 [list [.    
0fa0: 20 20 20 20 65 78 70 72 20 7b 24 6f 70 70 72 65      expr {$oppre
0fb0: 63 28 24 6f 70 32 29 20 3c 20 24 6f 70 70 72 65  c($op2) < $oppre
0fc0: 63 28 24 6f 70 31 29 20 3f 20 24 61 33 20 3a 20  c($op1) ? $a3 : 
0fd0: 24 61 32 7d 0a 20 20 20 20 20 20 5d 5d 0a 0a 20  $a2}.      ]].. 
0fe0: 20 20 20 20 20 69 66 20 7b 24 61 32 20 21 3d 20       if {$a2 != 
0ff0: 24 61 33 7d 20 7b 20 75 6e 73 65 74 20 2d 6e 6f  $a3} { unset -no
1000: 63 6f 6d 70 6c 61 69 6e 20 75 6e 74 65 73 74 65  complain unteste
1010: 64 28 24 6f 70 31 2c 24 6f 70 32 29 20 7d 0a 20  d($op1,$op2) }. 
1020: 20 20 20 7d 0a 20 20 7d 0a 7d 0a 0a 66 6f 72 65     }.  }.}..fore
1030: 61 63 68 20 6f 70 20 7b 2a 20 41 4e 44 20 4f 52  ach op {* AND OR
1040: 20 2b 20 7c 7c 20 26 20 7c 7d 20 7b 20 75 6e 73   + || & |} { uns
1050: 65 74 20 75 6e 74 65 73 74 65 64 28 24 6f 70 2c  et untested($op,
1060: 24 6f 70 29 20 7d 0a 75 6e 73 65 74 20 75 6e 74  $op) }.unset unt
1070: 65 73 74 65 64 28 2b 2c 2d 29 20 20 3b 23 20 20  ested(+,-)  ;#  
1080: 20 20 20 20 20 53 69 6e 63 65 20 20 20 20 28 61       Since    (a
1090: 2b 62 29 2d 63 20 3d 3d 20 61 2b 28 62 2d 63 29  +b)-c == a+(b-c)
10a0: 0a 75 6e 73 65 74 20 75 6e 74 65 73 74 65 64 28  .unset untested(
10b0: 2a 2c 3c 3c 29 20 3b 23 20 20 20 20 20 20 20 53  *,<<) ;#       S
10c0: 69 6e 63 65 20 20 20 20 28 61 2a 62 29 3c 3c 63  ince    (a*b)<<c
10d0: 20 3d 3d 20 61 2a 28 62 3c 3c 63 29 0a 0a 64 6f   == a*(b<<c)..do
10e0: 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 31 2e 31  _test e_expr-1.1
10f0: 20 7b 20 61 72 72 61 79 20 6e 61 6d 65 73 20 75   { array names u
1100: 6e 74 65 73 74 65 64 20 7d 20 7b 7d 0a 0a 23 20  ntested } {}..# 
1110: 41 74 20 6f 6e 65 20 70 6f 69 6e 74 2c 20 74 65  At one point, te
1120: 73 74 20 31 2e 32 2e 32 20 77 61 73 20 66 61 69  st 1.2.2 was fai
1130: 6c 69 6e 67 2e 20 49 6e 73 74 65 61 64 20 6f 66  ling. Instead of
1140: 20 74 68 65 20 63 6f 72 72 65 63 74 20 72 65 73   the correct res
1150: 75 6c 74 2c 20 69 74 0a 23 20 77 61 73 20 72 65  ult, it.# was re
1160: 74 75 72 6e 69 6e 67 20 7b 31 20 31 20 30 7d 2e  turning {1 1 0}.
1170: 20 54 68 69 73 20 77 6f 75 6c 64 20 73 65 65 6d   This would seem
1180: 20 74 6f 20 69 6e 64 69 63 61 74 65 20 74 68 61   to indicate tha
1190: 74 20 4c 49 4b 45 20 68 61 73 20 74 68 65 0a 23  t LIKE has the.#
11a0: 20 73 61 6d 65 20 70 72 65 63 65 64 65 6e 63 65   same precedence
11b0: 20 61 73 20 27 3c 27 2e 20 57 68 69 63 68 20 69   as '<'. Which i
11c0: 73 20 69 6e 63 6f 72 72 65 63 74 2e 20 49 74 20  s incorrect. It 
11d0: 68 61 73 20 6c 6f 77 65 72 20 70 72 65 63 65 64  has lower preced
11e0: 65 6e 63 65 2e 0a 23 0a 64 6f 5f 65 78 65 63 73  ence..#.do_execs
11f0: 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 31  ql_test e_expr-1
1200: 2e 32 2e 31 20 7b 20 0a 20 20 53 45 4c 45 43 54  .2.1 { .  SELECT
1210: 20 30 20 3c 20 32 20 4c 49 4b 45 20 31 2c 20 20   0 < 2 LIKE 1,  
1220: 20 28 30 20 3c 20 32 29 20 4c 49 4b 45 20 31 2c   (0 < 2) LIKE 1,
1230: 20 20 20 30 20 3c 20 28 32 20 4c 49 4b 45 20 31     0 < (2 LIKE 1
1240: 29 0a 7d 20 7b 31 20 31 20 30 7d 0a 64 6f 5f 65  ).} {1 1 0}.do_e
1250: 78 65 63 73 71 6c 5f 74 65 73 74 20 65 5f 65 78  xecsql_test e_ex
1260: 70 72 2d 31 2e 32 2e 32 20 7b 20 0a 20 20 53 45  pr-1.2.2 { .  SE
1270: 4c 45 43 54 20 30 20 4c 49 4b 45 20 30 20 3c 20  LECT 0 LIKE 0 < 
1280: 32 2c 20 20 20 28 30 20 4c 49 4b 45 20 30 29 20  2,   (0 LIKE 0) 
1290: 3c 20 32 2c 20 20 20 30 20 4c 49 4b 45 20 28 30  < 2,   0 LIKE (0
12a0: 20 3c 20 32 29 0a 7d 20 7b 30 20 31 20 30 7d 0a   < 2).} {0 1 0}.
12b0: 0a 23 20 53 68 6f 77 69 6e 67 20 74 68 61 74 20  .# Showing that 
12c0: 4c 49 4b 45 20 61 6e 64 20 3d 3d 20 68 61 76 65  LIKE and == have
12d0: 20 74 68 65 20 73 61 6d 65 20 70 72 65 63 65 64   the same preced
12e0: 65 6e 63 65 0a 23 0a 64 6f 5f 65 78 65 63 73 71  ence.#.do_execsq
12f0: 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 31 2e  l_test e_expr-1.
1300: 32 2e 33 20 7b 20 0a 20 20 53 45 4c 45 43 54 20  2.3 { .  SELECT 
1310: 32 20 4c 49 4b 45 20 32 20 3d 3d 20 31 2c 20 20  2 LIKE 2 == 1,  
1320: 20 28 32 20 4c 49 4b 45 20 32 29 20 3d 3d 20 31   (2 LIKE 2) == 1
1330: 2c 20 20 20 20 32 20 4c 49 4b 45 20 28 32 20 3d  ,    2 LIKE (2 =
1340: 3d 20 31 29 0a 7d 20 7b 31 20 31 20 30 7d 0a 64  = 1).} {1 1 0}.d
1350: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 65  o_execsql_test e
1360: 5f 65 78 70 72 2d 31 2e 32 2e 34 20 7b 20 0a 20  _expr-1.2.4 { . 
1370: 20 53 45 4c 45 43 54 20 32 20 3d 3d 20 32 20 4c   SELECT 2 == 2 L
1380: 49 4b 45 20 31 2c 20 20 20 28 32 20 3d 3d 20 32  IKE 1,   (2 == 2
1390: 29 20 4c 49 4b 45 20 31 2c 20 20 20 20 32 20 3d  ) LIKE 1,    2 =
13a0: 3d 20 28 32 20 4c 49 4b 45 20 31 29 0a 7d 20 7b  = (2 LIKE 1).} {
13b0: 31 20 31 20 30 7d 0a 0a 23 20 53 68 6f 77 69 6e  1 1 0}..# Showin
13c0: 67 20 74 68 61 74 20 3c 20 67 72 6f 75 70 73 20  g that < groups 
13d0: 6d 6f 72 65 20 74 69 67 68 74 6c 79 20 74 68 61  more tightly tha
13e0: 6e 20 3d 3d 20 28 3c 20 68 61 73 20 68 69 67 68  n == (< has high
13f0: 65 72 20 70 72 65 63 65 64 65 6e 63 65 29 2e 20  er precedence). 
1400: 0a 23 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  .#.do_execsql_te
1410: 73 74 20 65 5f 65 78 70 72 2d 31 2e 32 2e 35 20  st e_expr-1.2.5 
1420: 7b 20 0a 20 20 53 45 4c 45 43 54 20 30 20 3c 20  { .  SELECT 0 < 
1430: 32 20 3d 3d 20 31 2c 20 20 20 28 30 20 3c 20 32  2 == 1,   (0 < 2
1440: 29 20 3d 3d 20 31 2c 20 20 20 30 20 3c 20 28 32  ) == 1,   0 < (2
1450: 20 3d 3d 20 31 29 0a 7d 20 7b 31 20 31 20 30 7d   == 1).} {1 1 0}
1460: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
1470: 20 65 5f 65 78 70 72 2d 31 2e 36 20 7b 20 0a 20   e_expr-1.6 { . 
1480: 20 53 45 4c 45 43 54 20 30 20 3d 3d 20 30 20 3c   SELECT 0 == 0 <
1490: 20 32 2c 20 20 20 28 30 20 3d 3d 20 30 29 20 3c   2,   (0 == 0) <
14a0: 20 32 2c 20 20 20 30 20 3d 3d 20 28 30 20 3c 20   2,   0 == (0 < 
14b0: 32 29 0a 7d 20 7b 30 20 31 20 30 7d 0a 0a 7d 0a  2).} {0 1 0}..}.
14c0: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
14d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
14e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
14f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1500: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 43 68  -----------.# Ch
1510: 65 63 6b 20 74 68 61 74 20 74 68 65 20 66 6f 75  eck that the fou
1520: 72 20 75 6e 61 72 79 20 70 72 65 66 69 78 20 6f  r unary prefix o
1530: 70 65 72 61 74 6f 72 73 20 6d 65 6e 74 69 6f 6e  perators mention
1540: 65 64 20 69 6e 20 74 68 65 20 0a 23 20 64 6f 63  ed in the .# doc
1550: 75 6d 65 6e 74 61 74 69 6f 6e 20 65 78 69 73 74  umentation exist
1560: 2e 0a 23 0a 23 20 45 56 49 44 45 4e 43 45 2d 4f  ..#.# EVIDENCE-O
1570: 46 3a 20 52 2d 31 33 39 35 38 2d 35 33 34 31 39  F: R-13958-53419
1580: 20 53 75 70 70 6f 72 74 65 64 20 75 6e 61 72 79   Supported unary
1590: 20 70 72 65 66 69 78 20 6f 70 65 72 61 74 6f 72   prefix operator
15a0: 73 20 61 72 65 20 74 68 65 73 65 3a 0a 23 20 2d  s are these:.# -
15b0: 20 2b 20 7e 20 4e 4f 54 0a 23 0a 64 6f 5f 65 78   + ~ NOT.#.do_ex
15c0: 65 63 73 71 6c 5f 74 65 73 74 20 65 5f 65 78 70  ecsql_test e_exp
15d0: 72 2d 32 2e 31 20 7b 20 53 45 4c 45 43 54 20 2d  r-2.1 { SELECT -
15e0: 20 20 20 31 30 20 20 20 7d 20 7b 2d 31 30 7d 0a     10   } {-10}.
15f0: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1600: 65 5f 65 78 70 72 2d 32 2e 32 20 7b 20 53 45 4c  e_expr-2.2 { SEL
1610: 45 43 54 20 2b 20 20 20 31 30 20 20 20 7d 20 7b  ECT +   10   } {
1620: 31 30 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  10}.do_execsql_t
1630: 65 73 74 20 65 5f 65 78 70 72 2d 32 2e 33 20 7b  est e_expr-2.3 {
1640: 20 53 45 4c 45 43 54 20 7e 20 20 20 31 30 20 20   SELECT ~   10  
1650: 20 7d 20 7b 2d 31 31 7d 0a 64 6f 5f 65 78 65 63   } {-11}.do_exec
1660: 73 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d  sql_test e_expr-
1670: 32 2e 34 20 7b 20 53 45 4c 45 43 54 20 4e 4f 54  2.4 { SELECT NOT
1680: 20 31 30 20 20 20 7d 20 7b 30 7d 0a 0a 23 2d 2d   10   } {0}..#--
1690: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16d0: 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 73 20  -------.# Tests 
16e0: 66 6f 72 20 74 68 65 20 74 77 6f 20 73 74 61 74  for the two stat
16f0: 65 6d 65 6e 74 73 20 6d 61 64 65 20 72 65 67 61  ements made rega
1700: 72 64 69 6e 67 20 74 68 65 20 75 6e 61 72 79 20  rding the unary 
1710: 2b 20 6f 70 65 72 61 74 6f 72 2e 0a 23 0a 23 20  + operator..#.# 
1720: 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d 35  EVIDENCE-OF: R-5
1730: 33 36 37 30 2d 30 33 33 37 33 20 54 68 65 20 75  3670-03373 The u
1740: 6e 61 72 79 20 6f 70 65 72 61 74 6f 72 20 2b 20  nary operator + 
1750: 69 73 20 61 20 6e 6f 2d 6f 70 2e 0a 23 0a 23 20  is a no-op..#.# 
1760: 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d 31  EVIDENCE-OF: R-1
1770: 39 34 38 30 2d 33 30 39 36 38 20 49 74 20 63 61  9480-30968 It ca
1780: 6e 20 62 65 20 61 70 70 6c 69 65 64 20 74 6f 20  n be applied to 
1790: 73 74 72 69 6e 67 73 2c 20 6e 75 6d 62 65 72 73  strings, numbers
17a0: 2c 0a 23 20 62 6c 6f 62 73 20 6f 72 20 4e 55 4c  ,.# blobs or NUL
17b0: 4c 20 61 6e 64 20 69 74 20 61 6c 77 61 79 73 20  L and it always 
17c0: 72 65 74 75 72 6e 73 20 61 20 72 65 73 75 6c 74  returns a result
17d0: 20 77 69 74 68 20 74 68 65 20 73 61 6d 65 20 76   with the same v
17e0: 61 6c 75 65 20 61 73 0a 23 20 74 68 65 20 6f 70  alue as.# the op
17f0: 65 72 61 6e 64 2e 0a 23 0a 66 6f 72 65 61 63 68  erand..#.foreach
1800: 20 7b 74 6e 20 6c 69 74 65 72 61 6c 20 74 79 70   {tn literal typ
1810: 65 7d 20 7b 0a 20 20 31 20 20 20 20 20 27 68 65  e} {.  1     'he
1820: 6c 6c 6f 77 6f 72 6c 64 27 20 20 20 74 65 78 74  lloworld'   text
1830: 0a 20 20 32 20 20 20 20 20 34 35 20 20 20 20 20  .  2     45     
1840: 20 20 20 20 20 20 20 20 69 6e 74 65 67 65 72 0a          integer.
1850: 20 20 33 20 20 20 20 20 34 35 2e 32 20 20 20 20    3     45.2    
1860: 20 20 20 20 20 20 20 72 65 61 6c 0a 20 20 34 20         real.  4 
1870: 20 20 20 20 34 35 2e 30 20 20 20 20 20 20 20 20      45.0        
1880: 20 20 20 72 65 61 6c 0a 20 20 35 20 20 20 20 20     real.  5     
1890: 58 27 41 42 43 44 45 46 27 20 20 20 20 20 20 62  X'ABCDEF'      b
18a0: 6c 6f 62 0a 20 20 36 20 20 20 20 20 4e 55 4c 4c  lob.  6     NULL
18b0: 20 20 20 20 20 20 20 20 20 20 20 6e 75 6c 6c 0a             null.
18c0: 7d 20 7b 0a 20 20 73 65 74 20 73 71 6c 20 22 20  } {.  set sql " 
18d0: 53 45 4c 45 43 54 20 71 75 6f 74 65 28 20 2b 20  SELECT quote( + 
18e0: 24 6c 69 74 65 72 61 6c 20 29 2c 20 74 79 70 65  $literal ), type
18f0: 6f 66 28 20 2b 20 24 6c 69 74 65 72 61 6c 29 20  of( + $literal) 
1900: 22 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74  ".  do_execsql_t
1910: 65 73 74 20 65 5f 65 78 70 72 2d 33 2e 24 74 6e  est e_expr-3.$tn
1920: 20 24 73 71 6c 20 5b 6c 69 73 74 20 24 6c 69 74   $sql [list $lit
1930: 65 72 61 6c 20 24 74 79 70 65 5d 0a 7d 0a 0a 23  eral $type].}..#
1940: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1950: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1960: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1970: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1980: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 43 68 65 63  ---------.# Chec
1990: 6b 20 74 68 61 74 20 62 6f 74 68 20 3d 20 61 6e  k that both = an
19a0: 64 20 3d 3d 20 61 72 65 20 62 6f 74 68 20 61 63  d == are both ac
19b0: 63 65 70 74 61 62 6c 65 20 61 73 20 74 68 65 20  ceptable as the 
19c0: 22 65 71 75 61 6c 73 22 20 6f 70 65 72 61 74 6f  "equals" operato
19d0: 72 2e 0a 23 20 53 69 6d 69 6c 61 72 6c 79 2c 20  r..# Similarly, 
19e0: 65 69 74 68 65 72 20 21 3d 20 6f 72 20 3c 3e 20  either != or <> 
19f0: 77 6f 72 6b 20 61 73 20 74 68 65 20 6e 6f 74 2d  work as the not-
1a00: 65 71 75 61 6c 73 20 6f 70 65 72 61 74 6f 72 2e  equals operator.
1a10: 0a 23 0a 23 20 45 56 49 44 45 4e 43 45 2d 4f 46  .#.# EVIDENCE-OF
1a20: 3a 20 52 2d 30 33 36 37 39 2d 36 30 36 33 39 20  : R-03679-60639 
1a30: 45 71 75 61 6c 73 20 63 61 6e 20 62 65 20 65 69  Equals can be ei
1a40: 74 68 65 72 20 3d 20 6f 72 20 3d 3d 2e 0a 23 0a  ther = or ==..#.
1a50: 23 20 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52  # EVIDENCE-OF: R
1a60: 2d 33 30 30 38 32 2d 33 38 39 39 36 20 54 68 65  -30082-38996 The
1a70: 20 6e 6f 6e 2d 65 71 75 61 6c 73 20 6f 70 65 72   non-equals oper
1a80: 61 74 6f 72 20 63 61 6e 20 62 65 20 65 69 74 68  ator can be eith
1a90: 65 72 20 21 3d 20 6f 72 0a 23 20 3c 3e 2e 0a 23  er != or.# <>..#
1aa0: 0a 66 6f 72 65 61 63 68 20 7b 74 6e 20 6c 69 74  .foreach {tn lit
1ab0: 65 72 61 6c 20 64 69 66 66 65 72 65 6e 74 7d 20  eral different} 
1ac0: 7b 0a 20 20 31 20 20 20 27 68 65 6c 6c 6f 77 6f  {.  1   'hellowo
1ad0: 72 6c 64 27 20 20 27 31 32 33 34 35 27 0a 20 20  rld'  '12345'.  
1ae0: 32 20 20 20 32 32 20 20 20 20 20 20 20 20 20 20  2   22          
1af0: 20 20 32 33 0a 20 20 33 20 20 20 27 78 79 7a 27    23.  3   'xyz'
1b00: 20 20 20 20 20 20 20 20 20 58 27 37 38 37 39 37           X'78797
1b10: 41 27 0a 20 20 34 20 20 20 58 27 37 38 37 39 37  A'.  4   X'78797
1b20: 41 30 30 27 20 20 20 27 78 79 7a 27 0a 7d 20 7b  A00'   'xyz'.} {
1b30: 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  .  do_execsql_te
1b40: 73 74 20 65 5f 65 78 70 72 2d 34 2e 24 74 6e 20  st e_expr-4.$tn 
1b50: 22 0a 20 20 20 20 53 45 4c 45 43 54 20 24 6c 69  ".    SELECT $li
1b60: 74 65 72 61 6c 20 20 3d 20 24 6c 69 74 65 72 61  teral  = $litera
1b70: 6c 2c 20 20 20 24 6c 69 74 65 72 61 6c 20 3d 3d  l,   $literal ==
1b80: 20 24 6c 69 74 65 72 61 6c 2c 0a 20 20 20 20 20   $literal,.     
1b90: 20 20 20 20 20 20 24 6c 69 74 65 72 61 6c 20 20        $literal  
1ba0: 3d 20 24 64 69 66 66 65 72 65 6e 74 2c 20 24 6c  = $different, $l
1bb0: 69 74 65 72 61 6c 20 3d 3d 20 24 64 69 66 66 65  iteral == $diffe
1bc0: 72 65 6e 74 2c 0a 20 20 20 20 20 20 20 20 20 20  rent,.          
1bd0: 20 24 6c 69 74 65 72 61 6c 20 20 3d 20 4e 55 4c   $literal  = NUL
1be0: 4c 2c 20 20 20 20 20 20 20 24 6c 69 74 65 72 61  L,       $litera
1bf0: 6c 20 3d 3d 20 4e 55 4c 4c 2c 0a 20 20 20 20 20  l == NULL,.     
1c00: 20 20 20 20 20 20 24 6c 69 74 65 72 61 6c 20 21        $literal !
1c10: 3d 20 24 6c 69 74 65 72 61 6c 2c 20 20 20 24 6c  = $literal,   $l
1c20: 69 74 65 72 61 6c 20 3c 3e 20 24 6c 69 74 65 72  iteral <> $liter
1c30: 61 6c 2c 0a 20 20 20 20 20 20 20 20 20 20 20 24  al,.           $
1c40: 6c 69 74 65 72 61 6c 20 21 3d 20 24 64 69 66 66  literal != $diff
1c50: 65 72 65 6e 74 2c 20 24 6c 69 74 65 72 61 6c 20  erent, $literal 
1c60: 3c 3e 20 24 64 69 66 66 65 72 65 6e 74 2c 0a 20  <> $different,. 
1c70: 20 20 20 20 20 20 20 20 20 20 24 6c 69 74 65 72            $liter
1c80: 61 6c 20 21 3d 20 4e 55 4c 4c 2c 20 20 20 20 20  al != NULL,     
1c90: 20 20 24 6c 69 74 65 72 61 6c 20 21 3d 20 4e 55    $literal != NU
1ca0: 4c 4c 0a 0a 20 20 22 20 7b 31 20 31 20 30 20 30  LL..  " {1 1 0 0
1cb0: 20 7b 7d 20 7b 7d 20 30 20 30 20 31 20 31 20 7b   {} {} 0 0 1 1 {
1cc0: 7d 20 7b 7d 7d 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  } {}}.}..#------
1cd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ce0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1cf0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1d00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1d10: 2d 2d 2d 0a 23 20 54 65 73 74 20 74 68 65 20 7c  ---.# Test the |
1d20: 7c 20 6f 70 65 72 61 74 6f 72 2e 0a 23 0a 23 20  | operator..#.# 
1d30: 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d 34  EVIDENCE-OF: R-4
1d40: 34 34 30 39 2d 36 32 36 34 31 20 54 68 65 20 7c  4409-62641 The |
1d50: 7c 20 6f 70 65 72 61 74 6f 72 20 69 73 20 22 63  | operator is "c
1d60: 6f 6e 63 61 74 65 6e 61 74 65 22 20 2d 20 69 74  oncatenate" - it
1d70: 20 6a 6f 69 6e 73 0a 23 20 74 6f 67 65 74 68 65   joins.# togethe
1d80: 72 20 74 68 65 20 74 77 6f 20 73 74 72 69 6e 67  r the two string
1d90: 73 20 6f 66 20 69 74 73 20 6f 70 65 72 61 6e 64  s of its operand
1da0: 73 2e 0a 23 0a 66 6f 72 65 61 63 68 20 7b 74 6e  s..#.foreach {tn
1db0: 20 61 20 62 7d 20 7b 0a 20 20 31 20 20 20 27 68   a b} {.  1   'h
1dc0: 65 6c 6c 6f 77 6f 72 6c 64 27 20 20 27 31 32 33  elloworld'  '123
1dd0: 34 35 27 0a 20 20 32 20 20 20 32 32 20 20 20 20  45'.  2   22    
1de0: 20 20 20 20 20 20 20 20 32 33 0a 7d 20 7b 0a 20          23.} {. 
1df0: 20 73 65 74 20 61 73 20 5b 64 62 20 6f 6e 65 20   set as [db one 
1e00: 22 53 45 4c 45 43 54 20 24 61 22 5d 0a 20 20 73  "SELECT $a"].  s
1e10: 65 74 20 62 73 20 5b 64 62 20 6f 6e 65 20 22 53  et bs [db one "S
1e20: 45 4c 45 43 54 20 24 62 22 5d 0a 20 20 0a 20 20  ELECT $b"].  .  
1e30: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1e40: 65 5f 65 78 70 72 2d 35 2e 24 74 6e 20 22 53 45  e_expr-5.$tn "SE
1e50: 4c 45 43 54 20 24 61 20 7c 7c 20 24 62 22 20 5b  LECT $a || $b" [
1e60: 6c 69 73 74 20 22 24 7b 61 73 7d 24 7b 62 73 7d  list "${as}${bs}
1e70: 22 5d 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  "].}..#---------
1e80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1e90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ec0: 0a 23 20 54 65 73 74 20 74 68 65 20 25 20 6f 70  .# Test the % op
1ed0: 65 72 61 74 6f 72 2e 0a 23 0a 23 20 45 56 49 44  erator..#.# EVID
1ee0: 45 4e 43 45 2d 4f 46 3a 20 52 2d 30 38 39 31 34  ENCE-OF: R-08914
1ef0: 2d 36 33 37 39 30 20 54 68 65 20 6f 70 65 72 61  -63790 The opera
1f00: 74 6f 72 20 25 20 6f 75 74 70 75 74 73 20 74 68  tor % outputs th
1f10: 65 20 76 61 6c 75 65 20 6f 66 20 69 74 73 0a 23  e value of its.#
1f20: 20 6c 65 66 74 20 6f 70 65 72 61 6e 64 20 6d 6f   left operand mo
1f30: 64 75 6c 6f 20 69 74 73 20 72 69 67 68 74 20 6f  dulo its right o
1f40: 70 65 72 61 6e 64 2e 0a 23 0a 64 6f 5f 65 78 65  perand..#.do_exe
1f50: 63 73 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72  csql_test e_expr
1f60: 2d 36 2e 31 20 7b 53 45 4c 45 43 54 20 20 37 32  -6.1 {SELECT  72
1f70: 25 35 7d 20 20 7b 32 7d 0a 64 6f 5f 65 78 65 63  %5}  {2}.do_exec
1f80: 73 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d  sql_test e_expr-
1f90: 36 2e 32 20 7b 53 45 4c 45 43 54 20 20 37 32 25  6.2 {SELECT  72%
1fa0: 2d 35 7d 20 7b 32 7d 0a 64 6f 5f 65 78 65 63 73  -5} {2}.do_execs
1fb0: 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 36  ql_test e_expr-6
1fc0: 2e 33 20 7b 53 45 4c 45 43 54 20 2d 37 32 25 2d  .3 {SELECT -72%-
1fd0: 35 7d 20 7b 2d 32 7d 0a 64 6f 5f 65 78 65 63 73  5} {-2}.do_execs
1fe0: 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 36  ql_test e_expr-6
1ff0: 2e 34 20 7b 53 45 4c 45 43 54 20 2d 37 32 25 35  .4 {SELECT -72%5
2000: 7d 20 20 7b 2d 32 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  }  {-2}..#------
2010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2040: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2050: 2d 2d 2d 0a 23 20 54 65 73 74 20 74 68 61 74 20  ---.# Test that 
2060: 74 68 65 20 72 65 73 75 6c 74 73 20 6f 66 20 61  the results of a
2070: 6c 6c 20 62 69 6e 61 72 79 20 6f 70 65 72 61 74  ll binary operat
2080: 6f 72 73 20 61 72 65 20 65 69 74 68 65 72 20 6e  ors are either n
2090: 75 6d 65 72 69 63 20 6f 72 20 0a 23 20 4e 55 4c  umeric or .# NUL
20a0: 4c 2c 20 65 78 63 65 70 74 20 66 6f 72 20 74 68  L, except for th
20b0: 65 20 7c 7c 20 6f 70 65 72 61 74 6f 72 2c 20 77  e || operator, w
20c0: 68 69 63 68 20 6d 61 79 20 65 76 61 6c 75 61 74  hich may evaluat
20d0: 65 20 74 6f 20 65 69 74 68 65 72 20 61 20 74 65  e to either a te
20e0: 78 74 0a 23 20 76 61 6c 75 65 20 6f 72 20 4e 55  xt.# value or NU
20f0: 4c 4c 2e 0a 23 0a 23 20 45 56 49 44 45 4e 43 45  LL..#.# EVIDENCE
2100: 2d 4f 46 3a 20 52 2d 32 30 36 36 35 2d 31 37 37  -OF: R-20665-177
2110: 39 32 20 54 68 65 20 72 65 73 75 6c 74 20 6f 66  92 The result of
2120: 20 61 6e 79 20 62 69 6e 61 72 79 20 6f 70 65 72   any binary oper
2130: 61 74 6f 72 20 69 73 20 65 69 74 68 65 72 0a 23  ator is either.#
2140: 20 61 20 6e 75 6d 65 72 69 63 20 76 61 6c 75 65   a numeric value
2150: 20 6f 72 20 4e 55 4c 4c 2c 20 65 78 63 65 70 74   or NULL, except
2160: 20 66 6f 72 20 74 68 65 20 7c 7c 20 63 6f 6e 63   for the || conc
2170: 61 74 65 6e 61 74 69 6f 6e 20 6f 70 65 72 61 74  atenation operat
2180: 6f 72 0a 23 20 77 68 69 63 68 20 61 6c 77 61 79  or.# which alway
2190: 73 20 65 76 61 6c 75 61 74 65 73 20 74 6f 20 65  s evaluates to e
21a0: 69 74 68 65 72 20 4e 55 4c 4c 20 6f 72 20 61 20  ither NULL or a 
21b0: 74 65 78 74 20 76 61 6c 75 65 2e 0a 23 0a 73 65  text value..#.se
21c0: 74 20 6c 69 74 65 72 61 6c 73 20 7b 0a 20 20 31  t literals {.  1
21d0: 20 27 61 62 63 27 20 20 20 20 20 20 20 20 32 20   'abc'        2 
21e0: 27 68 65 78 61 64 65 63 69 6d 61 6c 27 20 20 20  'hexadecimal'   
21f0: 20 20 20 20 33 20 27 27 0a 20 20 34 20 31 32 33      3 ''.  4 123
2200: 20 20 20 20 20 20 20 20 20 20 35 20 2d 31 32 33            5 -123
2210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2220: 36 20 30 0a 20 20 37 20 31 32 33 2e 34 20 20 20  6 0.  7 123.4   
2230: 20 20 20 20 20 38 20 30 2e 30 20 20 20 20 20 20       8 0.0      
2240: 20 20 20 20 20 20 20 20 20 20 20 39 20 2d 31 32             9 -12
2250: 33 2e 34 0a 20 31 30 20 58 27 41 42 43 44 45 46  3.4. 10 X'ABCDEF
2260: 27 20 20 20 31 31 20 58 27 27 20 20 20 20 20 20  '   11 X''      
2270: 20 20 20 20 20 20 20 20 20 20 31 32 20 58 27 30            12 X'0
2280: 30 30 30 27 0a 20 31 33 20 20 20 20 20 4e 55 4c  000'. 13     NUL
2290: 4c 0a 7d 0a 66 6f 72 65 61 63 68 20 6f 70 20 24  L.}.foreach op $
22a0: 6f 70 6c 69 73 74 20 7b 0a 20 20 66 6f 72 65 61  oplist {.  forea
22b0: 63 68 20 7b 6e 31 20 72 68 73 7d 20 24 6c 69 74  ch {n1 rhs} $lit
22c0: 65 72 61 6c 73 20 7b 20 0a 20 20 66 6f 72 65 61  erals { .  forea
22d0: 63 68 20 7b 6e 32 20 6c 68 73 7d 20 24 6c 69 74  ch {n2 lhs} $lit
22e0: 65 72 61 6c 73 20 7b 0a 0a 20 20 20 20 73 65 74  erals {..    set
22f0: 20 74 20 5b 64 62 20 6f 6e 65 20 22 20 53 45 4c   t [db one " SEL
2300: 45 43 54 20 74 79 70 65 6f 66 28 24 6c 68 73 20  ECT typeof($lhs 
2310: 24 6f 70 20 24 72 68 73 29 20 22 5d 0a 20 20 20  $op $rhs) "].   
2320: 20 64 6f 5f 74 65 73 74 20 65 5f 65 78 70 72 2d   do_test e_expr-
2330: 37 2e 24 6f 70 6e 61 6d 65 28 24 6f 70 29 2e 24  7.$opname($op).$
2340: 6e 31 2e 24 6e 32 20 7b 0a 20 20 20 20 20 20 65  n1.$n2 {.      e
2350: 78 70 72 20 7b 0a 20 20 20 20 20 20 20 20 20 20  xpr {.          
2360: 20 28 24 6f 70 3d 3d 22 7c 7c 22 20 26 26 20 28   ($op=="||" && (
2370: 24 74 20 3d 3d 20 22 74 65 78 74 22 20 7c 7c 20  $t == "text" || 
2380: 24 74 20 3d 3d 20 22 6e 75 6c 6c 22 29 29 0a 20  $t == "null")). 
2390: 20 20 20 20 20 20 20 7c 7c 20 28 24 6f 70 21 3d         || ($op!=
23a0: 22 7c 7c 22 20 26 26 20 28 24 74 20 3d 3d 20 22  "||" && ($t == "
23b0: 69 6e 74 65 67 65 72 22 20 7c 7c 20 24 74 20 3d  integer" || $t =
23c0: 3d 20 22 72 65 61 6c 22 20 7c 7c 20 24 74 20 3d  = "real" || $t =
23d0: 3d 20 22 6e 75 6c 6c 22 29 29 0a 20 20 20 20 20  = "null")).     
23e0: 20 7d 0a 20 20 20 20 7d 20 31 0a 0a 20 20 7d 7d   }.    } 1..  }}
23f0: 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .}..#-----------
2400: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2410: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2420: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2430: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23  --------------.#
2440: 20 54 65 73 74 20 74 68 65 20 49 53 20 61 6e 64   Test the IS and
2450: 20 49 53 20 4e 4f 54 20 6f 70 65 72 61 74 6f 72   IS NOT operator
2460: 73 2e 0a 23 0a 23 20 45 56 49 44 45 4e 43 45 2d  s..#.# EVIDENCE-
2470: 4f 46 3a 20 52 2d 32 34 37 33 31 2d 34 35 37 37  OF: R-24731-4577
2480: 33 20 54 68 65 20 49 53 20 61 6e 64 20 49 53 20  3 The IS and IS 
2490: 4e 4f 54 20 6f 70 65 72 61 74 6f 72 73 20 77 6f  NOT operators wo
24a0: 72 6b 20 6c 69 6b 65 20 3d 20 61 6e 64 0a 23 20  rk like = and.# 
24b0: 21 3d 20 65 78 63 65 70 74 20 77 68 65 6e 20 6f  != except when o
24c0: 6e 65 20 6f 72 20 62 6f 74 68 20 6f 66 20 74 68  ne or both of th
24d0: 65 20 6f 70 65 72 61 6e 64 73 20 61 72 65 20 4e  e operands are N
24e0: 55 4c 4c 2e 0a 23 0a 23 20 45 56 49 44 45 4e 43  ULL..#.# EVIDENC
24f0: 45 2d 4f 46 3a 20 52 2d 30 36 33 32 35 2d 31 35  E-OF: R-06325-15
2500: 33 31 35 20 49 6e 20 74 68 69 73 20 63 61 73 65  315 In this case
2510: 2c 20 69 66 20 62 6f 74 68 20 6f 70 65 72 61 6e  , if both operan
2520: 64 73 20 61 72 65 20 4e 55 4c 4c 2c 0a 23 20 74  ds are NULL,.# t
2530: 68 65 6e 20 74 68 65 20 49 53 20 6f 70 65 72 61  hen the IS opera
2540: 74 6f 72 20 65 76 61 6c 75 61 74 65 73 20 74 6f  tor evaluates to
2550: 20 31 20 28 74 72 75 65 29 20 61 6e 64 20 74 68   1 (true) and th
2560: 65 20 49 53 20 4e 4f 54 20 6f 70 65 72 61 74 6f  e IS NOT operato
2570: 72 0a 23 20 65 76 61 6c 75 61 74 65 73 20 74 6f  r.# evaluates to
2580: 20 30 20 28 66 61 6c 73 65 29 2e 0a 23 0a 23 20   0 (false)..#.# 
2590: 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d 31  EVIDENCE-OF: R-1
25a0: 39 38 31 32 2d 33 36 37 37 39 20 49 66 20 6f 6e  9812-36779 If on
25b0: 65 20 6f 70 65 72 61 6e 64 20 69 73 20 4e 55 4c  e operand is NUL
25c0: 4c 20 61 6e 64 20 74 68 65 20 6f 74 68 65 72 20  L and the other 
25d0: 69 73 0a 23 20 6e 6f 74 2c 20 74 68 65 6e 20 74  is.# not, then t
25e0: 68 65 20 49 53 20 6f 70 65 72 61 74 6f 72 20 65  he IS operator e
25f0: 76 61 6c 75 61 74 65 73 20 74 6f 20 30 20 28 66  valuates to 0 (f
2600: 61 6c 73 65 29 20 61 6e 64 20 74 68 65 20 49 53  alse) and the IS
2610: 20 4e 4f 54 0a 23 20 6f 70 65 72 61 74 6f 72 20   NOT.# operator 
2620: 69 73 20 31 20 28 74 72 75 65 29 2e 0a 23 0a 23  is 1 (true)..#.#
2630: 20 45 56 49 44 45 4e 43 45 2d 4f 46 3a 20 52 2d   EVIDENCE-OF: R-
2640: 36 31 39 37 35 2d 31 33 34 31 30 20 49 74 20 69  61975-13410 It i
2650: 73 20 6e 6f 74 20 70 6f 73 73 69 62 6c 65 20 66  s not possible f
2660: 6f 72 20 61 6e 20 49 53 20 6f 72 20 49 53 20 4e  or an IS or IS N
2670: 4f 54 0a 23 20 65 78 70 72 65 73 73 69 6f 6e 20  OT.# expression 
2680: 74 6f 20 65 76 61 6c 75 61 74 65 20 74 6f 20 4e  to evaluate to N
2690: 55 4c 4c 2e 0a 23 0a 64 6f 5f 65 78 65 63 73 71  ULL..#.do_execsq
26a0: 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 38 2e  l_test e_expr-8.
26b0: 31 2e 31 20 20 7b 20 53 45 4c 45 43 54 20 4e 55  1.1  { SELECT NU
26c0: 4c 4c 20 49 53 20 20 20 20 20 4e 55 4c 4c 20 7d  LL IS     NULL }
26d0: 20 7b 31 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f   {1}.do_execsql_
26e0: 74 65 73 74 20 65 5f 65 78 70 72 2d 38 2e 31 2e  test e_expr-8.1.
26f0: 32 20 20 7b 20 53 45 4c 45 43 54 20 27 61 62 27  2  { SELECT 'ab'
2700: 20 49 53 20 20 20 20 20 4e 55 4c 4c 20 7d 20 7b   IS     NULL } {
2710: 30 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  0}.do_execsql_te
2720: 73 74 20 65 5f 65 78 70 72 2d 38 2e 31 2e 33 20  st e_expr-8.1.3 
2730: 20 7b 20 53 45 4c 45 43 54 20 4e 55 4c 4c 20 49   { SELECT NULL I
2740: 53 20 20 20 20 20 27 61 62 27 20 7d 20 7b 30 7d  S     'ab' } {0}
2750: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
2760: 20 65 5f 65 78 70 72 2d 38 2e 31 2e 34 20 20 7b   e_expr-8.1.4  {
2770: 20 53 45 4c 45 43 54 20 27 61 62 27 20 49 53 20   SELECT 'ab' IS 
2780: 20 20 20 20 27 61 62 27 20 7d 20 7b 31 7d 0a 64      'ab' } {1}.d
2790: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 65  o_execsql_test e
27a0: 5f 65 78 70 72 2d 38 2e 31 2e 35 20 20 7b 20 53  _expr-8.1.5  { S
27b0: 45 4c 45 43 54 20 4e 55 4c 4c 20 3d 3d 20 20 20  ELECT NULL ==   
27c0: 20 20 4e 55 4c 4c 20 7d 20 7b 7b 7d 7d 0a 64 6f    NULL } {{}}.do
27d0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 65 5f  _execsql_test e_
27e0: 65 78 70 72 2d 38 2e 31 2e 36 20 20 7b 20 53 45  expr-8.1.6  { SE
27f0: 4c 45 43 54 20 27 61 62 27 20 3d 3d 20 20 20 20  LECT 'ab' ==    
2800: 20 4e 55 4c 4c 20 7d 20 7b 7b 7d 7d 0a 64 6f 5f   NULL } {{}}.do_
2810: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 65 5f 65  execsql_test e_e
2820: 78 70 72 2d 38 2e 31 2e 37 20 20 7b 20 53 45 4c  xpr-8.1.7  { SEL
2830: 45 43 54 20 4e 55 4c 4c 20 3d 3d 20 20 20 20 20  ECT NULL ==     
2840: 27 61 62 27 20 7d 20 7b 7b 7d 7d 0a 64 6f 5f 65  'ab' } {{}}.do_e
2850: 78 65 63 73 71 6c 5f 74 65 73 74 20 65 5f 65 78  xecsql_test e_ex
2860: 70 72 2d 38 2e 31 2e 38 20 20 7b 20 53 45 4c 45  pr-8.1.8  { SELE
2870: 43 54 20 27 61 62 27 20 3d 3d 20 20 20 20 20 27  CT 'ab' ==     '
2880: 61 62 27 20 7d 20 7b 31 7d 0a 64 6f 5f 65 78 65  ab' } {1}.do_exe
2890: 63 73 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72  csql_test e_expr
28a0: 2d 38 2e 31 2e 39 20 20 7b 20 53 45 4c 45 43 54  -8.1.9  { SELECT
28b0: 20 4e 55 4c 4c 20 49 53 20 4e 4f 54 20 4e 55 4c   NULL IS NOT NUL
28c0: 4c 20 7d 20 7b 30 7d 0a 64 6f 5f 65 78 65 63 73  L } {0}.do_execs
28d0: 71 6c 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 38  ql_test e_expr-8
28e0: 2e 31 2e 31 30 20 7b 20 53 45 4c 45 43 54 20 27  .1.10 { SELECT '
28f0: 61 62 27 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ab' IS NOT NULL 
2900: 7d 20 7b 31 7d 0a 64 6f 5f 65 78 65 63 73 71 6c  } {1}.do_execsql
2910: 5f 74 65 73 74 20 65 5f 65 78 70 72 2d 38 2e 31  _test e_expr-8.1
2920: 2e 31 31 20 7b 20 53 45 4c 45 43 54 20 4e 55 4c  .11 { SELECT NUL
2930: 4c 20 49 53 20 4e 4f 54 20 27 61 62 27 20 7d 20  L IS NOT 'ab' } 
2940: 7b 31 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  {1}.do_execsql_t
2950: 65 73 74 20 65 5f 65 78 70 72 2d 38 2e 31 2e 31  est e_expr-8.1.1
2960: 32 20 7b 20 53 45 4c 45 43 54 20 27 61 62 27 20  2 { SELECT 'ab' 
2970: 49 53 20 4e 4f 54 20 27 61 62 27 20 7d 20 7b 30  IS NOT 'ab' } {0
2980: 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  }.do_execsql_tes
2990: 74 20 65 5f 65 78 70 72 2d 38 2e 31 2e 31 33 20  t e_expr-8.1.13 
29a0: 7b 20 53 45 4c 45 43 54 20 4e 55 4c 4c 20 21 3d  { SELECT NULL !=
29b0: 20 20 20 20 20 4e 55 4c 4c 20 7d 20 7b 7b 7d 7d       NULL } {{}}
29c0: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
29d0: 20 65 5f 65 78 70 72 2d 38 2e 31 2e 31 34 20 7b   e_expr-8.1.14 {
29e0: 20 53 45 4c 45 43 54 20 27 61 62 27 20 21 3d 20   SELECT 'ab' != 
29f0: 20 20 20 20 4e 55 4c 4c 20 7d 20 7b 7b 7d 7d 0a      NULL } {{}}.
2a00: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
2a10: 65 5f 65 78 70 72 2d 38 2e 31 2e 31 35 20 7b 20  e_expr-8.1.15 { 
2a20: 53 45 4c 45 43 54 20 4e 55 4c 4c 20 21 3d 20 20  SELECT NULL !=  
2a30: 20 20 20 27 61 62 27 20 7d 20 7b 7b 7d 7d 0a 64     'ab' } {{}}.d
2a40: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 65  o_execsql_test e
2a50: 5f 65 78 70 72 2d 38 2e 31 2e 31 36 20 7b 20 53  _expr-8.1.16 { S
2a60: 45 4c 45 43 54 20 27 61 62 27 20 21 3d 20 20 20  ELECT 'ab' !=   
2a70: 20 20 27 61 62 27 20 7d 20 7b 30 7d 0a 0a 66 6f    'ab' } {0}..fo
2a80: 72 65 61 63 68 20 7b 6e 31 20 72 68 73 7d 20 24  reach {n1 rhs} $
2a90: 6c 69 74 65 72 61 6c 73 20 7b 20 0a 20 20 66 6f  literals { .  fo
2aa0: 72 65 61 63 68 20 7b 6e 32 20 6c 68 73 7d 20 24  reach {n2 lhs} $
2ab0: 6c 69 74 65 72 61 6c 73 20 7b 0a 20 20 20 20 69  literals {.    i
2ac0: 66 20 7b 24 72 68 73 21 3d 22 4e 55 4c 4c 22 20  f {$rhs!="NULL" 
2ad0: 26 26 20 24 6c 68 73 21 3d 22 4e 55 4c 4c 22 7d  && $lhs!="NULL"}
2ae0: 20 7b 0a 20 20 20 20 20 20 73 65 74 20 65 71 20   {.      set eq 
2af0: 5b 65 78 65 63 73 71 6c 20 22 53 45 4c 45 43 54  [execsql "SELECT
2b00: 20 24 6c 68 73 20 3d 20 24 72 68 73 2c 20 24 6c   $lhs = $rhs, $l
2b10: 68 73 20 21 3d 20 24 72 68 73 22 5d 0a 20 20 20  hs != $rhs"].   
2b20: 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20   } else {.      
2b30: 73 65 74 20 65 71 20 5b 6c 69 73 74 20 5b 65 78  set eq [list [ex
2b40: 70 72 20 7b 24 6c 68 73 3d 3d 22 4e 55 4c 4c 22  pr {$lhs=="NULL"
2b50: 20 26 26 20 24 72 68 73 3d 3d 22 4e 55 4c 4c 22   && $rhs=="NULL"
2b60: 7d 5d 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20  }] \.           
2b70: 20 20 20 20 20 20 20 20 5b 65 78 70 72 20 7b 24          [expr {$
2b80: 6c 68 73 21 3d 22 4e 55 4c 4c 22 20 7c 7c 20 24  lhs!="NULL" || $
2b90: 72 68 73 21 3d 22 4e 55 4c 4c 22 7d 5d 0a 20 20  rhs!="NULL"}].  
2ba0: 20 20 20 20 5d 0a 20 20 20 20 7d 0a 20 20 20 20      ].    }.    
2bb0: 73 65 74 20 74 65 73 74 20 65 5f 65 78 70 72 2d  set test e_expr-
2bc0: 38 2e 32 2e 24 6e 31 2e 24 6e 32 0a 20 20 20 20  8.2.$n1.$n2.    
2bd0: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
2be0: 24 74 65 73 74 2e 31 20 22 53 45 4c 45 43 54 20  $test.1 "SELECT 
2bf0: 24 6c 68 73 20 49 53 20 24 72 68 73 2c 20 24 6c  $lhs IS $rhs, $l
2c00: 68 73 20 49 53 20 4e 4f 54 20 24 72 68 73 22 20  hs IS NOT $rhs" 
2c10: 24 65 71 0a 20 20 20 20 64 6f 5f 65 78 65 63 73  $eq.    do_execs
2c20: 71 6c 5f 74 65 73 74 20 24 74 65 73 74 2e 32 20  ql_test $test.2 
2c30: 22 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20 28  ".      SELECT (
2c40: 24 6c 68 73 20 49 53 20 24 72 68 73 29 20 49 53  $lhs IS $rhs) IS
2c50: 20 4e 55 4c 4c 2c 20 28 24 6c 68 73 20 49 53 20   NULL, ($lhs IS 
2c60: 4e 4f 54 20 24 72 68 73 29 20 49 53 20 4e 55 4c  NOT $rhs) IS NUL
2c70: 4c 0a 20 20 20 20 22 20 7b 30 20 30 7d 0a 20 20  L.    " {0 0}.  
2c80: 7d 0a 7d 0a 0a 66 69 6e 69 73 68 5f 74 65 73 74  }.}..finish_test
2c90: 0a                                               .