python.test.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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('python', [
  8. // Keywords
  9. [{
  10. line: 'def func():',
  11. tokens: [
  12. { startIndex: 0, type: 'keyword.python' },
  13. { startIndex: 3, type: 'white.python' },
  14. { startIndex: 4, type: 'identifier.python' },
  15. { startIndex: 8, type: 'delimiter.parenthesis.python' },
  16. { startIndex: 10, type: 'delimiter.python' }
  17. ]
  18. }],
  19. [{
  20. line: 'func(str Y3)',
  21. tokens: [
  22. { startIndex: 0, type: 'identifier.python' },
  23. { startIndex: 4, type: 'delimiter.parenthesis.python' },
  24. { startIndex: 5, type: 'keyword.python' },
  25. { startIndex: 8, type: 'white.python' },
  26. { startIndex: 9, type: 'identifier.python' },
  27. { startIndex: 11, type: 'delimiter.parenthesis.python' }
  28. ]
  29. }],
  30. [{
  31. line: '@Dec0_rator:',
  32. tokens: [
  33. { startIndex: 0, type: 'tag.python' },
  34. { startIndex: 11, type: 'delimiter.python' }
  35. ]
  36. }],
  37. // Comments
  38. [{
  39. line: ' # Comments! ## "jfkd" ',
  40. tokens: [
  41. { startIndex: 0, type: 'white.python' },
  42. { startIndex: 1, type: 'comment.python' }
  43. ]
  44. }],
  45. // Strings
  46. [{
  47. line: '\'s0\'',
  48. tokens: [
  49. { startIndex: 0, type: 'string.escape.python' },
  50. { startIndex: 1, type: 'string.python' },
  51. { startIndex: 3, type: 'string.escape.python' }
  52. ]
  53. }],
  54. [{
  55. line: '"\' " "',
  56. tokens: [
  57. { startIndex: 0, type: 'string.escape.python' },
  58. { startIndex: 1, type: 'string.python' },
  59. { startIndex: 3, type: 'string.escape.python' },
  60. { startIndex: 4, type: 'white.python' },
  61. { startIndex: 5, type: 'string.escape.python' }
  62. ]
  63. }],
  64. [{
  65. line: '\'\'\'Lots of string\'\'\'',
  66. tokens: [
  67. { startIndex: 0, type: 'string.python' }
  68. ]
  69. }],
  70. [{
  71. line: '"""Lots \'\'\' \'\'\'"""',
  72. tokens: [
  73. { startIndex: 0, type: 'string.python' }
  74. ]
  75. }],
  76. [{
  77. line: '\'\'\'Lots \'\'\'0.3e-5',
  78. tokens: [
  79. { startIndex: 0, type: 'string.python' },
  80. { startIndex: 11, type: 'number.python' }
  81. ]
  82. }],
  83. // Numbers
  84. [{
  85. line: '0xAcBFd',
  86. tokens: [
  87. { startIndex: 0, type: 'number.hex.python' }
  88. ]
  89. }],
  90. [{
  91. line: '0x0cH',
  92. tokens: [
  93. { startIndex: 0, type: 'number.hex.python' },
  94. { startIndex: 4, type: 'identifier.python' }
  95. ]
  96. }],
  97. [{
  98. line: '456.7e-7j',
  99. tokens: [
  100. { startIndex: 0, type: 'number.python' }
  101. ]
  102. }]
  103. ]);