Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/expressionparser.cpp
Show First 20 Lines • Show All 655 Lines • ▼ Show 20 Line(s) | 644 | { | |||
---|---|---|---|---|---|
656 | 656 | | |||
657 | ExpressionParser p(true); | 657 | ExpressionParser p(true); | ||
658 | 658 | | |||
659 | ExpressionEvaluationResult res = p.evaluateType(NSconst.toUtf8(), DUContextPointer(top), CursorInRevision(1, 0)); | 659 | ExpressionEvaluationResult res = p.evaluateType(NSconst.toUtf8(), DUContextPointer(top), CursorInRevision(1, 0)); | ||
660 | QVERIFY(res.type()); | 660 | QVERIFY(res.type()); | ||
661 | QCOMPARE(IntegralType::Ptr::staticCast(res.type())->dataType(), static_cast<uint>(IntegralType::TypeString)); | 661 | QCOMPARE(IntegralType::Ptr::staticCast(res.type())->dataType(), static_cast<uint>(IntegralType::TypeString)); | ||
662 | } | 662 | } | ||
663 | 663 | | |||
664 | void TestExpressionParser::invalidVariadicFunction_data() | ||||
665 | { | ||||
666 | QTest::addColumn<QString>("code"); | ||||
667 | | ||||
668 | QTest::newRow("defaultValue") << "<? function foo(...$i=NULL) { } \n"; | ||||
669 | | ||||
670 | QTest::newRow("multipleVariadics") << "<? function foo(...$i, ...$j) { } \n"; | ||||
671 | } | ||||
672 | | ||||
673 | void TestExpressionParser::invalidVariadicFunction() | ||||
674 | { | ||||
675 | QFETCH(QString, code); | ||||
676 | | ||||
677 | TopDUContext* top = parse(code.toUtf8(), DumpNone); | ||||
678 | DUChainReleaser releaseTop(top); | ||||
679 | DUChainWriteLocker lock; | ||||
680 | | ||||
681 | QVERIFY(!top->problems().isEmpty()); | ||||
682 | } | ||||
683 | | ||||
684 | void TestExpressionParser::invalidArgumentUnpacking() | ||||
685 | { | ||||
686 | // 0 1 2 3 4 5 6 7 | ||||
687 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | ||||
688 | QByteArray method("<? function foo($a, $b, $c){}; $d = [ 1, 2 ]; foo(...$d, $e);"); | ||||
689 | | ||||
690 | TopDUContext* top = parse(method, DumpNone); | ||||
691 | DUChainReleaser releaseTop(top); | ||||
692 | DUChainWriteLocker lock; | ||||
693 | | ||||
694 | QVERIFY(!top->problems().isEmpty()); | ||||
695 | } | ||||
696 | | ||||
664 | } | 697 | } | ||
665 | 698 | |