Changeset View
Changeset View
Standalone View
Standalone View
tests/auto/qmljsc/testasttoir.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 48 | public: | |||
---|---|---|---|---|---|
49 | static MockModuleLoader *create(IR::Module *module) | 49 | static MockModuleLoader *create(IR::Module *module) | ||
50 | { | 50 | { | ||
51 | return new MockModuleLoader(module); | 51 | return new MockModuleLoader(module); | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | bool canLoad() override | 54 | bool canLoad() override | ||
55 | { | 55 | { | ||
56 | if (module()->name() == "QtQuick" | 56 | if (module()->name() == "QtQuick" | ||
57 | && module()->importDescription().versionMajor == 2 | 57 | && module()->versionMajor() == 2 | ||
58 | && module()->importDescription().versionMinor <= 1) { | 58 | && module()->versionMinor() <= 1) { | ||
59 | return true; | 59 | return true; | ||
60 | } | 60 | } | ||
61 | if (module()->name() == "QtQuick.Controls" | 61 | if (module()->name() == "QtQuick.Controls" | ||
62 | && module()->importDescription().versionMajor == 1 | 62 | && module()->versionMajor() == 1 | ||
63 | && module()->importDescription().versionMinor <= 3) { | 63 | && module()->versionMinor() <= 3) { | ||
64 | return true; | 64 | return true; | ||
65 | } | 65 | } | ||
66 | if (module()->name() == "IExistInVersionTwoOne" | 66 | if (module()->name() == "IExistInVersionTwoOne" | ||
67 | && module()->importDescription().versionMajor == 2 | 67 | && module()->versionMajor() == 2 | ||
68 | && module()->importDescription().versionMinor <= 1) { | 68 | && module()->versionMinor() <= 1) { | ||
69 | return true; | 69 | return true; | ||
70 | } | 70 | } | ||
71 | return false; | 71 | return false; | ||
72 | 72 | | |||
73 | } | 73 | } | ||
74 | void doLoad() override | 74 | void doLoad() override | ||
75 | { | 75 | { | ||
76 | module()->setLoadingState(IR::Module::Successful); | 76 | module()->setLoadingState(IR::Module::Successful); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 117 | private: | |||
133 | IR::Type *m_oreganoType; | 133 | IR::Type *m_oreganoType; | ||
134 | IR::Type *m_uninstantiableType; | 134 | IR::Type *m_uninstantiableType; | ||
135 | }; | 135 | }; | ||
136 | 136 | | |||
137 | TestAstToIR::TestAstToIR() | 137 | TestAstToIR::TestAstToIR() | ||
138 | : QObject() | 138 | : QObject() | ||
139 | , m_lexer(&m_engine) | 139 | , m_lexer(&m_engine) | ||
140 | , m_parser(&m_engine) | 140 | , m_parser(&m_engine) | ||
141 | , m_pizzaModule({IR::ImportDescription::Kind_ModuleImport, "Pizzeria", 1, 0}) | 141 | , m_pizzaModule("Pizzeria", 1, 0) | ||
142 | { | 142 | { | ||
143 | ModuleLoading::registerModuleLoader(&MockModuleLoader::create); | 143 | ModuleLoading::registerModuleLoader(&MockModuleLoader::create); | ||
144 | 144 | | |||
145 | m_toppingType = new IR::Type("Topping", "QWTopping", IR::Type::Flags(IR::Type::IsInstantiable)); | 145 | m_toppingType = new IR::Type("Topping", "QWTopping", IR::Type::Flags(IR::Type::IsInstantiable)); | ||
146 | m_pizzaModule.addType(m_toppingType); | 146 | m_pizzaModule.addType(m_toppingType); | ||
147 | 147 | | |||
148 | m_pizzaType = new IR::Type("Pizza", "QWPizza", IR::Type::Flags(IR::Type::IsInstantiable) ); | 148 | m_pizzaType = new IR::Type("Pizza", "QWPizza", IR::Type::Flags(IR::Type::IsInstantiable) ); | ||
149 | IR::Property *p = m_pizzaType->addProperty("topping"); | 149 | IR::Property *p = m_pizzaType->addProperty("topping"); | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 218 | { | |||
221 | QFETCH(int, majorVersion); | 221 | QFETCH(int, majorVersion); | ||
222 | QFETCH(int, minorVersion); | 222 | QFETCH(int, minorVersion); | ||
223 | QFETCH(QString, prefix); | 223 | QFETCH(QString, prefix); | ||
224 | 224 | | |||
225 | m_lexer.setCode(qml, 1, true); | 225 | m_lexer.setCode(qml, 1, true); | ||
226 | m_parser.parse(); | 226 | m_parser.parse(); | ||
227 | AST::cast<AST::UiProgram*>(m_parser.rootNode())->headers->headerItem->accept(&m_pass); | 227 | AST::cast<AST::UiProgram*>(m_parser.rootNode())->headers->headerItem->accept(&m_pass); | ||
228 | 228 | | |||
229 | const QVector<IR::File::ModuleData> &importedModules = m_pass.m_file->importedModules(); | 229 | const QVector<IR::Import> &importedModules = m_pass.m_file->importedModules(); | ||
230 | QCOMPARE(importedModules.count(), 1); | 230 | QCOMPARE(importedModules.count(), 1); | ||
231 | QVERIFY(importedModules.first().module); | 231 | QVERIFY(importedModules.first().module()); | ||
232 | QCOMPARE(importedModules.first().module->name(), moduleName); | 232 | QCOMPARE(importedModules.first().module()->name(), moduleName); | ||
233 | QCOMPARE(importedModules.first().module->importDescription().versionMajor, majorVersion); | 233 | QCOMPARE(importedModules.first().module()->versionMajor(), majorVersion); | ||
234 | QCOMPARE(importedModules.first().module->importDescription().versionMinor, minorVersion); | 234 | QCOMPARE(importedModules.first().module()->versionMinor(), minorVersion); | ||
235 | QCOMPARE(importedModules.first().localPrefix, prefix); | 235 | QCOMPARE(importedModules.first().localPrefix(), prefix); | ||
236 | } | 236 | } | ||
237 | 237 | | |||
238 | void TestAstToIR::init() | 238 | void TestAstToIR::init() | ||
239 | { | 239 | { | ||
240 | m_pass.m_file = new IR::File; | 240 | m_pass.m_file = new IR::File; | ||
241 | m_pass.m_stack << m_pass.m_file; | 241 | m_pass.m_stack << m_pass.m_file; | ||
242 | } | 242 | } | ||
243 | 243 | | |||
▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines |