Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / main.cpp
blob: 8452e72d9cb38875e4f3509839568b031f3a648d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "Lexer.h"
#include <iostream>
#define LOG(msg) std::cout << msg << std::endl
void TestLess()
{
	auto tokens = Tokenize("<");
	if (tokens.size() == 2 && tokens[0].Type == TokenType::Less)
	{
		LOG("PASS");
	}
	else
	{
		LOG("FAIL");
	}
}

void TestNumber()
{
	auto tokens = Tokenize("213434.24");
	if (tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 213434.24)
	{
		LOG("PASS");
	}
	else
	{
		LOG("FAIL");
	}
}

void TestString()
{
	auto tokens = Tokenize("\"alabala\"");
	if (tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "\"alabala\"")
	{
		LOG("PASS");
	}
	else
	{
		LOG("FAIL");
	}
}

void TestKeyWord()
{
	auto tokens = Tokenize("for");
	if (tokens.size() == 2 && tokens[0].Type == TokenType::For)
	{
		LOG("PASS");
	}
	else
	{
		LOG("FAIL");
	}
}

int main()
{
	TestLess();
	TestNumber();
	TestString();
	TestKeyWord();
	return 0;
}