Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain.cpp
Context not available. | |||||
1359 | QCOMPARE(fun->defaultParameters()[1].str(), QString("null")); | 1359 | QCOMPARE(fun->defaultParameters()[1].str(), QString("null")); | ||
---|---|---|---|---|---|
1360 | } | 1360 | } | ||
1361 | 1361 | | |||
1362 | void TestDUChain::defaultFunctionParamWithTypehint() { | ||||
1363 | QByteArray method("<? function foo(array $i = array()) { } "); | ||||
1364 | | ||||
1365 | TopDUContext* top = parse(method, DumpAll); | ||||
1366 | DUChainReleaser releaseTop(top); | ||||
1367 | | ||||
1368 | DUChainWriteLocker lock(DUChain::lock()); | ||||
1369 | | ||||
1370 | FunctionType::Ptr fun = top->localDeclarations().first()->type<FunctionType>(); | ||||
1371 | QVERIFY(fun); | ||||
1372 | QCOMPARE(fun->arguments().count(), 1); | ||||
1373 | | ||||
1374 | IntegralType::Ptr argType = IntegralType::Ptr::dynamicCast(fun->arguments().first()); | ||||
1375 | QVERIFY(argType); | ||||
1376 | QVERIFY(argType->dataType() == IntegralType::TypeArray); | ||||
1377 | } | ||||
1378 | | ||||
1379 | void TestDUChain::nullDefaultFunctionParamWithTypehint() | ||||
1380 | { | ||||
1381 | // 0 1 2 3 4 5 6 7 | ||||
1382 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
1383 | QByteArray method("<? function foo(array $i = null) { } "); | ||||
1384 | | ||||
1385 | TopDUContext* top = parse(method, DumpAll); | ||||
1386 | DUChainReleaser releaseTop(top); | ||||
1387 | | ||||
1388 | DUChainWriteLocker lock(DUChain::lock()); | ||||
1389 | | ||||
1390 | FunctionType::Ptr fun = top->localDeclarations().first()->type<FunctionType>(); | ||||
1391 | QVERIFY(fun); | ||||
1392 | QCOMPARE(fun->arguments().count(), 1); | ||||
1393 | | ||||
1394 | UnsureType::Ptr argType = UnsureType::Ptr::dynamicCast(fun->arguments().first()); | ||||
1395 | QVERIFY(argType); | ||||
1396 | QCOMPARE(argType->typesSize(), 2u); | ||||
1397 | QVERIFY(argType->types()[0].abstractType().cast<IntegralType>()); | ||||
1398 | QVERIFY(argType->types()[0].abstractType().cast<IntegralType>()->dataType() == IntegralType::TypeArray); | ||||
1399 | QVERIFY(argType->types()[1].abstractType().cast<IntegralType>()); | ||||
1400 | QVERIFY(argType->types()[1].abstractType().cast<IntegralType>()->dataType() == IntegralType::TypeNull); | ||||
1401 | } | ||||
1402 | | ||||
1362 | void TestDUChain::globalFunction() | 1403 | void TestDUChain::globalFunction() | ||
1363 | { | 1404 | { | ||
1364 | // 0 1 2 3 4 5 6 7 | 1405 | // 0 1 2 3 4 5 6 7 | ||
Context not available. |