Esempio n. 1
0
TEST(TestLiteralExpression, testDictionaryLiteral2)
{
    PARSE_STATEMENT(L"[5 : 1]");
    ASSERT_NOT_NULL(root);
    DictionaryLiteralPtr d = std::dynamic_pointer_cast<DictionaryLiteral>(root);
    ASSERT_NOT_NULL(d);
    ASSERT_EQ(1, d->numElements());

}
Esempio n. 2
0
TEST(TestDeclaration, testLet_Multiple)
{
    PARSE_STATEMENT(L"let a=[k1 : 1, k2 : 2], b : Int = 2");
    ValueBindingsPtr c;
    ValueBindingPtr b;
    IdentifierPtr id;
    TypeIdentifierPtr Int;
    DictionaryLiteralPtr dict;
    ASSERT_NOT_NULL(c = std::dynamic_pointer_cast<ValueBindings>(root));
    ASSERT_TRUE(c->isReadOnly());
    ASSERT_EQ(2, c->numBindings());
    ASSERT_NOT_NULL(id = std::dynamic_pointer_cast<Identifier>(c->get(0)->getName()));
    ASSERT_EQ(L"a", id->getIdentifier());
    ASSERT_NOT_NULL(dict = std::dynamic_pointer_cast<DictionaryLiteral>(c->get(0)->getInitializer()));
    ASSERT_EQ(2, dict->numElements());

    ASSERT_NOT_NULL(b = c->get(1));
    ASSERT_NOT_NULL(id = std::dynamic_pointer_cast<Identifier>(b->getName()));
    ASSERT_EQ(L"b", id->getIdentifier());
    ASSERT_NOT_NULL(Int = std::dynamic_pointer_cast<TypeIdentifier>(b->getDeclaredType()));
    ASSERT_EQ(L"Int", Int->getName());

}