Correctly read files with a \0 in them

At least one test case uses this, so let's make sure
we read them correctly.

Change-Id: I9f4ea7785b5a400cd6f0b210a6a98975bbbaf7ce
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Lars Knoll 2018-10-12 22:24:58 +02:00
parent 2cc77519eb
commit 0fce92af2c
3 changed files with 4 additions and 4 deletions

View File

@ -576,7 +576,6 @@ language/expressions/tagged-template/tco-member.js strictFails
language/expressions/tagged-template/template-object-frozen-non-strict.js sloppyFails
language/expressions/tagged-template/template-object-frozen-strict.js strictFails
language/expressions/tagged-template/template-object.js fails
language/expressions/template-literal/tv-null-character-escape-sequence.js fails
language/function-code/each-param-has-own-non-shared-eval-scope.js sloppyFails
language/function-code/each-param-has-own-scope.js sloppyFails
language/function-code/eval-param-env-with-computed-key.js sloppyFails

View File

@ -494,7 +494,7 @@ void Test262Runner::writeTestExpectations()
static bool executeTest(const QByteArray &data, bool runAsModule = false, const QString &testCasePath = QString(), const QByteArray &harnessForModules = QByteArray())
{
QString testData = QString::fromUtf8(data);
QString testData = QString::fromUtf8(data.constData(), data.size());
QV4::ExecutionEngine vm;
@ -514,7 +514,7 @@ static bool executeTest(const QByteArray &data, bool runAsModule = false, const
QFile f(url.toLocalFile());
if (f.open(QIODevice::ReadOnly)) {
QByteArray content = harnessForModules + f.readAll();
module = vm.compileModule(url.toString(), QString::fromUtf8(content), QFileInfo(f).lastModified());
module = vm.compileModule(url.toString(), QString::fromUtf8(content.constData(), content.length()), QFileInfo(f).lastModified());
if (vm.hasException)
break;
vm.injectModule(module);

View File

@ -146,7 +146,8 @@ int main(int argc, char *argv[])
}
}
if (!script) {
const QString code = QString::fromUtf8(file.readAll());
QByteArray ba = file.readAll();
const QString code = QString::fromUtf8(ba.constData(), ba.length());
file.close();
script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, fn));