Changeset View
Changeset View
Standalone View
Standalone View
duchain/tests/duchain.cpp
Show First 20 Lines • Show All 3039 Lines • ▼ Show 20 Line(s) | 3027 | { | |||
---|---|---|---|---|---|
3040 | QVERIFY(top->problems().isEmpty()); | 3040 | QVERIFY(top->problems().isEmpty()); | ||
3041 | QCOMPARE(top->localDeclarations().count(),1); | 3041 | QCOMPARE(top->localDeclarations().count(),1); | ||
3042 | 3042 | | |||
3043 | Declaration* dec = top->localDeclarations().at(0); | 3043 | Declaration* dec = top->localDeclarations().at(0); | ||
3044 | ClassDeclaration* classDec = dynamic_cast<ClassDeclaration*>(dec); | 3044 | ClassDeclaration* classDec = dynamic_cast<ClassDeclaration*>(dec); | ||
3045 | QCOMPARE(classDec->uses().count(),1); | 3045 | QCOMPARE(classDec->uses().count(),1); | ||
3046 | } | 3046 | } | ||
3047 | 3047 | | |||
3048 | void TestDUChain::functionArgumentUnpacking_data() | ||||
3049 | { | ||||
3050 | QTest::addColumn<QString>("code"); | ||||
3051 | | ||||
3052 | QTest::newRow("unpackVariable") << QStringLiteral("<? $a = [ 1,2 ];\n$b = [ 3,4 ];\nfunction aaa($c,$d,$e,$f) { }\naaa(...$a, ...$b);\n"); | ||||
3053 | | ||||
3054 | QTest::newRow("unpackLiteral") << QStringLiteral("<? function aaa($c,$d,$e,$f) { }\naaa(...[1,2], ...[3,4]);\n"); | ||||
3055 | | ||||
3056 | QTest::newRow("unpackFunction") << QStringLiteral("<? function bbb() { return [1,2,3,4]; }\nfunction aaa($c,$d,$e,$f) { }\naaa(...bbb());\n"); | ||||
3057 | } | ||||
3058 | | ||||
3048 | void TestDUChain::functionArgumentUnpacking() | 3059 | void TestDUChain::functionArgumentUnpacking() | ||
3049 | { | 3060 | { | ||
3050 | // 0 1 2 3 4 5 6 7 | 3061 | QFETCH(QString, code); | ||
3051 | // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | | |||
3052 | QByteArray method("<?php\n" | | |||
3053 | "$a = [ 1,2 ];\n" | | |||
3054 | "$b = [ 3,4 ];\n" | | |||
3055 | "function aaa($c,$d,$e,$f) { }\n" | | |||
3056 | "aaa(...$a, ...$b);\n"); | | |||
3057 | 3062 | | |||
3058 | TopDUContext* top = parse(method); | 3063 | TopDUContext* top = parse(code.toUtf8(), DumpNone); | ||
3059 | QVERIFY(top); | 3064 | QVERIFY(top); | ||
3060 | DUChainReleaser releaseTop(top); | 3065 | DUChainReleaser releaseTop(top); | ||
3061 | DUChainWriteLocker lock(DUChain::lock()); | 3066 | DUChainWriteLocker lock(DUChain::lock()); | ||
3062 | 3067 | | |||
3063 | QVERIFY(top->problems().isEmpty()); | 3068 | QVERIFY(top->problems().isEmpty()); | ||
3064 | QCOMPARE(top->localDeclarations().count(),3); | | |||
3065 | } | 3069 | } |