57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
///|
|
|
test "parse_type" {
|
|
inspect(parse_type([Unit, EOF]), content="(Unit, [EOF])")
|
|
inspect(parse_type([Bool, EOF]), content="(Bool, [EOF])")
|
|
inspect(parse_type([Int, EOF]), content="(Int, [EOF])")
|
|
inspect(parse_type([Double, EOF]), content="(Double, [EOF])")
|
|
inspect(
|
|
parse_type([Array, LBracket, Int, RBracket, EOF]),
|
|
content="(Array(Int), [EOF])",
|
|
)
|
|
inspect(
|
|
parse_type([LParen, Int, Comma, Bool, RParen, EOF]),
|
|
content="(Tuple([Int, Bool]), [EOF])",
|
|
)
|
|
inspect(
|
|
parse_type([LParen, Int, RParen, EOF]),
|
|
content="(Tuple([Int]), [EOF])",
|
|
)
|
|
inspect(
|
|
parse_type([LParen, Int, Comma, Bool, RParen, Arrow, Double, EOF]),
|
|
content="(Function([Int, Bool], Double), [EOF])",
|
|
)
|
|
inspect(
|
|
parse_type([UpperIdentifier("MyType"), EOF]),
|
|
content=(
|
|
#|(UserDefined("MyType"), [EOF])
|
|
),
|
|
)
|
|
inspect(
|
|
parse_type([
|
|
UpperIdentifier("A"),
|
|
LBracket,
|
|
UpperIdentifier("B"),
|
|
RBracket,
|
|
EOF,
|
|
]),
|
|
content=(
|
|
#|(Generic("A", UserDefined("B")), [EOF])
|
|
),
|
|
)
|
|
inspect(
|
|
parse_type([
|
|
UpperIdentifier("A"),
|
|
LBracket,
|
|
UpperIdentifier("B"),
|
|
LBracket,
|
|
UpperIdentifier("C"),
|
|
RBracket,
|
|
RBracket,
|
|
EOF,
|
|
]),
|
|
content=(
|
|
#|(Generic("A", Generic("B", UserDefined("C"))), [EOF])
|
|
),
|
|
)
|
|
}
|