Exemplo n.º 1
0
TEST_F(TypeParserTests, MutableBoolean) {
    this->setInput("Bool! a\n");

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

    ASSERT_EQ(DataType::Kind::Boolean, type.kind());
    EXPECT_EQ(DataType::Access::ReadWrite, type.access());

    ASSERT_EQ("a", this->peek().str());
}
Exemplo n.º 2
0
TEST_F(TypeParserTests, MutablePointerToPointerToMutableBoolean) {
    this->setInput("*!*Bool! a\n");

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

    EXPECT_EQ(DataType::Pointer, type.kind());
    EXPECT_EQ(DataType::Access::ReadWrite, type.access());
    ASSERT_EQ(1, type.subtypeCount());

    type = type.subtypeAtIndex(0);
    EXPECT_EQ(DataType::Pointer, type.kind());
    EXPECT_EQ(DataType::Access::Read, type.access());
    ASSERT_EQ(1, type.subtypeCount());

    type = type.subtypeAtIndex(0);
    EXPECT_EQ(DataType::Boolean, type.kind());
    EXPECT_EQ(DataType::Access::ReadWrite, type.access());

    ASSERT_EQ("a", this->peek().str());
}
Exemplo n.º 3
0
TEST_F(ParserTests_Types, GlobalMutableBooleanPointerToMutablePointer) {
    ASTNode* node = this->parseNode("*!*Bool! value\n");

    node = node->childAtIndex(0);

    DataType type = node->dataType();
    ASSERT_EQ("Variable Declaration", node->nodeName());
    ASSERT_EQ("value", node->name());
    EXPECT_EQ(DataType::Pointer, type.kind());
    EXPECT_EQ(DataType::Access::ReadWrite, type.access());
    ASSERT_EQ(1, node->dataType().subtypeCount());

    type = type.subtypeAtIndex(0);
    EXPECT_EQ(DataType::Pointer, type.kind());
    EXPECT_EQ(DataType::Access::Read, type.access());
    ASSERT_EQ(1, type.subtypeCount());

    type = type.subtypeAtIndex(0);
    EXPECT_EQ(DataType::Boolean, type.kind());
    EXPECT_EQ(DataType::Access::ReadWrite, type.access());
}
Exemplo n.º 4
0
TEST_F(TypeParserTests, OptionalBoolean) {
    this->setInput("Bool? a\n");

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

    EXPECT_EQ(DataType::NullablePointer, type.kind());
    EXPECT_EQ(DataType::Access::Read, type.access());
    ASSERT_EQ(1, type.subtypeCount());
    EXPECT_EQ(DataType::Boolean, type.subtypeAtIndex(0).kind());
    EXPECT_EQ(DataType::Access::Read, type.subtypeAtIndex(0).access());

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