zz-scratch3.test.ts 627 B

1234567891011121314
  1. import { describe, it, beforeAll } from 'vitest';
  2. import { extractFromSource } from '../src/extraction';
  3. import { initGrammars, loadAllGrammars } from '../src/extraction/grammars';
  4. beforeAll(async () => { await initGrammars(); await loadAllGrammars(); });
  5. describe('d', () => { it('n', () => {
  6. const code = `struct V {
  7. int x;
  8. operator bool() const { return x != 0; }
  9. V operator+(const V& o) const { return V{x+o.x}; }
  10. V& operator=(const V& o) { x = o.x; return *this; }
  11. };`;
  12. const r = extractFromSource('t.cpp', code);
  13. console.log('NODES', r.nodes.map((n: any) => `${n.kind}:${JSON.stringify(n.name)}`));
  14. }); });