python.test.ts 2.5 KB

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