redis.test.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import { testTokenization } from '../test/testRunner';
  6. testTokenization('redis', [
  7. // Numbers
  8. [
  9. {
  10. line: '123',
  11. tokens: [{ startIndex: 0, type: 'number.redis' }]
  12. }
  13. ],
  14. [
  15. {
  16. line: '-123',
  17. tokens: [
  18. { startIndex: 0, type: 'operator.redis' },
  19. { startIndex: 1, type: 'number.redis' }
  20. ]
  21. }
  22. ],
  23. [
  24. {
  25. line: '0xaBc123',
  26. tokens: [{ startIndex: 0, type: 'number.redis' }]
  27. }
  28. ],
  29. [
  30. {
  31. line: '0XaBc123',
  32. tokens: [{ startIndex: 0, type: 'number.redis' }]
  33. }
  34. ],
  35. [
  36. {
  37. line: '0x',
  38. tokens: [{ startIndex: 0, type: 'number.redis' }]
  39. }
  40. ],
  41. [
  42. {
  43. line: '0x0',
  44. tokens: [{ startIndex: 0, type: 'number.redis' }]
  45. }
  46. ],
  47. [
  48. {
  49. line: '0xAB_CD',
  50. tokens: [
  51. { startIndex: 0, type: 'number.redis' },
  52. { startIndex: 4, type: 'identifier.redis' }
  53. ]
  54. }
  55. ],
  56. [
  57. {
  58. line: '$',
  59. tokens: [{ startIndex: 0, type: 'number.redis' }]
  60. }
  61. ],
  62. [
  63. {
  64. line: '$-123',
  65. tokens: [{ startIndex: 0, type: 'number.redis' }]
  66. }
  67. ],
  68. [
  69. {
  70. line: '$-+-123',
  71. tokens: [{ startIndex: 0, type: 'number.redis' }]
  72. }
  73. ],
  74. [
  75. {
  76. line: '$123.5678',
  77. tokens: [{ startIndex: 0, type: 'number.redis' }]
  78. }
  79. ],
  80. [
  81. {
  82. line: '$0.99',
  83. tokens: [{ startIndex: 0, type: 'number.redis' }]
  84. }
  85. ],
  86. [
  87. {
  88. line: '$.99',
  89. tokens: [{ startIndex: 0, type: 'number.redis' }]
  90. }
  91. ],
  92. [
  93. {
  94. line: '$99.',
  95. tokens: [{ startIndex: 0, type: 'number.redis' }]
  96. }
  97. ],
  98. [
  99. {
  100. line: '$0.',
  101. tokens: [{ startIndex: 0, type: 'number.redis' }]
  102. }
  103. ],
  104. [
  105. {
  106. line: '$.0',
  107. tokens: [{ startIndex: 0, type: 'number.redis' }]
  108. }
  109. ],
  110. [
  111. {
  112. line: '.',
  113. tokens: [{ startIndex: 0, type: 'delimiter.redis' }]
  114. }
  115. ],
  116. [
  117. {
  118. line: '123',
  119. tokens: [{ startIndex: 0, type: 'number.redis' }]
  120. }
  121. ],
  122. [
  123. {
  124. line: '123.5678',
  125. tokens: [{ startIndex: 0, type: 'number.redis' }]
  126. }
  127. ],
  128. [
  129. {
  130. line: '0.99',
  131. tokens: [{ startIndex: 0, type: 'number.redis' }]
  132. }
  133. ],
  134. [
  135. {
  136. line: '.99',
  137. tokens: [{ startIndex: 0, type: 'number.redis' }]
  138. }
  139. ],
  140. [
  141. {
  142. line: '99.',
  143. tokens: [{ startIndex: 0, type: 'number.redis' }]
  144. }
  145. ],
  146. [
  147. {
  148. line: '0.',
  149. tokens: [{ startIndex: 0, type: 'number.redis' }]
  150. }
  151. ],
  152. [
  153. {
  154. line: '.0',
  155. tokens: [{ startIndex: 0, type: 'number.redis' }]
  156. }
  157. ],
  158. [
  159. {
  160. line: '1E-2',
  161. tokens: [{ startIndex: 0, type: 'number.redis' }]
  162. }
  163. ],
  164. [
  165. {
  166. line: '1E+2',
  167. tokens: [{ startIndex: 0, type: 'number.redis' }]
  168. }
  169. ],
  170. [
  171. {
  172. line: '1E2',
  173. tokens: [{ startIndex: 0, type: 'number.redis' }]
  174. }
  175. ],
  176. [
  177. {
  178. line: '0.1E2',
  179. tokens: [{ startIndex: 0, type: 'number.redis' }]
  180. }
  181. ],
  182. [
  183. {
  184. line: '1.E2',
  185. tokens: [{ startIndex: 0, type: 'number.redis' }]
  186. }
  187. ],
  188. [
  189. {
  190. line: '.1E2',
  191. tokens: [{ startIndex: 0, type: 'number.redis' }]
  192. }
  193. ],
  194. // Strings
  195. [
  196. {
  197. line: 'SET key1 "Hello"',
  198. tokens: [
  199. { startIndex: 0, type: 'keyword.redis' },
  200. { startIndex: 3, type: 'white.redis' },
  201. { startIndex: 4, type: 'identifier.redis' },
  202. { startIndex: 8, type: 'white.redis' },
  203. { startIndex: 9, type: 'string.double.redis' }
  204. ]
  205. }
  206. ],
  207. [
  208. {
  209. line: "SET key1 'Hello'",
  210. tokens: [
  211. { startIndex: 0, type: 'keyword.redis' },
  212. { startIndex: 3, type: 'white.redis' },
  213. { startIndex: 4, type: 'identifier.redis' },
  214. { startIndex: 8, type: 'white.redis' },
  215. { startIndex: 9, type: 'string.redis' }
  216. ]
  217. }
  218. ],
  219. // Commands
  220. [
  221. {
  222. line: 'DEL key1 key2 key3',
  223. tokens: [
  224. { startIndex: 0, type: 'keyword.redis' },
  225. { startIndex: 3, type: 'white.redis' },
  226. { startIndex: 4, type: 'identifier.redis' },
  227. { startIndex: 8, type: 'white.redis' },
  228. { startIndex: 9, type: 'identifier.redis' },
  229. { startIndex: 13, type: 'white.redis' },
  230. { startIndex: 14, type: 'identifier.redis' }
  231. ]
  232. }
  233. ],
  234. [
  235. {
  236. line: 'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
  237. tokens: [
  238. { startIndex: 0, type: 'keyword.redis' },
  239. { startIndex: 6, type: 'white.redis' },
  240. { startIndex: 7, type: 'identifier.redis' },
  241. { startIndex: 13, type: 'white.redis' },
  242. { startIndex: 14, type: 'number.redis' },
  243. { startIndex: 23, type: 'white.redis' },
  244. { startIndex: 24, type: 'number.redis' },
  245. { startIndex: 33, type: 'white.redis' },
  246. { startIndex: 34, type: 'string.double.redis' },
  247. { startIndex: 43, type: 'white.redis' },
  248. { startIndex: 44, type: 'number.redis' },
  249. { startIndex: 53, type: 'white.redis' },
  250. { startIndex: 54, type: 'number.redis' },
  251. { startIndex: 63, type: 'white.redis' },
  252. { startIndex: 64, type: 'string.double.redis' }
  253. ]
  254. }
  255. ],
  256. [
  257. {
  258. line: 'HGET myhash field1',
  259. tokens: [
  260. { startIndex: 0, type: 'keyword.redis' },
  261. { startIndex: 4, type: 'white.redis' },
  262. { startIndex: 5, type: 'identifier.redis' },
  263. { startIndex: 11, type: 'white.redis' },
  264. { startIndex: 12, type: 'identifier.redis' }
  265. ]
  266. }
  267. ]
  268. ]);