UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

41 lines (33 loc) 1.27 kB
/** * @fileoverview Debug token stream behavior */ import { describe, expect, it } from 'vitest'; import { OrdoJSLexer } from './lexer.js'; describe('Debug Token Stream', () => { it('should verify token stream current position tracking', () => { const source = ` component TestComponent { markup { <div>Hello World</div> } } `; const lexer = new OrdoJSLexer(source, 'test.ordo'); const tokens = lexer.tokenize(); console.log('Initial current position:', tokens.current); console.log('Initial peek:', tokens.peek()); // Advance a few tokens and check position console.log('\nAdvancing through tokens:'); for (let i = 0; i < 5; i++) { const token = tokens.advance(); console.log(`Step ${i + 1}: advanced to token "${token.value}" (${token.type}), current position: ${tokens.current}`); console.log(` Now peeking at: "${tokens.peek().value}" (${tokens.peek().type})`); } // Test accessing tokens by index console.log('\nDirect token access:'); console.log('Token at index 12:', tokens.tokens[12]); console.log('Token at index 13:', tokens.tokens[13]); console.log('Token at index 14:', tokens.tokens[14]); expect(true).toBe(true); }); });