Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain.cpp
Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Line(s) | 569 | { | |||
---|---|---|---|---|---|
603 | QCOMPARE(top->childContexts().at(1)->localDeclarations().first()->type<StructureType>()->qualifiedIdentifier(), QualifiedIdentifier("a")); | 603 | QCOMPARE(top->childContexts().at(1)->localDeclarations().first()->type<StructureType>()->qualifiedIdentifier(), QualifiedIdentifier("a")); | ||
604 | 604 | | |||
605 | FunctionType::Ptr fType = top->localDeclarations().at(1)->type<FunctionType>(); | 605 | FunctionType::Ptr fType = top->localDeclarations().at(1)->type<FunctionType>(); | ||
606 | QVERIFY(fType); | 606 | QVERIFY(fType); | ||
607 | QVERIFY(StructureType::Ptr::dynamicCast(fType->returnType())); | 607 | QVERIFY(StructureType::Ptr::dynamicCast(fType->returnType())); | ||
608 | QCOMPARE(StructureType::Ptr::dynamicCast(fType->returnType())->qualifiedIdentifier(), QualifiedIdentifier("a")); | 608 | QCOMPARE(StructureType::Ptr::dynamicCast(fType->returnType())->qualifiedIdentifier(), QualifiedIdentifier("a")); | ||
609 | } | 609 | } | ||
610 | 610 | | |||
611 | void TestDUChain::declareVariadicFunction() | ||||
612 | { | ||||
613 | // 0 1 2 3 4 5 6 7 | ||||
614 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
615 | QByteArray method("<? function foo(...$i) { } "); | ||||
616 | | ||||
617 | TopDUContext* top = parse(method, DumpAll); | ||||
618 | DUChainReleaser releaseTop(top); | ||||
619 | | ||||
620 | DUChainWriteLocker lock(DUChain::lock()); | ||||
621 | | ||||
622 | FunctionType::Ptr fun = top->localDeclarations().first()->type<FunctionType>(); | ||||
623 | QVERIFY(fun); | ||||
624 | QCOMPARE(fun->arguments().count(), 1); | ||||
625 | QVERIFY(IntegralType::Ptr::dynamicCast(fun->arguments().first())); | ||||
626 | QVERIFY(IntegralType::Ptr::dynamicCast(fun->arguments().first())->dataType() == IntegralType::TypeArray); | ||||
627 | | ||||
628 | IntegralType::Ptr type = top->childContexts().first()->localDeclarations().first()->type<IntegralType>(); | ||||
629 | QVERIFY(type); | ||||
630 | QVERIFY(type->dataType() == IntegralType::TypeArray); | ||||
631 | } | ||||
632 | | ||||
611 | void TestDUChain::declareTypehintArrayFunction() | 633 | void TestDUChain::declareTypehintArrayFunction() | ||
612 | { | 634 | { | ||
613 | // 0 1 2 3 4 5 6 7 | 635 | // 0 1 2 3 4 5 6 7 | ||
614 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | 636 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||
615 | QByteArray method("<? function foo(array $i) { } "); | 637 | QByteArray method("<? function foo(array $i) { } "); | ||
616 | 638 | | |||
617 | TopDUContext* top = parse(method, DumpAll); | 639 | TopDUContext* top = parse(method, DumpAll); | ||
618 | DUChainReleaser releaseTop(top); | 640 | DUChainReleaser releaseTop(top); | ||
▲ Show 20 Lines • Show All 2406 Lines • Show Last 20 Lines |