@ordojs/core
Version:
Core compiler and runtime for OrdoJS framework
44 lines (34 loc) • 1.35 kB
text/typescript
/**
* @fileoverview Simple OrdoJS Lexer Tests - Basic functionality tests
*/
import { describe, expect, it } from 'vitest';
import { TokenType } from '../types/index.js';
import { OrdoJSLexer } from './lexer.js';
describe('OrdoJSLexer - Basic Tests', () => {
it('should tokenize a simple identifier', () => {
const lexer = new OrdoJSLexer('hello');
const stream = lexer.tokenize();
expect(stream.tokens).toHaveLength(2); // hello, EOF
expect(stream.tokens[0].type).toBe(TokenType.IDENTIFIER);
expect(stream.tokens[0].value).toBe('hello');
expect(stream.tokens[1].type).toBe(TokenType.EOF);
});
it('should tokenize keywords', () => {
const lexer = new OrdoJSLexer('component');
const stream = lexer.tokenize();
expect(stream.tokens[0].type).toBe(TokenType.COMPONENT);
expect(stream.tokens[0].value).toBe('component');
});
it('should tokenize numbers', () => {
const lexer = new OrdoJSLexer('123');
const stream = lexer.tokenize();
expect(stream.tokens[0].type).toBe(TokenType.NUMBER);
expect(stream.tokens[0].value).toBe('123');
});
it('should tokenize strings', () => {
const lexer = new OrdoJSLexer('"hello"');
const stream = lexer.tokenize();
expect(stream.tokens[0].type).toBe(TokenType.STRING);
expect(stream.tokens[0].value).toBe('hello');
});
});