// File: pfnet-research[P]pml/src/test.cpp
// Function: parsing_deptype_test::parsing_deptype_test()
PML_TEST(parsing_deptype_test) {
    std::unordered_map<std::string, std::string> inputs = {
        {"{n:int|true} -> {x:bool|x}", "Dep([Ref(n, Int, Top)], Ref(x, Bool, x))"},
        {"(int, int) -> int", "Dep([Ref(@blah, Int, Top), Ref(@blah, Int, Top)], Ref(@blah, Int, Top))"}
    };
    for (auto const& input : inputs) {
        parser::parse_deptype(input.first).case_of(
            ok >> [&](ast::dependent_type_t const& ty) {
                assert_eq(
                    ast::to_debug_string(ty),
                    input.second);
            },
            error >> [&](parser::error_t err) {
                assert_(false, format("parse error at {} : {}",
                        std::to_string(err.pos), err.message));
            });
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x71f20
movq -0x190(%rbp), %rax
leaq 0x7815b(%rip), %rcx     # 0xe6a48
movq %rcx, (%rax)
leaq -0xd0(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
leaq 0x314b2(%rip), %rsi     # 0x9fdb7
leaq 0x314c6(%rip), %rdx     # 0x9fdd2
callq 0x81c10
jmp 0x6e913
leaq -0x90(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
leaq 0x314d3(%rip), %rsi     # 0x9fdfb
leaq 0x314de(%rip), %rdx     # 0x9fe0d
callq 0x81cf0
jmp 0x6e936
leaq -0xd0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x2, -0x48(%rbp)
leaq -0xe7(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x7ff10
movq -0x198(%rbp), %rcx
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %ecx
leaq -0x40(%rbp), %rdi
leaq -0xe5(%rbp), %r8
leaq -0xe6(%rbp), %r9
callq 0x7ff30
jmp 0x6e98e
leaq -0xe7(%rbp), %rdi
callq 0x7ff90
leaq -0xd0(%rbp), %rax
movq %rax, -0x1a8(%rbp)
addq $0x80, %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x7fee0
movq -0x1a8(%rbp), %rcx
movq -0x1b0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1a0(%rbp)
jne 0x6e9b5
leaq -0x40(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x7ffb0
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x7ffe0
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x80010
testb $0x1, %al
jne 0x6ea33
jmp 0x6ec14
leaq -0xf8(%rbp), %rdi
callq 0x80040
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x3fc20
jmp 0x6ea5b
movq -0x190(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq 0x314e5(%rip), %rdi     # 0x9ff63
leaq -0x178(%rbp), %rsi
callq 0x68b40
movq %rax, -0x1b8(%rbp)
jmp 0x6ea93
movq -0x190(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movq %rax, -0x188(%rbp)
leaq 0x314ae(%rip), %rdi     # 0x9ff64
leaq -0x188(%rbp), %rsi
callq 0x68b60
movq %rax, -0x1c0(%rbp)
jmp 0x6eacb
movq -0x1c0(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x81dd0
jmp 0x6eaf5
leaq -0x160(%rbp), %rdi
callq 0x41c40
leaq -0xf8(%rbp), %rdi
callq 0x80100
jmp 0x6ea17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
movq -0xd8(%rbp), %rax
leaq -0xd0(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x1c8(%rbp)
je 0x6eb6f
movq -0x1c8(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x7fee0
movq -0x1d0(%rbp), %rax
leaq -0xd0(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x1c8(%rbp)
jne 0x6eb3e
jmp 0x6ec2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0xe7(%rbp), %rdi
callq 0x7ff90
leaq -0xd0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
addq $0x80, %rax
movq %rax, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x7fee0
movq -0x1e0(%rbp), %rcx
movq -0x1e8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1d8(%rbp)
jne 0x6ebad
jmp 0x6ec2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x6ec26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x41c40
jmp 0x6ec26
leaq -0x40(%rbp), %rdi
callq 0x80130
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x80130
movq -0x190(%rbp), %rdi
callq 0x71f80
movq -0xe0(%rbp), %rdi
callq 0xa650
nopw (%rax,%rax)