wasm-tree-sitter-spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. const dedent = require('dedent');
  2. const path = require('path');
  3. const { Point } = require('atom');
  4. xdescribe('WASM Tree-sitter Ruby grammar', () => {
  5. beforeEach(async () => {
  6. await atom.packages.activatePackage('language-ruby');
  7. atom.config.set('core.useTreeSitterParsers', true);
  8. atom.config.set('core.useExperimentalModernTreeSitter', true);
  9. });
  10. it('tokenizes symbols', async () => {
  11. const editor = await openDocument('classes-wasm-ts.rb');
  12. normalizeTreeSitterTextData(editor, /#/).forEach(({expected, editorPosition, testPosition}) => {
  13. expect(editor.scopeDescriptorForBufferPosition(editorPosition).scopes).toSatisfy((scopes, reason) => {
  14. reason(`Expected to find scope "${expected}" but found "${scopes}"\n` +
  15. ` at class-wasm-ts.rb:${testPosition.row+1}:${testPosition.column+1}`
  16. )
  17. return scopes.indexOf(expected) !== -1
  18. })
  19. })
  20. });
  21. it('folds code', async () => {
  22. const fullPath = path.join(__dirname, 'fixtures', 'folds.rb')
  23. await runFoldsTests(fullPath, /#/)
  24. });
  25. });
  26. async function openDocument(fileName) {
  27. const fullPath = path.join(__dirname, 'fixtures', fileName)
  28. const editor = await atom.workspace.open(fullPath)
  29. await editor.languageMode.ready
  30. return editor
  31. }