lua.test.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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('lua', [
  7. // Keywords
  8. [
  9. {
  10. line: 'local x, y = 1, 10',
  11. tokens: [
  12. { startIndex: 0, type: 'keyword.local.lua' },
  13. { startIndex: 5, type: '' },
  14. { startIndex: 6, type: 'identifier.lua' },
  15. { startIndex: 7, type: 'delimiter.lua' },
  16. { startIndex: 8, type: '' },
  17. { startIndex: 9, type: 'identifier.lua' },
  18. { startIndex: 10, type: '' },
  19. { startIndex: 11, type: 'delimiter.lua' },
  20. { startIndex: 12, type: '' },
  21. { startIndex: 13, type: 'number.lua' },
  22. { startIndex: 14, type: 'delimiter.lua' },
  23. { startIndex: 15, type: '' },
  24. { startIndex: 16, type: 'number.lua' }
  25. ]
  26. }
  27. ],
  28. [
  29. {
  30. line: 'foo = "Hello" .. "World"; local foo = foo',
  31. tokens: [
  32. { startIndex: 0, type: 'identifier.lua' },
  33. { startIndex: 3, type: '' },
  34. { startIndex: 4, type: 'delimiter.lua' },
  35. { startIndex: 5, type: '' },
  36. { startIndex: 6, type: 'string.lua' },
  37. { startIndex: 13, type: '' },
  38. { startIndex: 14, type: 'delimiter.lua' },
  39. { startIndex: 16, type: '' },
  40. { startIndex: 17, type: 'string.lua' },
  41. { startIndex: 24, type: 'delimiter.lua' },
  42. { startIndex: 25, type: '' },
  43. { startIndex: 26, type: 'keyword.local.lua' },
  44. { startIndex: 31, type: '' },
  45. { startIndex: 32, type: 'identifier.lua' },
  46. { startIndex: 35, type: '' },
  47. { startIndex: 36, type: 'delimiter.lua' },
  48. { startIndex: 37, type: '' },
  49. { startIndex: 38, type: 'identifier.lua' }
  50. ]
  51. }
  52. ],
  53. // Comments
  54. [
  55. {
  56. line: '--[[ text ]] x',
  57. tokens: [
  58. { startIndex: 0, type: 'comment.lua' },
  59. { startIndex: 12, type: '' },
  60. { startIndex: 13, type: 'identifier.lua' }
  61. ]
  62. }
  63. ],
  64. [
  65. {
  66. line: '--[===[ text ]===] x',
  67. tokens: [
  68. { startIndex: 0, type: 'comment.lua' },
  69. { startIndex: 18, type: '' },
  70. { startIndex: 19, type: 'identifier.lua' }
  71. ]
  72. }
  73. ],
  74. [
  75. {
  76. line: '--[===[ text ]==] x',
  77. tokens: [{ startIndex: 0, type: 'comment.lua' }]
  78. }
  79. ]
  80. ]);