Exemplo n.º 1
0
TEST_F(TypeParserTests, FunctionWithOnePointerParam) {
    this->setInput("(*Int) -> Void a\n");

    DataType type = this->typeParser()->parseType();

    ASSERT_EQ(DataType::Function, type.kind());
    ASSERT_EQ(1, type.parameterCount());
    ASSERT_EQ(DataType::Pointer, type.parameterAtIndex(0).kind());
    ASSERT_EQ(DataType::Integer, type.parameterAtIndex(0).subtypeAtIndex(0).kind());
    ASSERT_EQ(DataType::Kind::Void, type.returnType().kind());

    ASSERT_EQ("a", this->peek().str());
}
Exemplo n.º 2
0
TEST_F(TypeParserTests, ClosureWithOneParam) {
    this->setInput("{Int} -> Void a\n");

    DataType type = this->typeParser()->parseType();

    ASSERT_EQ(DataType::Kind::Closure, type.kind());
    ASSERT_EQ(0, type.subtypeCount());
    ASSERT_EQ(2, type.parameterCount());
    ASSERT_EQ(DataType::Integer, type.parameterAtIndex(1).kind());
    ASSERT_EQ(DataType::Kind::Void, type.returnType().kind());

    ASSERT_EQ("a", this->peek().str());
}
Exemplo n.º 3
0
TEST_F(TypeParserTests, FunctionWithTwoParams) {
    this->setInput("(Int, Float) -> Void a\n");

    DataType type = this->typeParser()->parseType();

    ASSERT_EQ(DataType::Function, type.kind());
    ASSERT_EQ(2, type.parameterCount());
    ASSERT_EQ(DataType::Integer, type.parameterAtIndex(0).kind());
    ASSERT_EQ(DataType::Float, type.parameterAtIndex(1).kind());
    ASSERT_EQ(DataType::Kind::Void, type.returnType().kind());

    ASSERT_EQ("a", this->peek().str());
}