summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-05 16:02:47 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-05 16:02:47 (GMT)
commita0fecb437176786e9c809a45e64351516b05a201 (patch)
treedba10b91d8104aad7896a766462899e589b9144b
parent43ab9a27363681c5db81004c95141b3d0695cabd (diff)
downloadQt-a0fecb437176786e9c809a45e64351516b05a201.zip
Qt-a0fecb437176786e9c809a45e64351516b05a201.tar.gz
Qt-a0fecb437176786e9c809a45e64351516b05a201.tar.bz2
RegExp.prototype.toString() when pattern is empty
Like ECMA-262 says, // starts a single-line comment; /(?:)/ represents an empty regular expression.
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/RegExpPrototype.cpp4
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpPrototype.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpPrototype.cpp
index b1ab889..e507016 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpPrototype.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/RegExpPrototype.cpp
@@ -106,6 +106,10 @@ JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec, JSObject*, JSValu
}
UString result = "/" + asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);
+#ifdef QT_BUILD_SCRIPT_LIB
+ if (result.size() == 1)
+ result.append("(?:)");
+#endif
result.append('/');
if (asRegExpObject(thisValue)->get(exec, exec->propertyNames().global).toBoolean(exec))
result.append('g');
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index ec84406..7f22316 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -508,12 +508,10 @@ void tst_QScriptEngine::newRegExp()
QScriptValue r9 = rxCtor.construct();
QVERIFY(r9.isRegExp());
- QEXPECT_FAIL("", "JSC: String representation of regexp with empty pattern is wrong", Continue);
QCOMPARE(r9.toString(), QString::fromLatin1("/(?:)/"));
QScriptValue r10 = rxCtor.construct(QScriptValueList() << "" << "gim");
QVERIFY(r10.isRegExp());
- QEXPECT_FAIL("", "JSC: String representation of regexp with empty pattern is wrong", Continue);
QCOMPARE(r10.toString(), QString::fromLatin1("/(?:)/gim"));
QScriptValue r11 = rxCtor.construct(QScriptValueList() << "{1.*}" << "g");