Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain.cpp
Show First 20 Lines • Show All 560 Lines • ▼ Show 20 Line(s) | 549 | { | |||
---|---|---|---|---|---|
561 | 561 | | |||
562 | //function a | 562 | //function a | ||
563 | // FIXME | 563 | // FIXME | ||
564 | QEXPECT_FAIL("", "This test fails after porting the plugin to KF5.", Abort); | 564 | QEXPECT_FAIL("", "This test fails after porting the plugin to KF5.", Abort); | ||
565 | QVERIFY(/* func a (this) */ ctx->localDeclarations().at(0)->type<FunctionType>().data() == ctx->owner()->abstractType().data()); | 565 | QVERIFY(/* func a (this) */ ctx->localDeclarations().at(0)->type<FunctionType>().data() == ctx->owner()->abstractType().data()); | ||
566 | QVERIFY(/* func b (self) */ ctx->localDeclarations().at(1)->type<FunctionType>().data() == ctx->owner()->abstractType().data()); | 566 | QVERIFY(/* func b (self) */ ctx->localDeclarations().at(1)->type<FunctionType>().data() == ctx->owner()->abstractType().data()); | ||
567 | } | 567 | } | ||
568 | 568 | | |||
569 | void TestDUChain::declarationReturnTypeTypehint() | ||||
570 | { | ||||
571 | //Typehint preferred over phpdoc preferred over inferred type | ||||
572 | QByteArray method("<? /** @return string **/ function foo(): bool { return 5; }"); | ||||
573 | | ||||
574 | TopDUContext* top = parse(method, DumpNone); | ||||
575 | DUChainReleaser releaseTop(top); | ||||
576 | DUChainWriteLocker lock(DUChain::lock()); | ||||
577 | | ||||
578 | QVERIFY(!top->parentContext()); | ||||
579 | QCOMPARE(top->childContexts().count(), 2); | ||||
580 | QCOMPARE(top->localDeclarations().count(), 1); | ||||
581 | | ||||
582 | FunctionType::Ptr fun = top->localDeclarations().first()->type<FunctionType>(); | ||||
583 | QVERIFY(fun); | ||||
584 | IntegralType::Ptr returnType = IntegralType::Ptr::dynamicCast(fun->returnType()); | ||||
585 | QVERIFY(returnType); | ||||
586 | QVERIFY(returnType->dataType() == IntegralType::TypeBoolean); | ||||
587 | } | ||||
588 | | ||||
589 | void TestDUChain::declarationReturnTypeTypehintVoid() | ||||
590 | { | ||||
591 | //Typehint preferred over phpdoc preferred over inferred type | ||||
592 | QByteArray method("<? /** @return string **/ function foo(): void { return 5; }"); | ||||
593 | | ||||
594 | TopDUContext* top = parse(method, DumpNone); | ||||
595 | DUChainReleaser releaseTop(top); | ||||
596 | DUChainWriteLocker lock(DUChain::lock()); | ||||
597 | | ||||
598 | QVERIFY(!top->parentContext()); | ||||
599 | QCOMPARE(top->childContexts().count(), 2); | ||||
600 | QCOMPARE(top->localDeclarations().count(), 1); | ||||
601 | | ||||
602 | FunctionType::Ptr fun = top->localDeclarations().first()->type<FunctionType>(); | ||||
603 | QVERIFY(fun); | ||||
604 | IntegralType::Ptr returnType = IntegralType::Ptr::dynamicCast(fun->returnType()); | ||||
605 | QVERIFY(returnType); | ||||
606 | QVERIFY(returnType->dataType() == IntegralType::TypeVoid); | ||||
607 | } | ||||
608 | | ||||
569 | void TestDUChain::declareTypehintFunction() | 609 | void TestDUChain::declareTypehintFunction() | ||
570 | { | 610 | { | ||
571 | // 0 1 2 3 4 5 6 7 | 611 | // 0 1 2 3 4 5 6 7 | ||
572 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | 612 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||
573 | QByteArray method("<? class A {} function foo(A $i) { return $i; } "); | 613 | QByteArray method("<? class A {} function foo(A $i) { return $i; } "); | ||
574 | 614 | | |||
575 | TopDUContext* top = parse(method, DumpAll); | 615 | TopDUContext* top = parse(method, DumpAll); | ||
576 | DUChainReleaser releaseTop(top); | 616 | DUChainReleaser releaseTop(top); | ||
▲ Show 20 Lines • Show All 2743 Lines • Show Last 20 Lines |