Skip to content

Commit

Permalink
test: add test for numbers with exponent and decimal point
Browse files Browse the repository at this point in the history
  • Loading branch information
magraina committed Nov 7, 2024
1 parent 564699f commit a3948a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lexical-analysis/lexical-analyser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ describe('lexicalAnalyser', () => {
assert.deepStrictEqual(tokens[2], { column: 3, line: 1, type: 'number', value: '456.789' });
});
it('should identify numbers with exponent', () => {
const code = '123e4 456e-4 789E4 456e+4';
const code = '123e4 456e-4 789E4 456e+4 56.12e4';

const tokens = lexicalAnalyser(code);

assert.strictEqual(tokens.length, 4);
assert.strictEqual(tokens.length, 5);
assert.deepStrictEqual(tokens[0], { column: 1, line: 1, type: 'number', value: '123e4' });
assert.deepStrictEqual(tokens[1], { column: 2, line: 1, type: 'number', value: '456e-4' });
assert.deepStrictEqual(tokens[2], { column: 3, line: 1, type: 'number', value: '789E4' });
assert.deepStrictEqual(tokens[3], { column: 4, line: 1, type: 'number', value: '456e+4' });
assert.deepStrictEqual(tokens[4], { column: 5, line: 1, type: 'number', value: '56.12e4' });
});
});
describe('identifiers', () => {
Expand Down

0 comments on commit a3948a0

Please sign in to comment.