redis.test.ts 5.0 KB

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