// File: /workspace/github_c_makefile_star2_O2/dalnefre[P]kernel_abe/kernel.c
// Function: test_kernel
void
test_kernel()
{
	SOURCE* src;
	CONS* expr;
	CONS* expect;

	DBUG_ENTER("test_kernel");
	TRACE(printf("--test_kernel--\n"));

	/*
	 * test character source
	 */
	src = string_source(NULL);
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("");
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source(" ");
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER(32));
	assert(expr == NUMBER(' '));
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("()");
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER('('));
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER(')'));
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("\r\n");
	expr = read_sexpr(src);
	expect = NUMBER(EOF);
	assert(equal(expect, expr));

	src = string_source("()");
	expr = read_sexpr(src);
	expect = a_nil;
	assert(equal(expect, expr));
/*
	src = string_source("(x)");
	expr = read_sexpr(src);
	expect = pr(ATOM("x"), NIL);
	assert(equal(expect, expr));

	src = string_source("(x y)");
	expr = read_sexpr(src);
	expect = pr(ATOM("x"), pr(ATOM("y"), NIL));
	assert(equal(expect, expr));
*/
	src = string_source("(x (y");
	expr = read_sexpr(src);
	expect = NUMBER(EOF);
	assert(equal(expect, expr));

	/*
	 * #inert
	 * ==> #inert
	 */
	expr = a_inert;
	expect = a_inert;
	assert_eval(expr, expect);

	/*
	 * (boolean? #t #f)
	 * ==> #t
	 */
	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("boolean?")),
		ACTOR(pair_type, pr(
			a_true,
			ACTOR(pair_type, pr(
				a_false,
				a_nil))))));
	expect = a_true;
	assert_eval(expr, expect);

	/*
	 * (ignore? #ignore #inert)
	 * ==> #f
	 */
	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("ignore?")),
		ACTOR(pair_type, pr(
			a_ignore,
			ACTOR(pair_type, pr(
				a_inert,
				a_nil))))));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * (($vau (x) #ignore x) y)
	 * ==> y
	 */
	expr = read_sexpr(string_source(
		"(($vau (x) #ignore x) y)"));
/*	expr = ACTOR(pair_type, pr(
		ACTOR(pair_type, pr(
			get_symbol(ATOM("$vau")),
			ACTOR(pair_type, pr(
				ACTOR(pair_type, pr(
					get_symbol(ATOM("x")),
					a_nil)),
				ACTOR(pair_type, pr(
					a_ignore,
					ACTOR(pair_type, pr(
						get_symbol(ATOM("x")),
						a_nil)))))))),
		ACTOR(pair_type, pr(
			get_symbol(ATOM("y")),
			a_nil)))); */
	expect = get_symbol(ATOM("y"));
	assert_eval(expr, expect);

	/*
	 * (list #t #f)
	 */
/*	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("list")),
		ACTOR(pair_type, pr(
			a_true,
			ACTOR(pair_type, pr(
				a_false,
				a_nil))))));
	expect = a_true;
	assert_eval(expr, expect);
*/
	/*
	 * ($sequence
	 *		($define! y #t)
	 *		(($lambda (x) x) y))
	 * ==> #t
	 */
	expr = read_sexpr(string_source(
"($sequence \n\
	($define! y #t) \n\
	(($lambda (x) x) y))\n\
"));
/*	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("$sequence")),
		ACTOR(pair_type, pr(
			ACTOR(pair_type, pr(
				get_symbol(ATOM("$define!")),
				ACTOR(pair_type, pr(
					get_symbol(ATOM("y")),
					ACTOR(pair_type, pr(
						a_true,
						a_nil)))))),
			ACTOR(pair_type, pr(
				ACTOR(pair_type, pr(
					ACTOR(pair_type, pr(
						get_symbol(ATOM("$lambda")),
						ACTOR(pair_type, pr(
							ACTOR(pair_type, pr(
								get_symbol(ATOM("x")),
								a_nil)),
							ACTOR(pair_type, pr(
								get_symbol(ATOM("x")),
								a_nil)))))),
					ACTOR(pair_type, pr(
						get_symbol(ATOM("y")),
						a_nil)))),
				a_nil)))))); */
	expect = a_true;
	assert_eval(expr, expect);

	/*
	 * (eq? #f (boolean? #t #f))
	 * ==> #f
	 */
	expr = read_sexpr(string_source(
		"(eq? #f (boolean? #t #f))"));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * ($if #t
	 *		($if #f
	 *			0
	 *			42)
	 *		314)
	 * ==> 42
	 */
	expr = read_sexpr(string_source(
"($if #t \n\
	($if #f \n\
		0 \n\
		42) \n\
	314)\n\
"));
	expect = get_const(NUMBER(42));
	assert_eval(expr, expect);

	/*
	 * (eq? (cons 0 (cons 1 ())) (list 0 1))
	 * ==> #f  ; equal?, but not eq?
	 */
	expr = read_sexpr(string_source(
		"(eq? (cons 0 (cons 1 ())) (list 0 1))"));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * ($sequence
	 *		(write (cons (list #t #f #inert #ignore) (cons 0 1)))
	 *		(newline))
	 * ==> #t
	 */
	expr = read_sexpr(string_source(
"($sequence \n\
	(write (cons (list #t #f #inert #ignore) (cons 0 1))) \n\
	(newline))"
));
	expect = a_true;
	assert_eval(expr, expect);
	
	/*
	 * (($lambda ((#ignore . x)) x) (cons 0 1))
	 * ==> 1
	 */
	expr = read_sexpr(string_source(
		"(($lambda ((#ignore . x)) x) (cons 0 1))"));
	expect = get_const(NUMBER(1));
	assert_eval(expr, expect);

/* ...ADD TESTS HERE... */

#if 1
	cfg_force_gc(CFG);			/* clean up garbage created by tests */
#endif

	DBUG_RETURN;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
leaq 0x1828f(%rip), %rax     # 0x1c295
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x2031b(%rip), %rax     # 0x24330
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0xbd3, 0xc(%rdi)       # imm = 0xBD3
leaq 0x1831a(%rip), %rcx     # 0x1c34a
movq %rcx, 0x10(%rdi)
leaq 0x20115(%rip), %rcx     # 0x24150
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x1b079
leaq 0x18b6c(%rip), %rdi     # 0x1cbbb
callq 0x20a0
xorl %edi, %edi
callq 0x29ec
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x2031d(%rip), %rax     # 0x24388
jne 0x4477
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4496
leaq 0x182c2(%rip), %rdi     # 0x1c34a
callq 0x29ec
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x202eb(%rip), %rax     # 0x24388
jne 0x44b5
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x44d4
leaq 0x1a70e(%rip), %rdi     # 0x1e7c8
callq 0x29ec
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x202b1(%rip), %rax     # 0x24380
jne 0x44f3
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0x83, %rax
jne 0x4512
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x20294(%rip), %rax     # 0x24388
jne 0x4531
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4550
leaq 0x1804c(%rip), %rdi     # 0x1c15d
callq 0x29ec
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x2025a(%rip), %rax     # 0x24380
jne 0x456f
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa3, %rax
jne 0x458e
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x20235(%rip), %rax     # 0x24380
jne 0x45ad
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa7, %rax
jne 0x45cc
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x20218(%rip), %rax     # 0x24388
jne 0x45eb
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x460a
leaq 0x181bb(%rip), %rdi     # 0x1c348
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
pushq $-0x1
popq %rdi
movq %rax, %rsi
callq 0x1942d
testq %rax, %rax
je 0x4629
leaq 0x17fa8(%rip), %rdi     # 0x1c15d
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq 0x201cf(%rip), %rdi     # 0x24398
movq %rax, %rsi
callq 0x1942d
testq %rax, %rax
je 0x4648
leaq 0x1817e(%rip), %rdi     # 0x1c35f
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
pushq $-0x1
popq %rdi
movq %rax, %rsi
callq 0x1942d
testq %rax, %rax
je 0x4667
movq 0x2019f(%rip), %rdi     # 0x243a8
movq %rdi, %rsi
callq 0x4686
movq 0x20188(%rip), %r14     # 0x243a0
leaq 0x18146(%rip), %rdi     # 0x1c365
callq 0x1691f
movq %rax, %rdi
callq 0x3adf
movq %rax, %r15
movq 0x2016a(%rip), %r12     # 0x243a0
movq 0x2014b(%rip), %r13     # 0x24388
movq 0x2013c(%rip), %rdi     # 0x24380
movq 0x2014d(%rip), %rsi     # 0x24398
callq 0x19164
leaq -0xbec(%rip), %rbx      # 0x366b
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq %r13, %rdi
movq %rax, %rsi
callq 0x19164
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq %r15, %rdi
movq %rax, %rsi
callq 0x19164
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq 0x200ea(%rip), %rsi     # 0x24388
movq %rax, %rdi
callq 0x4686
movq 0x200f3(%rip), %r14     # 0x243a0
leaq 0x180ba(%rip), %rdi     # 0x1c36e
callq 0x1691f
movq %rax, %rdi
callq 0x3adf
movq %rax, %r15
movq 0x200d5(%rip), %r12     # 0x243a0
movq 0x200de(%rip), %r13     # 0x243b0
movq 0x200cf(%rip), %rdi     # 0x243a8
movq 0x200b8(%rip), %rsi     # 0x24398
callq 0x19164
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq %r13, %rdi
movq %rax, %rsi
callq 0x19164
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq %r15, %rdi
movq %rax, %rsi
callq 0x19164
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x123b7
movq 0x20054(%rip), %rsi     # 0x24380
movq %rax, %rdi
callq 0x4686
leaq 0x1803b(%rip), %rdi     # 0x1c376
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq %rax, %rbx
leaq 0x18011(%rip), %rdi     # 0x1c363
callq 0x1691f
movq %rax, %rdi
callq 0x3adf
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4686
leaq 0x1801e(%rip), %rdi     # 0x1c38f
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq 0x20003(%rip), %rsi     # 0x24388
movq %rax, %rdi
callq 0x4686
leaq 0x18030(%rip), %rdi     # 0x1c3c4
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq 0x1ffd8(%rip), %rsi     # 0x24380
movq %rax, %rdi
callq 0x4686
leaq 0x18027(%rip), %rdi     # 0x1c3de
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq %rax, %rbx
movl $0xab, %edi
callq 0x3968
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4686
leaq 0x18021(%rip), %rdi     # 0x1c404
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq 0x1ff89(%rip), %rsi     # 0x24380
movq %rax, %rdi
callq 0x4686
leaq 0x18024(%rip), %rdi     # 0x1c42a
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq 0x1ff6e(%rip), %rsi     # 0x24388
movq %rax, %rdi
callq 0x4686
leaq 0x18051(%rip), %rdi     # 0x1c47a
callq 0x29ec
movq %rax, %rdi
callq 0x2f66
movq %rax, %rbx
pushq $0x7
popq %rdi
callq 0x3968
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4686
movq 0x1ff4d(%rip), %rdi     # 0x243a0
callq 0x11fab
leaq 0x8(%rsp), %rdi
movl $0xcbd, 0xc(%rdi)       # imm = 0xCBD
callq 0x1b1f2
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x17e23(%rip), %rdi     # 0x1c2a1
leaq 0x17b97(%rip), %rsi     # 0x1c01c
leaq 0x17e31(%rip), %rcx     # 0x1c2bd
movl $0xbda, %edx            # imm = 0xBDA
callq 0x2100
leaq 0x17e33(%rip), %rdi     # 0x1c2d0
leaq 0x17b78(%rip), %rsi     # 0x1c01c
leaq 0x17e12(%rip), %rcx     # 0x1c2bd
movl $0xbdb, %edx            # imm = 0xBDB
callq 0x2100
leaq 0x17de5(%rip), %rdi     # 0x1c2a1
leaq 0x17b59(%rip), %rsi     # 0x1c01c
leaq 0x17df3(%rip), %rcx     # 0x1c2bd
movl $0xbde, %edx            # imm = 0xBDE
callq 0x2100
leaq 0x17df5(%rip), %rdi     # 0x1c2d0
leaq 0x17b3a(%rip), %rsi     # 0x1c01c
leaq 0x17dd4(%rip), %rcx     # 0x1c2bd
movl $0xbdf, %edx            # imm = 0xBDF
callq 0x2100
leaq 0x17df6(%rip), %rdi     # 0x1c2f0
leaq 0x17b1b(%rip), %rsi     # 0x1c01c
leaq 0x17db5(%rip), %rcx     # 0x1c2bd
movl $0xbe2, %edx            # imm = 0xBE2
callq 0x2100
leaq 0x17df4(%rip), %rdi     # 0x1c30d
leaq 0x17afc(%rip), %rsi     # 0x1c01c
leaq 0x17d96(%rip), %rcx     # 0x1c2bd
movl $0xbe4, %edx            # imm = 0xBE4
callq 0x2100
leaq 0x17d69(%rip), %rdi     # 0x1c2a1
leaq 0x17add(%rip), %rsi     # 0x1c01c
leaq 0x17d77(%rip), %rcx     # 0x1c2bd
movl $0xbe6, %edx            # imm = 0xBE6
callq 0x2100
leaq 0x17d79(%rip), %rdi     # 0x1c2d0
leaq 0x17abe(%rip), %rsi     # 0x1c01c
leaq 0x17d58(%rip), %rcx     # 0x1c2bd
movl $0xbe7, %edx            # imm = 0xBE7
callq 0x2100
leaq 0x17d7a(%rip), %rdi     # 0x1c2f0
leaq 0x17a9f(%rip), %rsi     # 0x1c01c
leaq 0x17d39(%rip), %rcx     # 0x1c2bd
movl $0xbea, %edx            # imm = 0xBEA
callq 0x2100
leaq 0x17d8b(%rip), %rdi     # 0x1c320
leaq 0x17a80(%rip), %rsi     # 0x1c01c
leaq 0x17d1a(%rip), %rcx     # 0x1c2bd
movl $0xbec, %edx            # imm = 0xBEC
callq 0x2100
leaq 0x17d3c(%rip), %rdi     # 0x1c2f0
leaq 0x17a61(%rip), %rsi     # 0x1c01c
leaq 0x17cfb(%rip), %rcx     # 0x1c2bd
movl $0xbed, %edx            # imm = 0xBED
callq 0x2100
leaq 0x17d61(%rip), %rdi     # 0x1c334
leaq 0x17a42(%rip), %rsi     # 0x1c01c
leaq 0x17cdc(%rip), %rcx     # 0x1c2bd
movl $0xbef, %edx            # imm = 0xBEF
callq 0x2100
leaq 0x17caf(%rip), %rdi     # 0x1c2a1
leaq 0x17a23(%rip), %rsi     # 0x1c01c
leaq 0x17cbd(%rip), %rcx     # 0x1c2bd
movl $0xbf0, %edx            # imm = 0xBF0
callq 0x2100
leaq 0x17cbf(%rip), %rdi     # 0x1c2d0
leaq 0x17a04(%rip), %rsi     # 0x1c01c
leaq 0x17c9e(%rip), %rcx     # 0x1c2bd
movl $0xbf1, %edx            # imm = 0xBF1
callq 0x2100
leaq 0x17d1b(%rip), %rdi     # 0x1c34b
leaq 0x179e5(%rip), %rsi     # 0x1c01c
leaq 0x17c7f(%rip), %rcx     # 0x1c2bd
movl $0xbf6, %edx            # imm = 0xBF6
callq 0x2100
leaq 0x17cfc(%rip), %rdi     # 0x1c34b
leaq 0x179c6(%rip), %rsi     # 0x1c01c
leaq 0x17c60(%rip), %rcx     # 0x1c2bd
movl $0xbfb, %edx            # imm = 0xBFB
callq 0x2100
leaq 0x17cdd(%rip), %rdi     # 0x1c34b
leaq 0x179a7(%rip), %rsi     # 0x1c01c
leaq 0x17c41(%rip), %rcx     # 0x1c2bd
movl $0xc0a, %edx            # imm = 0xC0A
callq 0x2100