From bbf514474b2664779229b919b54b4c541157c1d3 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 19 Aug 2009 16:11:03 +0200 Subject: add more detailed tests for QRegExp <--> JS RegExp conversion --- tests/auto/qscriptengine/tst_qscriptengine.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index b1e2599..994a244 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1958,9 +1958,27 @@ void tst_QScriptEngine::valueConversion() QRegExp in = QRegExp("foo"); QScriptValue val = qScriptValueFromValue(&eng, in); QVERIFY(val.isRegExp()); - QEXPECT_FAIL("", "RegExp <--> ScriptValue RegExp conversion is buggy", Continue); + QRegExp out = val.toRegExp(); + QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::patternSyntax (always uses RegExp2)", Continue); + QCOMPARE(out.patternSyntax(), in.patternSyntax()); + QCOMPARE(out.pattern(), in.pattern()); + QCOMPARE(out.caseSensitivity(), in.caseSensitivity()); + QCOMPARE(out.isMinimal(), in.isMinimal()); + } + { + QRegExp in = QRegExp("foo", Qt::CaseSensitive, QRegExp::RegExp2); + QScriptValue val = qScriptValueFromValue(&eng, in); + QVERIFY(val.isRegExp()); QCOMPARE(val.toRegExp(), in); } + { + QRegExp in = QRegExp("foo"); + in.setMinimal(true); + QScriptValue val = qScriptValueFromValue(&eng, in); + QVERIFY(val.isRegExp()); + QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::minimal (always false)", Continue); + QCOMPARE(val.toRegExp().isMinimal(), in.isMinimal()); + } } static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng) -- cgit v0.12