UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

54 lines (43 loc) 1.55 kB
/** * @fileoverview Debug lexer context switching */ import { describe, expect, it } from 'vitest'; import { OrdoJSLexer } from './lexer.js'; describe('Debug Lexer Context', () => { it('should verify lexer context switching in markup block', () => { const source = ` component TestComponent { markup { <div>Hello World</div> } } `; const lexer = new OrdoJSLexer(source, 'test.ordo'); const tokens = lexer.tokenize(); // Find the markup section const markupIndex = tokens.tokens.findIndex(t => t.type === 'MARKUP'); const markupTokens = tokens.tokens.slice(markupIndex, markupIndex + 15); console.log('Markup section tokens:'); markupTokens.forEach((token, i) => { console.log(` ${markupIndex + i}: ${token.type} = "${token.value}"`); }); // Check if HTML tokens are properly generated const hasHTMLTokens = tokens.tokens.some(t => t.type === 'HTML_TAG_OPEN' || t.type === 'HTML_TEXT' || t.type === 'HTML_TAG_CLOSE' ); console.log('Has HTML tokens:', hasHTMLTokens); expect(true).toBe(true); }); it('should test standalone HTML parsing', () => { console.log('\n--- Testing standalone HTML ---'); const htmlSource = `<div>Hello World</div>`; const lexer = new OrdoJSLexer(htmlSource, 'test.html'); const tokens = lexer.tokenize(); console.log('Standalone HTML tokens:'); tokens.tokens.forEach((token, i) => { console.log(` ${i}: ${token.type} = "${token.value}"`); }); }); });