// File: pfnet-research[P]pml/src/test.cpp
// Function: parsing_reftype_test::parsing_reftype_test()
PML_TEST(parsing_reftype_test) {
    std::unordered_map<std::string, std::string> inputs = {
        {"{x:int|true}", "Ref(x, Int, Top)"},
        {"{x:bool|x}", "Ref(x, Bool, x)"},
        {"int", "Ref(@blah, Int, Top)"},
        {"bool", "Ref(@blah, Bool, Top)"},
        {"x:int", "Ref(x, Int, Top)"},
        {"x:bool", "Ref(x, Bool, Top)"}
    };
    for (auto const& input : inputs) {
        parser::parse_reftype(input.first).case_of(
            ok >> [&](ast::refinement_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 $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x71f20
movq -0x278(%rbp), %rax
leaq 0x7861b(%rip), %rcx     # 0xe6a08
movq %rcx, (%rax)
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x3190e(%rip), %rsi     # 0x9fd13
leaq 0x31914(%rip), %rdx     # 0x9fd20
callq 0x7f9a0
jmp 0x6e413
leaq -0x190(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x3199f(%rip), %rsi     # 0x9fdc7
leaq 0x31902(%rip), %rdx     # 0x9fd31
callq 0x7fa80
jmp 0x6e436
leaq -0x150(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x319be(%rip), %rsi     # 0x9fe09
leaq 0x318ef(%rip), %rdx     # 0x9fd41
callq 0x7fb60
jmp 0x6e459
leaq -0x110(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x31906(%rip), %rsi     # 0x9fd74
leaq 0x318e1(%rip), %rdx     # 0x9fd56
callq 0x7fc40
jmp 0x6e47c
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x318db(%rip), %rsi     # 0x9fd6c
leaq 0x31888(%rip), %rdx     # 0x9fd20
callq 0x7fd20
jmp 0x6e49f
leaq -0x90(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq 0x318be(%rip), %rsi     # 0x9fd72
leaq 0x318be(%rip), %rdx     # 0x9fd79
callq 0x7fe00
jmp 0x6e4c2
leaq -0x1d0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x6, -0x48(%rbp)
leaq -0x1e7(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x7ff10
movq -0x280(%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 -0x1e5(%rbp), %r8
leaq -0x1e6(%rbp), %r9
callq 0x7ff30
jmp 0x6e51a
leaq -0x1e7(%rbp), %rdi
callq 0x7ff90
leaq -0x1d0(%rbp), %rax
movq %rax, -0x290(%rbp)
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x298(%rbp)
callq 0x7fee0
movq -0x290(%rbp), %rcx
movq -0x298(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x288(%rbp)
jne 0x6e541
leaq -0x40(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rdi
callq 0x7ffb0
movq %rax, -0x1f8(%rbp)
movq -0x1f0(%rbp), %rdi
callq 0x7ffe0
movq %rax, -0x200(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x80010
testb $0x1, %al
jne 0x6e5bf
jmp 0x6e7a0
leaq -0x1f8(%rbp), %rdi
callq 0x80040
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0x3fbe0
jmp 0x6e5e7
movq -0x278(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq 0x31959(%rip), %rdi     # 0x9ff63
leaq -0x260(%rbp), %rsi
callq 0x685e0
movq %rax, -0x2a0(%rbp)
jmp 0x6e61f
movq -0x278(%rbp), %rax
movq -0x2a0(%rbp), %rcx
movq %rcx, -0x250(%rbp)
movq %rax, -0x270(%rbp)
leaq 0x31922(%rip), %rdi     # 0x9ff64
leaq -0x270(%rbp), %rsi
callq 0x68600
movq %rax, -0x2a8(%rbp)
jmp 0x6e657
movq -0x2a8(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
leaq -0x268(%rbp), %rdx
callq 0x80070
jmp 0x6e681
leaq -0x248(%rbp), %rdi
callq 0x41650
leaq -0x1f8(%rbp), %rdi
callq 0x80100
jmp 0x6e5a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
movq -0x1d8(%rbp), %rax
leaq -0x1d0(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x2b0(%rbp)
je 0x6e6fb
movq -0x2b0(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x7fee0
movq -0x2b8(%rbp), %rax
leaq -0x1d0(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x2b0(%rbp)
jne 0x6e6ca
jmp 0x6e7bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x1e7(%rbp), %rdi
callq 0x7ff90
leaq -0x1d0(%rbp), %rax
movq %rax, -0x2c8(%rbp)
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rdi
addq $-0x40, %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x7fee0
movq -0x2c8(%rbp), %rcx
movq -0x2d0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x2c0(%rbp)
jne 0x6e739
jmp 0x6e7bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x6e7b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x41650
jmp 0x6e7b2
leaq -0x40(%rbp), %rdi
callq 0x80130
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x80130
movq -0x278(%rbp), %rdi
callq 0x71f80
movq -0x1e0(%rbp), %rdi
callq 0xa650
nopw %cs:(%rax,%rax)
nopl (%rax)