// File: pranavmodx[P]modlang/test/parser_test.cpp
// Function: TestIntegerLiteralExpression()
void TestIntegerLiteralExpression()
{
	std::string input = "5;";

	Lexer lexer;
	lexer.New(input);

	Parser parser;
	parser.New(lexer);

	Program *program = parser.ParseProgram();

	checkParserErrors(parser);

	if (program == nullptr)
		std::cout << "ParseProgram() returned null" << std::endl;

	if (program->statements.size() != 1)
		std::cout << "program->statements does not contain 1 statements, got " << program->statements.size() << std::endl;

	Statement *stmt;
	ExpressionStatement *expStmt;
	IntegerLiteral *intLit;

	for (int i = 0; i < program->statements.size(); i++)
	{
		stmt = program->statements[i];

		expStmt = ((ExpressionStatement *)stmt);

		if (expStmt->tokenLiteral() != "5")
			std::cout << "stmt->tokenLiteral() not '5'"
					  << ", got " << stmt->tokenLiteral() << std::endl;

		intLit = ((IntegerLiteral *)expStmt->expression);

		if (intLit->value != 5)
			std::cout << "intLit->value not '5'"
					  << ", got " << stmt->tokenLiteral() << std::endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
leaq -0x21(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x5470
movq -0x268(%rbp), %rdx
leaq 0x18f74(%rip), %rsi     # 0x2626d
leaq -0x20(%rbp), %rdi
callq 0xdb60
jmp 0xd304
leaq -0x21(%rbp), %rdi
callq 0x52c0
leaq -0x68(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0xde70
movq -0x270(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x12480
jmp 0xd32f
leaq -0x1d8(%rbp), %rdi
callq 0x197b0
jmp 0xd33d
leaq -0x1d8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x19c70
jmp 0xd34f
leaq -0x1d8(%rbp), %rdi
callq 0x1c280
movq %rax, -0x278(%rbp)
jmp 0xd364
movq -0x278(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xd720
jmp 0xd380
cmpq $0x0, -0x1e0(%rbp)
jne 0xd3f9
movq 0x2ac3f(%rip), %rdi     # 0x37fd0
leaq 0x18d61(%rip), %rsi     # 0x260f9
callq 0x5260
movq %rax, -0x280(%rbp)
jmp 0xd3a6
movq -0x280(%rbp), %rdi
movq 0x2abf4(%rip), %rsi     # 0x37fa8
callq 0x52a0
jmp 0xd3bb
jmp 0xd3f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x52c0
jmp 0xd712
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xd700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xd6f4
movq -0x1e0(%rbp), %rdi
addq $0x8, %rdi
callq 0xde90
cmpq $0x1, %rax
je 0xd46a
movq 0x2abba(%rip), %rdi     # 0x37fd0
leaq 0x18ddc(%rip), %rsi     # 0x261f9
callq 0x5260
movq %rax, -0x288(%rbp)
jmp 0xd42b
movq -0x1e0(%rbp), %rdi
addq $0x8, %rdi
callq 0xde90
movq -0x288(%rbp), %rdi
movq %rax, %rsi
callq 0x50a0
movq %rax, -0x290(%rbp)
jmp 0xd453
movq -0x290(%rbp), %rdi
movq 0x2ab47(%rip), %rsi     # 0x37fa8
callq 0x52a0
jmp 0xd468
jmp 0xd46a
movl $0x0, -0x1fc(%rbp)
movslq -0x1fc(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x1e0(%rbp), %rdi
addq $0x8, %rdi
callq 0xde90
movq %rax, %rcx
movq -0x298(%rbp), %rax
cmpq %rcx, %rax
jae 0xd6cd
movq -0x1e0(%rbp), %rdi
addq $0x8, %rdi
movslq -0x1fc(%rbp), %rsi
callq 0xdeb0
movq (%rax), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x220(%rbp), %rdi
callq *%rax
jmp 0xd4ec
leaq 0x18d7d(%rip), %rsi     # 0x26270
leaq -0x220(%rbp), %rdi
callq 0xdf90
movb %al, -0x299(%rbp)
jmp 0xd507
leaq -0x220(%rbp), %rdi
callq 0x54d8
movb -0x299(%rbp), %al
testb $0x1, %al
jne 0xd522
jmp 0xd5eb
movq 0x2aaa7(%rip), %rdi     # 0x37fd0
leaq 0x18d42(%rip), %rsi     # 0x26272
callq 0x5260
movq %rax, -0x2a8(%rbp)
jmp 0xd53e
movq -0x2a8(%rbp), %rdi
leaq 0x18cde(%rip), %rsi     # 0x2622a
callq 0x5260
movq %rax, -0x2b0(%rbp)
jmp 0xd55a
movq -0x1e8(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x240(%rbp), %rdi
callq *%rax
jmp 0xd572
movq -0x2b0(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x5230
movq %rax, -0x2b8(%rbp)
jmp 0xd58e
movq -0x2b8(%rbp), %rdi
movq 0x2aa0c(%rip), %rsi     # 0x37fa8
callq 0x52a0
jmp 0xd5a3
leaq -0x240(%rbp), %rdi
callq 0x54d8
jmp 0xd5eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x54d8
jmp 0xd6f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x54d8
jmp 0xd6f4
movq -0x1f0(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rax
cmpl $0x5, 0x48(%rax)
je 0xd6b7
movq 0x2a9bb(%rip), %rdi     # 0x37fd0
leaq 0x18c73(%rip), %rsi     # 0x2628f
callq 0x5260
movq %rax, -0x2c0(%rbp)
jmp 0xd62a
movq -0x2c0(%rbp), %rdi
leaq 0x18bf2(%rip), %rsi     # 0x2622a
callq 0x5260
movq %rax, -0x2c8(%rbp)
jmp 0xd646
movq -0x1e8(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x260(%rbp), %rdi
callq *%rax
jmp 0xd65e
movq -0x2c8(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x5230
movq %rax, -0x2d0(%rbp)
jmp 0xd67a
movq -0x2d0(%rbp), %rdi
movq 0x2a920(%rip), %rsi     # 0x37fa8
callq 0x52a0
jmp 0xd68f
leaq -0x260(%rbp), %rdi
callq 0x54d8
jmp 0xd6b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x54d8
jmp 0xd6f4
jmp 0xd6b9
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0xd474
leaq -0x1d8(%rbp), %rdi
callq 0xdef0
leaq -0x68(%rbp), %rdi
callq 0xdf70
leaq -0x20(%rbp), %rdi
callq 0x54d8
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
leaq -0x1d8(%rbp), %rdi
callq 0xdef0
leaq -0x68(%rbp), %rdi
callq 0xdf70
leaq -0x20(%rbp), %rdi
callq 0x54d8
movq -0x30(%rbp), %rdi
callq 0x5460
nopl (%rax,%rax)