From c518bb628897514253c83321ee0913fabf40e4bf Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Mon, 1 Oct 2012 18:18:59 +0200 Subject: Update regex related tests of QJSEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify expected results based on ECMA-262 standard and current results of JSC. Task-number: QTBUG-27169 Change-Id: I705d474b2a62775860f6ff6eba8a0f6b28f50ff3 Reviewed-by: Jędrzej Nowacki --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'tests/auto/qml/qjsengine') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index f761339040..840030daba 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -295,13 +295,16 @@ void tst_QJSEngine::newRegExp() QVERIFY(!rexp.isUndefined()); QCOMPARE(rexp.isRegExp(), true); QCOMPARE(rexp.isObject(), true); - QEXPECT_FAIL("", "QTBUG-27169", Continue); - QVERIFY(rexp.isCallable()); // in JSC, RegExp objects are callable + QCOMPARE(rexp.isCallable(), false); // prototype should be RegExp.prototype QVERIFY(!rexp.prototype().isUndefined()); QCOMPARE(rexp.prototype().isObject(), true); - QEXPECT_FAIL("", "QTBUG-27169", Continue); - QCOMPARE(rexp.prototype().isRegExp(), false); + QCOMPARE(rexp.prototype().isRegExp(), true); + // Get [[Class]] internal property of RegExp Prototype Object. + // See ECMA-262 Section 8.6.2, "Object Internal Properties and Methods". + // See ECMA-262 Section 15.10.6, "Properties of the RegExp Prototype Object". + QJSValue r = eng.evaluate("Object.prototype.toString.call(RegExp.prototype)"); + QCOMPARE(r.toString(), QString::fromLatin1("[object RegExp]")); QCOMPARE(rexp.prototype().strictlyEquals(eng.evaluate("RegExp.prototype")), true); QCOMPARE(qjsvalue_cast(rexp).pattern(), QRegExp("foo").pattern()); @@ -340,23 +343,18 @@ void tst_QJSEngine::jsRegExp() // This is different from SpiderMonkey and old back-end. QVERIFY(!r5.strictlyEquals(r)); + // See ECMA-262 Section 15.10.4.1, "new RegExp(pattern, flags)". QJSValue r6 = rxCtor.callAsConstructor(QJSValueList() << "foo" << "bar"); QVERIFY(r6.isError()); - // QVERIFY(r6.toString().contains(QString::fromLatin1("SyntaxError"))); // Invalid regular expression flag - + QVERIFY(r6.toString().contains(QString::fromLatin1("SyntaxError"))); // Invalid regular expression flag QJSValue r7 = eng.evaluate("/foo/gimp"); - /* v8 and jsc ignores invalid flags QVERIFY(r7.isError()); QVERIFY(r7.toString().contains(QString::fromLatin1("SyntaxError"))); // Invalid regular expression flag - */ - // JSC doesn't complain about duplicate flags. QJSValue r8 = eng.evaluate("/foo/migmigmig"); - QEXPECT_FAIL("", "QTBUG-27169", Continue); - QVERIFY(r8.isRegExp()); - QEXPECT_FAIL("", "QTBUG-27169", Continue); - QCOMPARE(r8.toString(), QString::fromLatin1("/foo/gim")); + QVERIFY(r8.isError()); + QVERIFY(r8.toString().contains(QString::fromLatin1("SyntaxError"))); // Invalid regular expression flag QJSValue r9 = rxCtor.callAsConstructor(); QVERIFY(r9.isRegExp()); @@ -2622,8 +2620,7 @@ void tst_QJSEngine::qRegExpInport() rexp = eng.toScriptValue(rx); QCOMPARE(rexp.isRegExp(), true); - QEXPECT_FAIL("", "QTBUG-27169", Continue); - QVERIFY(rexp.isCallable()); + QCOMPARE(rexp.isCallable(), false); QJSValue func = eng.evaluate("(function(string, regexp) { return string.match(regexp); })"); QJSValue result = func.call(QJSValueList() << string << rexp); -- cgit v1.2.3