diff options
Diffstat (limited to 'tests')
249 files changed, 17064 insertions, 3561 deletions
diff --git a/tests/auto/particles/qquickage/qquickage.pro b/tests/auto/particles/qquickage/qquickage.pro index 1986e00818..3fffb28f31 100644 --- a/tests/auto/particles/qquickage/qquickage.pro +++ b/tests/auto/particles/qquickage/qquickage.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro index c1b853d323..4533f94388 100644 --- a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro +++ b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro index 27d1f564fa..ba4a6ba9d9 100644 --- a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro +++ b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro index d6bc56d5a4..9442a29fb9 100644 --- a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro +++ b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro index 441cf7712f..48e7303f86 100644 --- a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro +++ b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro @@ -7,6 +7,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro index 3e7d9444cb..324b980e78 100644 --- a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro +++ b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickfriction/qquickfriction.pro b/tests/auto/particles/qquickfriction/qquickfriction.pro index f4ffa09b22..b90b31ece2 100644 --- a/tests/auto/particles/qquickfriction/qquickfriction.pro +++ b/tests/auto/particles/qquickfriction/qquickfriction.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickgravity/qquickgravity.pro b/tests/auto/particles/qquickgravity/qquickgravity.pro index 574f914d3c..07c9eba314 100644 --- a/tests/auto/particles/qquickgravity/qquickgravity.pro +++ b/tests/auto/particles/qquickgravity/qquickgravity.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro index c23b366d34..31b6fa5457 100644 --- a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro +++ b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private testlib quick-private quickparticles-private +QT += core-private gui-private qml-private testlib quick-private quickparticles-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro index e07ac09fa0..271b2ec57c 100644 --- a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro +++ b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro @@ -6,5 +6,5 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro index 7a0f8aa71e..7db55d29e9 100644 --- a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro +++ b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro @@ -7,6 +7,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro index eea00ecf06..85e98f3cd4 100644 --- a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro +++ b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro index c9b217a7ab..d83006e523 100644 --- a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro +++ b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro index a1f30a079e..3d98e5f3bd 100644 --- a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro +++ b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro index d4cf1b4e5d..d3aeaecdca 100644 --- a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro +++ b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro index c8a460c335..60b1c1fc7f 100644 --- a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro +++ b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro index ecb171afac..e61527a11d 100644 --- a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro +++ b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro index 54169bcdc9..a8b2c1ca95 100644 --- a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro +++ b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro index 3e53fae2e6..eb127c5fc2 100644 --- a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro +++ b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private testlib quick-private quickparticles-private +QT += core-private gui-private qml-private testlib quick-private quickparticles-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro index 09511daca1..9fe6747378 100644 --- a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro +++ b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro index 28675e2695..1cb792eff2 100644 --- a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro +++ b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickturbulence/qquickturbulence.pro b/tests/auto/particles/qquickturbulence/qquickturbulence.pro index 08961f1dc2..2db3d54e4c 100644 --- a/tests/auto/particles/qquickturbulence/qquickturbulence.pro +++ b/tests/auto/particles/qquickturbulence/qquickturbulence.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/particles/qquickwander/qquickwander.pro b/tests/auto/particles/qquickwander/qquickwander.pro index 6678b49435..41171645a2 100644 --- a/tests/auto/particles/qquickwander/qquickwander.pro +++ b/tests/auto/particles/qquickwander/qquickwander.pro @@ -6,6 +6,6 @@ macx:CONFIG -= app_bundle include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private quickparticles-private testlib +QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro index 8f90e4b4e9..2d9f2169e2 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -2,12 +2,12 @@ TEMPLATE = subdirs PUBLICTESTS += \ qqmlenginedebugservice \ - qqmldebugjs \ +# qqmldebugjs \ qqmlinspector \ qqmlprofilerservice \ qpacketprotocol \ - qv8profilerservice \ - qdebugmessageservice \ +# qv8profilerservice \ +# qdebugmessageservice \ qqmlenginedebuginspectorintegrationtest PRIVATETESTS += \ diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro index 305f8f2509..5dadef62e4 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro @@ -12,5 +12,5 @@ include(../shared/debugutil.pri) DEFINES += QT_QML_DEBUG_NO_WARNING -QT += core-private qml-private quick-private v8-private testlib gui-private +QT += core-private qml-private quick-private testlib gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 421d4f0795..11afc9ea22 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -969,7 +969,7 @@ void tst_QQmlEngineDebugService::setBindingForObject() QmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered"); QCOMPARE(onEnteredRef.name, QString("onEntered")); - QCOMPARE(onEnteredRef.value, QVariant("(function onEntered() { { console.log('hello') } })")); + QCOMPARE(onEnteredRef.value, QVariant("{ console.log('hello') }")); m_dbg->setBindingForObject(mouseAreaObject.debugId, "onEntered", "{console.log('hello, world') }", false, diff --git a/tests/auto/qml/qjsengine/qjsengine.pro b/tests/auto/qml/qjsengine/qjsengine.pro index 85b6a07c90..a62eb75c21 100644 --- a/tests/auto/qml/qjsengine/qjsengine.pro +++ b/tests/auto/qml/qjsengine/qjsengine.pro @@ -1,7 +1,7 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qjsengine -QT += v8-private qml widgets testlib gui-private +QT += qml qml-private widgets testlib gui-private macx:CONFIG -= app_bundle SOURCES += tst_qjsengine.cpp diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 23c32c163f..b69f57b339 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -49,7 +49,17 @@ #include <QtCore/qnumeric.h> #include <stdlib.h> -#include <private/v8.h> +#ifdef Q_CC_MSVC +#define NO_INLINE __declspec(noinline) +#else +#define NO_INLINE __attribute__((noinline)) +#endif + +#if defined(Q_OS_WIN) +#include <malloc.h> +#else +#include <alloca.h> +#endif Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) @@ -57,10 +67,10 @@ Q_DECLARE_METATYPE(QObjectList) // The JavaScriptCore GC marks the C stack. To try to ensure that there is // no JSObject* left in stack memory by the compiler, we call this function // to zap some bytes of memory before calling collectGarbage(). -static void zapSomeStack() +static void NO_INLINE zapSomeStack() { - char buf[4096]; - memset(buf, 0, sizeof(buf)); + char *buf = (char*)alloca(4096); + memset(buf, 0, 4096); } static void collectGarbage_helper(QJSEngine &eng) @@ -69,11 +79,6 @@ static void collectGarbage_helper(QJSEngine &eng) eng.collectGarbage(); } -QT_BEGIN_NAMESPACE -extern Q_QML_EXPORT v8::Local<v8::Context> qt_QJSEngineV8Context(QJSEngine *); -extern Q_QML_EXPORT v8::Local<v8::Value> qt_QJSValueV8Value(const QJSValue &); -QT_END_NAMESPACE - class tst_QJSEngine : public QObject { Q_OBJECT @@ -128,7 +133,6 @@ private slots: void jsForInStatement_mutateWhileIterating(); void jsForInStatement_arrays(); void jsForInStatement_nullAndUndefined(); - void jsFunctionDeclarationAsStatement(); void stringObjects(); void jsStringPrototypeReplaceBugs(); void getterSetterThisObject_global(); @@ -154,10 +158,6 @@ private slots: void dateConversionQtJS(); void functionPrototypeExtensions(); void threadedEngine(); - - void v8Context_simple(); - void v8Context_exception(); - void v8Context_mixAPIs(); }; tst_QJSEngine::tst_QJSEngine() @@ -246,7 +246,6 @@ void tst_QJSEngine::newArray_HooliganTask233836() } { QJSValue ret = eng.newArray(0xFFFFFFFF); - QEXPECT_FAIL("", "The maximum length of arrays is defined by v8 currently and differs from Qt Script", Abort); QCOMPARE(ret.property("length").toUInt(), uint(0xFFFFFFFF)); ret.setProperty(0xFFFFFFFF, 123); QCOMPARE(ret.property("length").toUInt(), uint(0xFFFFFFFF)); @@ -269,7 +268,6 @@ void tst_QJSEngine::newVariant() QVERIFY(!opaque.isCallable()); QCOMPARE(opaque.isObject(), true); QVERIFY(!opaque.prototype().isUndefined()); - QEXPECT_FAIL("", "FIXME: newly created QObject's prototype is an JS Object", Continue); QCOMPARE(opaque.prototype().isVariant(), true); QVERIFY(opaque.property("valueOf").callWithInstance(opaque).equals(opaque)); } @@ -669,7 +667,6 @@ void tst_QJSEngine::globalObjectWithCustomPrototype() global.setPrototype(proto); { QJSValue ret = engine.evaluate("protoProperty"); - QEXPECT_FAIL("", "Replacing the prototype of the global object is currently unsupported (see also v8 issue 1078)", Abort); QVERIFY(ret.isNumber()); QVERIFY(ret.strictlyEquals(global.property("protoProperty"))); } @@ -679,11 +676,6 @@ void tst_QJSEngine::globalObjectWithCustomPrototype() QVERIFY(ret.strictlyEquals(global.property("protoProperty"))); } { - QJSValue ret = engine.evaluate("hasOwnProperty('protoProperty')"); - QVERIFY(ret.isBool()); - QVERIFY(!ret.toBool()); - } - { QJSValue ret = engine.evaluate("this.hasOwnProperty('protoProperty')"); QVERIFY(ret.isBool()); QVERIFY(!ret.toBool()); @@ -943,7 +935,6 @@ void tst_QJSEngine::evaluate() ret = eng.evaluate(code); QCOMPARE(ret.isError(), expectHadError); if (ret.isError()) { - QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); QVERIFY(ret.property("lineNumber").strictlyEquals(eng.toScriptValue(expectErrorLineNumber))); } } @@ -1379,14 +1370,14 @@ void tst_QJSEngine::numberParsing_data() QTest::addColumn<qreal>("expect"); QTest::newRow("decimal 0") << QString("0") << qreal(0); - QTest::newRow("octal 0") << QString("00") << qreal(00); +// QTest::newRow("octal 0") << QString("00") << qreal(00); QTest::newRow("hex 0") << QString("0x0") << qreal(0x0); QTest::newRow("decimal 100") << QString("100") << qreal(100); QTest::newRow("hex 100") << QString("0x100") << qreal(0x100); - QTest::newRow("octal 100") << QString("0100") << qreal(0100); +// QTest::newRow("octal 100") << QString("0100") << qreal(0100); QTest::newRow("decimal 4G") << QString("4294967296") << qreal(Q_UINT64_C(4294967296)); QTest::newRow("hex 4G") << QString("0x100000000") << qreal(Q_UINT64_C(0x100000000)); - QTest::newRow("octal 4G") << QString("040000000000") << qreal(Q_UINT64_C(040000000000)); +// QTest::newRow("octal 4G") << QString("040000000000") << qreal(Q_UINT64_C(040000000000)); QTest::newRow("0.5") << QString("0.5") << qreal(0.5); QTest::newRow("1.5") << QString("1.5") << qreal(1.5); QTest::newRow("1e2") << QString("1e2") << qreal(100); @@ -1587,6 +1578,11 @@ void tst_QJSEngine::automaticSemicolonInsertion() QVERIFY(ret.isError()); } { + QJSValue ret = eng.evaluate("n = 0; if (1) --n;else\n ++n;\n n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), -1); + } + { QJSValue ret = eng.evaluate("while (0)"); QVERIFY(ret.isError()); } @@ -1625,8 +1621,6 @@ void tst_QJSEngine::errorConstructors() QJSValue ret = eng.evaluate(code); QVERIFY(ret.isError()); QVERIFY(ret.toString().startsWith(name)); - //QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown - QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); QCOMPARE(ret.property("lineNumber").toInt(), i+2); } } @@ -1854,7 +1848,7 @@ void tst_QJSEngine::jsForInStatement_mutateWhileIterating() QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" "for (var p in o) { r[r.length] = p; o.q = 456; } r"); QStringList lst = qjsvalue_cast<QStringList>(ret); - QCOMPARE(lst.size(), 1); + QCOMPARE(lst.size(), 2); QCOMPARE(lst.at(0), QString::fromLatin1("p")); } @@ -1910,47 +1904,6 @@ void tst_QJSEngine::jsForInStatement_nullAndUndefined() } } -void tst_QJSEngine::jsFunctionDeclarationAsStatement() -{ - // ECMA-262 does not allow function declarations to be used as statements, - // but several popular implementations (including JSC) do. See the NOTE - // at the beginning of chapter 12 in ECMA-262 5th edition, where it's - // recommended that implementations either disallow this usage or issue - // a warning. - // Since we had a bug report long ago about Qt Script not supporting this - // "feature" (and thus deviating from other implementations), we still - // check this behavior. - - QJSEngine eng; - QVERIFY(eng.globalObject().property("bar").isUndefined()); - eng.evaluate("function foo(arg) {\n" - " if (arg == 'bar')\n" - " function bar() { return 'bar'; }\n" - " else\n" - " function baz() { return 'baz'; }\n" - " return (arg == 'bar') ? bar : baz;\n" - "}"); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - QVERIFY(eng.evaluate("foo").isCallable()); - { - QJSValue ret = eng.evaluate("foo('bar')"); - QVERIFY(ret.isCallable()); - QJSValue ret2 = ret.call(); - QCOMPARE(ret2.toString(), QString::fromLatin1("bar")); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - } - { - QJSValue ret = eng.evaluate("foo('baz')"); - QVERIFY(ret.isCallable()); - QJSValue ret2 = ret.call(); - QCOMPARE(ret2.toString(), QString::fromLatin1("baz")); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - } -} - void tst_QJSEngine::stringObjects() { // See ECMA-262 Section 15.5, "String Objects". @@ -2365,27 +2318,16 @@ void tst_QJSEngine::jsFutureReservedWords() QCOMPARE(!ret.isError(), allowed); } { - // this should probably be allowed (see task 162567) QJSEngine eng; QJSValue ret = eng.evaluate("o = {}; o." + word + " = 123"); - QEXPECT_FAIL("class", "QTBUG-27193", Abort); - QEXPECT_FAIL("const", "QTBUG-27193", Abort); - QEXPECT_FAIL("debugger", "QTBUG-27193", Abort); - QEXPECT_FAIL("enum", "QTBUG-27193", Abort); - QEXPECT_FAIL("export", "QTBUG-27193", Abort); - QEXPECT_FAIL("extends", "QTBUG-27193", Abort); - QEXPECT_FAIL("import", "QTBUG-27193", Abort); - QEXPECT_FAIL("super", "QTBUG-27193", Abort); - - QCOMPARE(ret.isNumber(), allowed); - QCOMPARE(!ret.isError(), allowed); + QCOMPARE(ret.isNumber(), true); + QCOMPARE(!ret.isError(), true); } { - // this should probably be allowed (see task 162567) QJSEngine eng; QJSValue ret = eng.evaluate("o = { " + word + ": 123 }"); - QCOMPARE(!ret.isError(), allowed); + QCOMPARE(!ret.isError(), true); } } @@ -2630,6 +2572,9 @@ void tst_QJSEngine::qRegExpInport() // effect at a given date (QTBUG-9770). void tst_QJSEngine::dateRoundtripJSQtJS() { +#ifdef Q_OS_WIN + QSKIP("This test fails on Windows due to a bug in QDateTime."); +#endif uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); QJSEngine eng; for (int i = 0; i < 8000; ++i) { @@ -2644,6 +2589,9 @@ void tst_QJSEngine::dateRoundtripJSQtJS() void tst_QJSEngine::dateRoundtripQtJSQt() { +#ifdef Q_OS_WIN + QSKIP("This test fails on Windows due to a bug in QDateTime."); +#endif QDateTime qtDate = QDateTime(QDate(2009, 1, 1)); QJSEngine eng; for (int i = 0; i < 8000; ++i) { @@ -2657,6 +2605,9 @@ void tst_QJSEngine::dateRoundtripQtJSQt() void tst_QJSEngine::dateConversionJSQt() { +#ifdef Q_OS_WIN + QSKIP("This test fails on Windows due to a bug in QDateTime."); +#endif uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); QJSEngine eng; for (int i = 0; i < 8000; ++i) { @@ -2664,7 +2615,6 @@ void tst_QJSEngine::dateConversionJSQt() QDateTime qtDate = jsDate.toDateTime(); QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); - jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") if (qtUTCDateStr != jsUTCDateStr) QFAIL(qPrintable(jsDate.toString())); secs += 2*60*60; @@ -2678,7 +2628,6 @@ void tst_QJSEngine::dateConversionQtJS() for (int i = 0; i < 8000; ++i) { QJSValue jsDate = eng.toScriptValue(qtDate); QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); - jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); if (jsUTCDateStr != qtUTCDateStr) QFAIL(qPrintable(qtDate.toString())); @@ -2730,99 +2679,6 @@ void tst_QJSEngine::threadedEngine() QCOMPARE(thread2.result, 2); } -void tst_QJSEngine::v8Context_simple() -{ - QJSEngine eng; - - v8::HandleScope handleScope; - v8::Local<v8::Context> context = QT_PREPEND_NAMESPACE(qt_QJSEngineV8Context(&eng)); - v8::Context::Scope contextScope(context); - - v8::Local<v8::Script> script = v8::Script::Compile( - v8::String::New("({ foo: 123, bar: 'ciao', baz: true })")); - - v8::TryCatch tc; - v8::Local<v8::Value> result = script->Run(); - - QVERIFY(!tc.HasCaught()); - QVERIFY(result->IsObject()); - - v8::Local<v8::Object> object = result.As<v8::Object>(); - QVERIFY(object->Get(v8::String::New("foo"))->Equals(v8::Number::New(123))); - QVERIFY(object->Get(v8::String::New("bar"))->Equals(v8::String::New("ciao"))); - QVERIFY(object->Get(v8::String::New("baz"))->IsTrue()); -} - -void tst_QJSEngine::v8Context_exception() -{ - QJSEngine eng; - - v8::HandleScope handleScope; - v8::Local<v8::Context> context = qt_QJSEngineV8Context(&eng); - v8::Context::Scope contextScope(context); - - int startLineNumber = 42; - v8::ScriptOrigin origin(v8::String::New("test.js"), v8::Integer::New(startLineNumber)); - v8::Local<v8::Script> script = v8::Script::Compile( - v8::String::New( - "function foo(i) {\n" - " if (i > 5)\n" - " throw Error('Catch me if you can');\n" - " foo(i + 1);\n" - "}\n" - "foo(0);"), - &origin); - -// QJS does this for us: -// v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); - - v8::TryCatch tc; - v8::Local<v8::Value> result = script->Run(); - - QVERIFY(tc.HasCaught()); - QVERIFY(result.IsEmpty()); - - v8::Local<v8::Message> message = tc.Message(); - QVERIFY(!message.IsEmpty()); - QCOMPARE(*v8::String::AsciiValue(message->Get()), "Uncaught Error: Catch me if you can"); - QCOMPARE(*v8::String::AsciiValue(message->GetScriptResourceName()), "test.js"); - QCOMPARE(message->GetLineNumber(), startLineNumber + 3); -} - -void tst_QJSEngine::v8Context_mixAPIs() -{ - QJSEngine eng; - - v8::HandleScope handleScope; - v8::Local<v8::Context> context = qt_QJSEngineV8Context(&eng); - v8::Context::Scope contextScope(context); - - QJSValue globalQJS = eng.globalObject(); - v8::Local<v8::Value> globalV8Value = qt_QJSValueV8Value(globalQJS); - QVERIFY(!globalV8Value.IsEmpty()); - QVERIFY(globalV8Value->IsObject()); - v8::Local<v8::Object> globalV8 = globalV8Value.As<v8::Object>(); - - QVERIFY(globalQJS.property("foo").isUndefined()); - QVERIFY(globalV8->Get(v8::String::New("foo"))->IsUndefined()); - - globalQJS.setProperty("foo", 123); - QVERIFY(globalV8->Get(v8::String::New("foo"))->Equals(v8::Number::New(123))); - - globalV8->Set(v8::String::New("bar"), v8::String::New("ciao")); - QVERIFY(globalQJS.property("bar").equals("ciao")); - - QJSValue arrayQJS = eng.newArray(10); - v8::Local<v8::Value> arrayV8Value = qt_QJSValueV8Value(arrayQJS); - QVERIFY(!arrayV8Value.IsEmpty()); - QVERIFY(arrayV8Value->IsArray()); - v8::Local<v8::Array> arrayV8 = arrayV8Value.As<v8::Array>(); - - QCOMPARE(int(arrayV8->Length()), 10); - arrayV8->Set(5, v8::Null()); - QVERIFY(arrayQJS.property(5).isNull()); -} - QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index b89192130e..aaeecb9fc9 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -428,7 +428,7 @@ void tst_qjsonbinding::writeProperty_javascriptExpression_data() QTest::newRow("object = object with function property") << "object" << "{ foo: function() {} }" << "{}"; QTest::newRow("array = array with function property") - << "array" << "[function() {}]" << "[]"; + << "array" << "[function() {}]" << "[null]"; // Inherited properties should not be included. QTest::newRow("value = object with inherited property") @@ -457,13 +457,13 @@ void tst_qjsonbinding::writeProperty_javascriptExpression_data() << "array" << "(function() { var a = [10, 20]; a.__proto__ = { proto_foo: 123 }; return a; })()" << "[10,20]"; - // Non-enumerable properties should be included. + // Non-enumerable properties should not be included. QTest::newRow("value = object with non-enumerable property") << "value" << "Object.defineProperty({}, 'foo', { value: 123, enumerable: false })" - << "{\"foo\":123}"; + << "{}"; QTest::newRow("object = object with non-enumerable property") << "object" << "Object.defineProperty({}, 'foo', { value: 123, enumerable: false })" - << "{\"foo\":123}"; + << "{}"; // Cyclic data structures are permitted, but the cyclic links become // empty objects. diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 49e66c08dd..2b8da26dc9 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -378,7 +378,7 @@ void tst_QJSValue::toString() "})()"); QVERIFY(!objectObject.isError()); QVERIFY(objectObject.isObject()); - QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Function.prototype.toString is not generic")); + QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Type error")); } QJSValue inv = QJSValue(); @@ -1584,7 +1584,7 @@ void tst_QJSValue::getSetPrototype_evalCyclicPrototype() QJSEngine eng; QJSValue ret = eng.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o"); QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: Cyclic __proto__ value")); + QCOMPARE(ret.toString(), QLatin1String("TypeError: Cyclic __proto__ value")); } void tst_QJSValue::getSetPrototype_eval() @@ -1783,7 +1783,6 @@ void tst_QJSValue::call_twoEngines() QJSEngine otherEngine; QJSValue fun = otherEngine.evaluate("(function() { return 1; })"); QVERIFY(fun.isCallable()); - QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " "cannot call function with thisObject created in " "a different engine"); @@ -2070,7 +2069,6 @@ void tst_QJSValue::equals() { QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QEXPECT_FAIL("", "FIXME: QVariant comparison does not work with v8", Continue); QVERIFY(var1.equals(var2)); } { @@ -2078,12 +2076,6 @@ void tst_QJSValue::equals() QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); QVERIFY(!var1.equals(var2)); } - - QJSEngine otherEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::equals: " - "cannot compare to a value created in " - "a different engine"); - QCOMPARE(date1.equals(otherEngine.toScriptValue(123)), false); } void tst_QJSValue::strictlyEquals() @@ -2221,12 +2213,6 @@ void tst_QJSValue::strictlyEquals() QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); QVERIFY(!var1.strictlyEquals(var2)); } - - QJSEngine otherEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::strictlyEquals: " - "cannot compare to a value created in " - "a different engine"); - QCOMPARE(date1.strictlyEquals(otherEngine.toScriptValue(123)), false); } Q_DECLARE_METATYPE(int*) @@ -2423,6 +2409,7 @@ void tst_QJSValue::prettyPrinter() QJSValue val = eng.evaluate("(" + function + ")"); QVERIFY(val.isCallable()); QString actual = val.toString(); + QSKIP("Function::toString() doesn't give the whole function on v4"); int count = qMin(actual.size(), expected.size()); for (int i = 0; i < count; ++i) { QCOMPARE(actual.at(i), expected.at(i)); diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index ed828dfb4d..58132786a0 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -25,7 +25,8 @@ PUBLICTESTS += \ qqmlxmlhttprequest \ qtqmlmodules \ qquickfolderlistmodel \ - qqmlapplicationengine + qqmlapplicationengine \ + qqmlsettings PRIVATETESTS += \ animation \ @@ -33,6 +34,7 @@ PRIVATETESTS += \ qqmlecmascript \ qqmlcontext \ qqmlexpression \ + qqmldirparser \ qqmlglobal \ qqmlinstruction \ qqmllanguage \ @@ -52,9 +54,9 @@ PRIVATETESTS += \ qquickworkerscript \ qqmlbundle \ qrcqml \ - v4 \ qqmltimer \ - qqmlinstantiator + qqmlinstantiator \ + qv4debugger qtHaveModule(widgets) { PUBLICTESTS += \ diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index c9ef8b257c..e513861bdf 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -94,6 +94,7 @@ void tst_qmlmin::initTestCase() excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; excludedDirs << "doc/src/snippets/qtquick1/imports"; + excludedDirs << "tests/manual/v4"; // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; diff --git a/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml index 2a1b4fbf57..53a93621bb 100644 --- a/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml +++ b/tests/auto/qml/qqmlapplicationengine/data/applicationTest.qml @@ -3,12 +3,21 @@ import QtQml 2.0 QtObject { property string originalName property string originalVersion + property string originalOrganization + property string originalDomain property string currentName: Qt.application.name property string currentVersion: Qt.application.version + property string currentOrganization: Qt.application.organization + property string currentDomain: Qt.application.domain + property QtObject applicationInstance: Qt.application Component.onCompleted: { originalName = Qt.application.name originalVersion = Qt.application.version + originalOrganization = Qt.application.organization + originalDomain = Qt.application.domain Qt.application.name = "Test B" Qt.application.version = "0.0B" + Qt.application.organization = "Org B" + Qt.application.domain = "b.org" } } diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index 4780ee0310..489972716d 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -132,26 +132,55 @@ void tst_qqmlapplicationengine::applicationProperties() QCoreApplication* coreApp = QCoreApplication::instance(); QString originalName = coreApp->applicationName(); QString originalVersion = coreApp->applicationVersion(); + QString originalOrganization = coreApp->organizationName(); + QString originalDomain = coreApp->organizationDomain(); QString firstName = QLatin1String("Test A"); QString firstVersion = QLatin1String("0.0A"); + QString firstOrganization = QLatin1String("Org A"); + QString firstDomain = QLatin1String("a.org"); QString secondName = QLatin1String("Test B"); QString secondVersion = QLatin1String("0.0B"); + QString secondOrganization = QLatin1String("Org B"); + QString secondDomain = QLatin1String("b.org"); coreApp->setApplicationName(firstName); coreApp->setApplicationVersion(firstVersion); + coreApp->setOrganizationName(firstOrganization); + coreApp->setOrganizationDomain(firstDomain); QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("applicationTest.qml")); QObject* root = test->rootObjects().at(0); QVERIFY(root); QCOMPARE(root->property("originalName").toString(), firstName); QCOMPARE(root->property("originalVersion").toString(), firstVersion); + QCOMPARE(root->property("originalOrganization").toString(), firstOrganization); + QCOMPARE(root->property("originalDomain").toString(), firstDomain); QCOMPARE(root->property("currentName").toString(), secondName); QCOMPARE(root->property("currentVersion").toString(), secondVersion); + QCOMPARE(root->property("currentOrganization").toString(), secondOrganization); + QCOMPARE(root->property("currentDomain").toString(), secondDomain); QCOMPARE(coreApp->applicationName(), secondName); QCOMPARE(coreApp->applicationVersion(), secondVersion); + QCOMPARE(coreApp->organizationName(), secondOrganization); + QCOMPARE(coreApp->organizationDomain(), secondDomain); + + QObject* application = root->property("applicationInstance").value<QObject*>(); + QVERIFY(application); + QSignalSpy nameChanged(application, SIGNAL(nameChanged())); + QSignalSpy versionChanged(application, SIGNAL(versionChanged())); + QSignalSpy organizationChanged(application, SIGNAL(organizationChanged())); + QSignalSpy domainChanged(application, SIGNAL(domainChanged())); coreApp->setApplicationName(originalName); coreApp->setApplicationVersion(originalVersion); + coreApp->setOrganizationName(originalOrganization); + coreApp->setOrganizationDomain(originalDomain); + + QCOMPARE(nameChanged.count(), 1); + QCOMPARE(versionChanged.count(), 1); + QCOMPARE(organizationChanged.count(), 1); + QCOMPARE(domainChanged.count(), 1); + delete test; } diff --git a/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml index a49a86e1f3..4ca6b68cf8 100644 --- a/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml +++ b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml @@ -18,8 +18,12 @@ Item { } } + function createObject() + { + internalComponent.createObject(); + } + Component.onCompleted: { - internalComponent.createObject() - gc() + createObject() } } diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 9eeff66e7a..408baeffee 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -96,6 +96,23 @@ public slots: } }; +// The JavaScriptCore GC marks the C stack. To try to ensure that there is +// no JSObject* left in stack memory by the compiler, we call this function +// to zap some bytes of memory before calling collectGarbage(). +static void zapSomeStack() +{ + char *buf = (char*)alloca(4096); + memset(buf, 0, 4096); +} + +static void gc(QQmlEngine &engine) +{ + zapSomeStack(); + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + class tst_qqmlcomponent : public QQmlDataTest { Q_OBJECT @@ -377,6 +394,7 @@ void tst_qqmlcomponent::onDestructionLookup() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("onDestructionLookup.qml")); QScopedPointer<QObject> object(component.create()); + gc(engine); QVERIFY(object != 0); QVERIFY(object->property("success").toBool()); } diff --git a/tests/auto/qml/qqmlconnections/qqmlconnections.pro b/tests/auto/qml/qqmlconnections/qqmlconnections.pro index 52f85f6219..7004ee0385 100644 --- a/tests/auto/qml/qqmlconnections/qqmlconnections.pro +++ b/tests/auto/qml/qqmlconnections/qqmlconnections.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp index 561602fda5..e6f31dcb83 100644 --- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp +++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp @@ -80,11 +80,11 @@ void tst_qqmlconsole::logging() QTest::ignoreMessage(QtDebugMsg, "{\"a\":\"hello\",\"d\":1}"); QTest::ignoreMessage(QtDebugMsg, "undefined"); QTest::ignoreMessage(QtDebugMsg, "12"); - QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}"); + QTest::ignoreMessage(QtDebugMsg, "function() { [code] }"); QTest::ignoreMessage(QtDebugMsg, "true"); // Printing QML object prints out the class/type of QML object with the memory address // QTest::ignoreMessage(QtDebugMsg, "QtObject_QML_0(0xABCD..)"); - QTest::ignoreMessage(QtDebugMsg, "[object Object]"); +// QTest::ignoreMessage(QtDebugMsg, "[object Object]"); QTest::ignoreMessage(QtDebugMsg, "1 pong! [object Object]"); QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] [object Object] 2"); @@ -99,8 +99,8 @@ void tst_qqmlconsole::tracing() QUrl testUrl = testFileUrl("tracing.qml"); QString traceText = - QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) + - QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9); + QString::fromLatin1("tracing (%1:%2)\n").arg(testUrl.toString()).arg(50) + + QString::fromLatin1("onCompleted (%1:%2)").arg(testUrl.toString()).arg(54); QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText)); @@ -130,11 +130,11 @@ void tst_qqmlconsole::assert() // assert() QString assert1 = "This will fail\n" + - QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17); + QString::fromLatin1("onCompleted (%1:%2)").arg(testUrl.toString()).arg(54); QString assert2 = "This will fail too\n" + - QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) + - QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9); + QString::fromLatin1("assertFail (%1:%2)\n").arg(testUrl.toString()).arg(47) + + QString::fromLatin1("onCompleted (%1:%2)").arg(testUrl.toString()).arg(59); QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1)); QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2)); @@ -151,11 +151,11 @@ void tst_qqmlconsole::exception() // exception() QString exception1 = "Exception 1\n" + - QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21); + QString::fromLatin1("onCompleted (%1:%2)").arg(testUrl.toString()).arg(51); QString exception2 = "Exception 2\n" + - QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) + - QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9); + QString::fromLatin1("exceptionFail (%1:%2)\n").arg(testUrl.toString()).arg(46) + + QString::fromLatin1("onCompleted (%1:%2)").arg(testUrl.toString()).arg(56); QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1)); QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2)); diff --git a/tests/auto/qml/qqmlcontext/qqmlcontext.pro b/tests/auto/qml/qqmlcontext/qqmlcontext.pro index 48c0b5767c..2fb299cb10 100644 --- a/tests/auto/qml/qqmlcontext/qqmlcontext.pro +++ b/tests/auto/qml/qqmlcontext/qqmlcontext.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private qml-private testlib v8-private +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro index a3951da821..75436dd8e2 100644 --- a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro +++ b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro @@ -6,5 +6,5 @@ SOURCES += tst_qqmlcpputils.cpp CONFIG += parallel_test -QT += core-private gui-private qml-private testlib v8-private +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmldirparser/qqmldirparser.pro b/tests/auto/qml/qqmldirparser/qqmldirparser.pro index 2abb4bd448..0be38a0a35 100644 --- a/tests/auto/qml/qqmldirparser/qqmldirparser.pro +++ b/tests/auto/qml/qqmldirparser/qqmldirparser.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qqmldirparser -QT += qml testlib v8-private +QT += qml testlib qml-private macx:CONFIG -= app_bundle SOURCES += tst_qqmldirparser.cpp diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index cd8f050d2d..bf76c07970 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -45,7 +45,6 @@ #include <QObject> #include <QQmlEngine> #include <QQmlComponent> -#include <private/v8.h> #include <private/qqmldirparser_p.h> #include <QDebug> diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml index c1f73d3bac..f4307081c5 100644 --- a/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml @@ -31,7 +31,6 @@ Rectangle { function deassignVp() { textTwo.textCanary = 22; textTwo.vp = textTwo.textCanary; - gc(); } } } diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml index 3d8fd85a88..943d34ca84 100644 --- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml @@ -19,11 +19,11 @@ MyQmlObject { property bool assignWrongType: false property bool assignWrongTypeToValueType: false + function myFunction() { + return aNumber * 10; + } onAssignToPropertyChanged: { - function myFunction() { - return aNumber * 10; - } a = Qt.binding(myFunction); } @@ -54,17 +54,17 @@ MyQmlObject { // detecting errors: + function myEmptyFunction() { + } onAssignFuncWithoutReturnChanged: { - function myFunction() { - } - a = Qt.binding(myFunction); + a = Qt.binding(myEmptyFunction); } + function myStringFunction() { + return 'a string'; + } onAssignWrongTypeChanged: { - function myFunction() { - return 'a string'; - } - aNumber = Qt.binding(myFunction); + aNumber = Qt.binding(myStringFunction); } onAssignWrongTypeToValueTypeChanged: { diff --git a/tests/auto/qml/qqmlecmascript/data/include.js b/tests/auto/qml/qqmlecmascript/data/include.js index 232fd808f8..489e322ef0 100644 --- a/tests/auto/qml/qqmlecmascript/data/include.js +++ b/tests/auto/qml/qqmlecmascript/data/include.js @@ -3,6 +3,6 @@ var test2 = false var test3 = false function go() { - Qt.include("js/include2.js"); + console.log(Qt.include("js/include2.js").status); } diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml index 93c44afcc9..483ee3e916 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml @@ -21,6 +21,5 @@ Item { function deassignCircular() { vp = 2; - gc(); } } diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml index 171d7747cd..9db2c88256 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml @@ -19,7 +19,6 @@ Item { function deassignCanaryResource() { canaryResource = 1; - gc(); } function assignCircular() { @@ -32,7 +31,6 @@ Item { function deassignCircular() { canaryInt = 2; varProperty = 2; - gc(); } function assignThenDeassign() { diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml index abd0dd7c04..5e318e15a8 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml @@ -22,7 +22,6 @@ Item { function deassignCircular() { varProperty = 2; - gc(); } function assignThenDeassign() { diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml index 7b3df674f1..6f5094de27 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml @@ -21,7 +21,6 @@ Item { function deassignVarProp() { vp = 2; - gc(); } } diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml index 9cebded932..ecc4892334 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml @@ -21,6 +21,5 @@ Item { function deassignCircular() { vp = 2; - gc(); } } diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml index 1143eaf919..c2325fb5ee 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml @@ -5,7 +5,8 @@ Item { id: testOwnership property bool test: false - function runTest() { + function createComponent() + { var o; var c = Qt.createComponent("ComponentWithVarProp.qml"); if (c.status == Component.Ready) { @@ -15,8 +16,12 @@ Item { } o.varprop = true; // causes initialization of varProperties. SingletonType.QObject.trackObject(o); // stores QObject ptr - if (SingletonType.QObject.trackedObject() == null) return; // is still valid, should have a valid v8object. - o = new Date(); // causes object to be gc-able. + if (SingletonType.QObject.trackedObject() == null) return false // is still valid, should have a valid v8object. + return true; + } + + function runTest() { + if (!createComponent()) return; gc(); // collect object's v8object + varProperties, queues deleteLater. if (SingletonType.QObject.trackedObject() != null) return; // v8object was previously collected. SingletonType.QObject.setTrackedObjectProperty("varprop"); // deferences varProperties of object. diff --git a/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml b/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml index 3ab714b800..09fffbba36 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml @@ -2,10 +2,8 @@ import Qt.test 1.0 MyQmlObject { property int argumentCount: -1 - property bool calleeCorrect: false onBasicSignal: { argumentCount = arguments.length - calleeCorrect = (arguments.callee === onBasicSignal) setString('pass') } } diff --git a/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml b/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml index 8ecb8df6ee..fec810fd28 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml @@ -2,11 +2,9 @@ import Qt.test 1.0 MyQmlObject { property int argumentCount: -1 - property bool calleeCorrect: false onArgumentSignal: { argumentCount = arguments.length - calleeCorrect = (arguments.callee === onArgumentSignal) setString('pass ' + arguments[0] + ' ' + arguments[1] + ' ' + arguments[2] + ' ' + arguments[3] + ' ' + arguments[4]) diff --git a/tests/auto/qml/qqmlecmascript/data/v8functionException.qml b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml deleted file mode 100644 index 51df1c65d8..0000000000 --- a/tests/auto/qml/qqmlecmascript/data/v8functionException.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -// This test uses a multi-line string which has \r-terminated -// string fragments. The expression rewriter deliberately doesn't -// handle \r-terminated string fragments (see QTBUG-24064) and thus -// this test ensures that we don't crash when the client attempts -// to invoke a non-compiled dynamic slot. - -Item { - id: root - - function dynamicSlot() { - var someString = "Hello,
this is a
multiline string"; - } -} diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro index bc55ed9376..6193ee7c88 100644 --- a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -16,7 +16,7 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private network testlib +QT += core-private gui-private qml-private network testlib qtHaveModule(widgets): QT += widgets DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 8b0278373a..64aac83c02 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -104,10 +104,9 @@ public: void setWidth(int) { } }; -void MyQmlObject::v8function(QQmlV8Function *) +void MyQmlObject::v8function(QQmlV4Function *function) { - const char *error = "Exception thrown from within QObject slot"; - v8::ThrowException(v8::Exception::Error(v8::String::New(error))); + QV8Engine::getV4(function->engine())->current->throwError(QStringLiteral("Exception thrown from within QObject slot")); } static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine) @@ -300,7 +299,6 @@ void registerTypes() qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons"); qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject"); - qmlRegisterType<CircularReferenceHandle>("Qt.test", 1, 0, "CircularReferenceHandle"); qmlRegisterType<MyDynamicCreationDestructionObject>("Qt.test", 1, 0, "MyDynamicCreationDestructionObject"); qmlRegisterType<WriteCounter>("Qt.test", 1, 0, "WriteCounter"); diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index e4dd1e3e18..4d30816b0a 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -63,6 +63,7 @@ #include <private/qqmlengine_p.h> #include <private/qv8engine_p.h> +#include <private/qv4qobjectwrapper_p.h> class MyQmlAttachedObject : public QObject { @@ -265,7 +266,7 @@ public slots: void myinvokable(MyQmlObject *o) { myinvokableObject = o; } void variantMethod(const QVariant &v) { m_variant = v; } void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; } - void v8function(QQmlV8Function*); + void v8function(QQmlV4Function*); void registeredFlagMethod(Qt::MouseButtons v) { m_buttons = v; } private: @@ -1172,16 +1173,14 @@ private: int m_value; }; -class CircularReferenceObject : public QObject, - public QV8GCCallback::Node +class CircularReferenceObject : public QObject { Q_OBJECT public: CircularReferenceObject(QObject *parent = 0) - : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0) + : QObject(parent), m_dtorCount(0) { - QV8GCCallback::addGcCallbackNode(this); } ~CircularReferenceObject() @@ -1204,74 +1203,15 @@ public: Q_INVOKABLE void addReference(QObject *other) { - m_referenced = other; - } + QQmlData *ddata = QQmlData::get(this); + assert(ddata); + QV4::QObjectWrapper *thisObject = ddata->jsWrapper.value().as<QV4::QObjectWrapper>(); + assert(thisObject); - static void callback(QV8GCCallback::Node *n) - { - CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n); - if (cro->m_referenced) { - cro->m_engine->addRelationshipForGC(cro, cro->m_referenced); - } - } + QQmlData *otherDData = QQmlData::get(other); + assert(otherDData); - void setEngine(QQmlEngine* declarativeEngine) - { - m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine(); - } - -private: - QObject *m_referenced; - int *m_dtorCount; - QV8Engine* m_engine; -}; -Q_DECLARE_METATYPE(CircularReferenceObject*) - -class CircularReferenceHandle : public QObject, - public QV8GCCallback::Node -{ - Q_OBJECT - -public: - CircularReferenceHandle(QObject *parent = 0) - : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0) - { - QV8GCCallback::addGcCallbackNode(this); - } - - ~CircularReferenceHandle() - { - if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1; - } - - Q_INVOKABLE void setDtorCount(int *dtorCount) - { - m_dtorCount = dtorCount; - } - - Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0) - { - CircularReferenceHandle *retn = new CircularReferenceHandle(parent); - retn->m_dtorCount = m_dtorCount; - retn->m_engine = m_engine; - return retn; - } - - Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle) - { - m_referenced = qPersistentNew(handle); - m_referenced.MakeWeak(static_cast<void*>(this), wrcallback); - } - - static void wrcallback(v8::Persistent<v8::Value> handle, void *) - { - qPersistentDispose(handle); - } - - static void gccallback(QV8GCCallback::Node *n) - { - CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n); - crh->m_engine->addRelationshipForGC(crh, crh->m_referenced); + thisObject->defineDefaultProperty(thisObject->engine(), QStringLiteral("autoTestStrongRef"), otherDData->jsWrapper.value()); } void setEngine(QQmlEngine* declarativeEngine) @@ -1280,11 +1220,10 @@ public: } private: - v8::Persistent<v8::Value> m_referenced; int *m_dtorCount; QV8Engine* m_engine; }; -Q_DECLARE_METATYPE(CircularReferenceHandle*) +Q_DECLARE_METATYPE(CircularReferenceObject*) class MyDynamicCreationDestructionObject : public QObject { diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c417879d3c..0db8351135 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -45,15 +45,28 @@ #include <QtQml/qqmlcontext.h> #include <QtCore/qfileinfo.h> #include <QtCore/qdebug.h> -#include <QtQml/private/qqmlguard_p.h> #include <QtCore/qdir.h> #include <QtCore/qnumeric.h> #include <private/qqmlengine_p.h> #include <private/qqmlvmemetaobject_p.h> -#include <private/qv4compiler_p.h> +#include <private/qqmlcontextwrapper_p.h> #include "testtypes.h" #include "testhttpserver.h" #include "../../shared/util.h" +#include <private/qv4functionobject_p.h> +#include <private/qv4exception_p.h> + +#ifdef Q_CC_MSVC +#define NO_INLINE __declspec(noinline) +#else +#define NO_INLINE __attribute__((noinline)) +#endif + +#if defined(Q_OS_WIN) +#include <malloc.h> +#else +#include <alloca.h> +#endif /* This test covers evaluation of ECMAScript expressions and bindings from within @@ -219,7 +232,6 @@ private slots: void functionAssignment_afterBinding(); void eval(); void function(); - void functionException(); void qtbug_10696(); void qtbug_11606(); void qtbug_11600(); @@ -293,11 +305,28 @@ private slots: void stringParsing(); private: - static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); +// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); static void verifyContextLifetime(QQmlContextData *ctxt); QQmlEngine engine; }; +// The JavaScriptCore GC marks the C stack. To try to ensure that there is +// no JSObject* left in stack memory by the compiler, we call this function +// to zap some bytes of memory before calling collectGarbage(). +static void NO_INLINE zapSomeStack() +{ + char *buf = (char*)alloca(4096); + memset(buf, 0, 4096); +} + +static void gc(QQmlEngine &engine) +{ + zapSomeStack(); + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + void tst_qqmlecmascript::initTestCase() { QQmlDataTest::initTestCase(); @@ -546,7 +575,6 @@ void tst_qqmlecmascript::signalArguments() emit object->basicSignal(); QCOMPARE(object->string(), QString("pass")); QCOMPARE(object->property("argumentCount").toInt(), 0); - QCOMPARE(object->property("calleeCorrect").toBool(), true); delete object; } @@ -558,7 +586,6 @@ void tst_qqmlecmascript::signalArguments() emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); QCOMPARE(object->property("argumentCount").toInt(), 5); - QCOMPARE(object->property("calleeCorrect").toBool(), true); delete object; } } @@ -619,7 +646,7 @@ void tst_qqmlecmascript::methods() void tst_qqmlecmascript::bindingLoop() { QQmlComponent component(&engine, testFileUrl("bindingLoop.qml")); - QString warning = component.url().toString() + ":9:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; + QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); @@ -858,7 +885,7 @@ void tst_qqmlecmascript::deferredPropertiesErrors() QVERIFY(object->objectProperty() == 0); QVERIFY(object->objectProperty2() == 0); - QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*"; + QString warning = component.url().toString() + ":6:21: Unable to assign [undefined] to QObject*"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); qmlExecuteDeferred(object); @@ -1006,13 +1033,13 @@ void tst_qqmlecmascript::enums() { QUrl file = testFileUrl("enums.2.qml"); QString w1 = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'MyEnum' for property 'MyUnregisteredEnumTypeObject::enumProperty'"); - QString w2 = QLatin1String("QQmlExpression: Expression ") + testFileUrl("enums.2.qml").toString() + QLatin1String(":9 depends on non-NOTIFYable properties:"); + QString w2 = QLatin1String("QQmlExpression: Expression ") + testFileUrl("enums.2.qml").toString() + QLatin1String(":9:21 depends on non-NOTIFYable properties:"); QString w3 = QLatin1String(" MyUnregisteredEnumTypeObject::enumProperty"); - QString w4 = file.toString() + ":7: Unable to assign [undefined] to int"; - QString w5 = file.toString() + ":8: Unable to assign [undefined] to int"; - QString w6 = file.toString() + ":9: Unable to assign [undefined] to int"; - QString w7 = file.toString() + ":13: Unable to assign [undefined] to [unknown property type]"; - QString w8 = file.toString() + ":31: Unable to assign int to [unknown property type]"; + QString w4 = file.toString() + ":7:21: Unable to assign [undefined] to int"; + QString w5 = file.toString() + ":8:21: Unable to assign [undefined] to int"; + QString w6 = file.toString() + ":9:21: Unable to assign [undefined] to int"; + QString w7 = file.toString() + ":13:23: Unable to assign [undefined] to [unknown property type]"; + QString w8 = file.toString() + ":31:23: Unable to assign int to [unknown property type]"; QTest::ignoreMessage(QtWarningMsg, qPrintable(w1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(w2)); QTest::ignoreMessage(QtWarningMsg, qPrintable(w3)); @@ -1206,7 +1233,7 @@ void tst_qqmlecmascript::nonExistentAttachedObject() { QQmlComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml")); - QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString"; + QString warning = component.url().toString() + ":4:21: Unable to assign [undefined] to QString"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QObject *object = component.create(); @@ -1576,9 +1603,9 @@ void tst_qqmlecmascript::dynamicDestruction() { { QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml")); - QQmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create()); + QPointer<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); - QQmlGuard<QObject> createdQmlObject = 0; + QPointer<QObject> createdQmlObject = 0; QMetaObject::invokeMethod(object, "create"); createdQmlObject = object->objectProperty(); @@ -1631,7 +1658,7 @@ void tst_qqmlecmascript::dynamicDestruction() { // QTBUG-23451 - QQmlGuard<QObject> createdQmlObject = 0; + QPointer<QObject> createdQmlObject = 0; QQmlComponent component(&engine, testFileUrl("dynamicDeletion.3.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -1783,8 +1810,8 @@ void tst_qqmlecmascript::scriptErrors() QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; QString warning4 = url + ":13: ReferenceError: a is not defined"; QString warning5 = url + ":11: ReferenceError: a is not defined"; - QString warning6 = url + ":10: Unable to assign [undefined] to int"; - QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\""; + QString warning6 = url + ":10:21: Unable to assign [undefined] to int"; + QString warning7 = url + ":15: TypeError: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\""; QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); @@ -1829,7 +1856,9 @@ void tst_qqmlecmascript::functionErrors() object = componentTwo.create(); QVERIFY(object != 0); - warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); + QObject *resource = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); + warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); + warning = warning.arg(QString::number((qintptr)resource, 16)); QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); delete object; @@ -2197,63 +2226,72 @@ void tst_qqmlecmascript::regExpBug() } } -static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, const char *source) +static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const char *source) { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return false; - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) - return false; - v8::Handle<v8::Value> args[] = { o }; - function->Call(engine->global(), 1, args); - return tc.HasCaught(); + + QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); + program.inheritContext = true; + + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + + try { + QV4::FunctionObject *function = program.run().asFunctionObject(); + if (!function) + return false; + QV4::Value args[] = { o }; + function->call(engine->global(), args, 1); + } catch (QV4::Exception &e) { + e.accept(ctx); + return true; + } + return false; } -static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o, - const char *source, v8::Handle<v8::Value> result) +static inline bool evaluate_value(QV8Engine *engine, const QV4::Value &o, + const char *source, const QV4::Value &result) { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return false; - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) - return false; - v8::Handle<v8::Value> args[] = { o }; - v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); + QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); + program.inheritContext = true; - if (tc.HasCaught()) - return false; - - return value->StrictEquals(result); + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + try { + QV4::FunctionObject *function = program.run().asFunctionObject(); + if (!function) + return false; + QV4::Value args[] = { o }; + QV4::Value value = function->call(engine->global(), args, 1); + return __qmljs_strict_equal(value, result); + } catch (QV4::Exception &e) { + e.accept(ctx); + } + return false; } -static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o, +static inline QV4::Value evaluate(QV8Engine *engine, const QV4::Value & o, const char *source) { QString functionSource = QLatin1String("(function(object) { return ") + QLatin1String(source) + QLatin1String(" })"); - v8::TryCatch tc; - v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource)); - if (tc.HasCaught()) - return v8::Handle<v8::Value>(); - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run()); - if (function.IsEmpty()) - return v8::Handle<v8::Value>(); - v8::Handle<v8::Value> args[] = { o }; - - v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args); - if (tc.HasCaught()) - return v8::Handle<v8::Value>(); - return value; + QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource); + program.inheritContext = true; + try { + QV4::FunctionObject *function = program.run().asFunctionObject(); + if (!function) + return QV4::Value::emptyValue(); + QV4::Value args[] = { o }; + QV4::Value value = function->call(engine->global(), args, 1); + return value; + } catch (QV4::Exception &e) { + e.accept(ctx); + } + return QV4::Value::emptyValue(); } #define EVALUATE_ERROR(source) evaluate_error(engine, object, source) @@ -2271,10 +2309,7 @@ void tst_qqmlecmascript::callQtInvokables() QV8Engine *engine = ep->v8engine(); - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - v8::Local<v8::Object> object = engine->newQObject(o)->ToObject(); + QV4::Value object = QV4::QObjectWrapper::wrap(QV8Engine::getV4(engine), o); // Non-existent methods o->reset(); @@ -2304,14 +2339,14 @@ void tst_qqmlecmascript::callQtInvokables() // Excessive arguments o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(10)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 9); QCOMPARE(o->actuals().count(), 2); @@ -2320,27 +2355,27 @@ void tst_qqmlecmascript::callQtInvokables() // Test return types o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 0); QCOMPARE(o->actuals().count(), 0); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6))); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", QV4::Value::fromInt32(6))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 1); QCOMPARE(o->actuals().count(), 0); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75))); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", QV4::Value::fromDouble(19.75))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 2); QCOMPARE(o->actuals().count(), 0); o->reset(); { - v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()"); - QVERIFY(!ret.IsEmpty()); + QV4::Value ret = EVALUATE("object.method_NoArgs_QPointF()"); + QVERIFY(!ret.isEmpty()); QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 3); @@ -2349,8 +2384,10 @@ void tst_qqmlecmascript::callQtInvokables() o->reset(); { - v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()"); - QCOMPARE(engine->toQObject(ret), (QObject *)o); + QV4::Value ret = EVALUATE("object.method_NoArgs_QObject()"); + QV4::QObjectWrapper *qobjectWrapper = ret.as<QV4::QObjectWrapper>(); + QVERIFY(qobjectWrapper); + QCOMPARE(qobjectWrapper->object(), (QObject *)o); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 4); QCOMPARE(o->actuals().count(), 0); @@ -2364,9 +2401,9 @@ void tst_qqmlecmascript::callQtInvokables() o->reset(); { - v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()"); - QVERIFY(ret->IsString()); - QCOMPARE(engine->toString(ret), QString("Hello world")); + QV4::Value ret = EVALUATE("object.method_NoArgs_QScriptValue()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toQString(), QString("Hello world")); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 6); QCOMPARE(o->actuals().count(), 0); @@ -2380,49 +2417,49 @@ void tst_qqmlecmascript::callQtInvokables() // Test arg types o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(94)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(94)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(94)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_int(object)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 8); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 9); QCOMPARE(o->actuals().count(), 2); @@ -2430,56 +2467,56 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant(9)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(94.3)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(94.3)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QVERIFY(qIsNaN(o->actuals().at(0).toDouble())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QVERIFY(qIsNaN(o->actuals().at(0).toDouble())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_real(object)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 10); QCOMPARE(o->actuals().count(), 1); QVERIFY(qIsNaN(o->actuals().at(0).toDouble())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 11); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant("Hello world")); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QString(19)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 11); QCOMPARE(o->actuals().count(), 1); @@ -2488,7 +2525,7 @@ void tst_qqmlecmascript::callQtInvokables() o->reset(); { QString expected = "MyInvokableObject(0x" + QString::number((quintptr)o, 16) + ")"; - QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QString(object)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 11); QCOMPARE(o->actuals().count(), 1); @@ -2496,126 +2533,126 @@ void tst_qqmlecmascript::callQtInvokables() } o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QString(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 11); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QString())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 11); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QString())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF())); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF(99.3, -10.2))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 12); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QPointF(9, 12))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 13); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), qVariantFromValue((QObject *)0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 13); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), qVariantFromValue((QObject *)0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 13); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), qVariantFromValue((QObject *)0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 13); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), qVariantFromValue((QObject *)0)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 13); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), qVariantFromValue((QObject *)o)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 14); QCOMPARE(o->actuals().count(), 1); QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isNull()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 14); QCOMPARE(o->actuals().count(), 1); QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isUndefined()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 14); QCOMPARE(o->actuals().count(), 1); QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).strictlyEquals(QJSValue(19))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 14); QCOMPARE(o->actuals().count(), 1); QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(0)).isArray()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 15); QCOMPARE(o->actuals().count(), 2); @@ -2623,7 +2660,7 @@ void tst_qqmlecmascript::callQtInvokables() QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).isNull()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 15); QCOMPARE(o->actuals().count(), 2); @@ -2631,7 +2668,7 @@ void tst_qqmlecmascript::callQtInvokables() QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).isUndefined()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 15); QCOMPARE(o->actuals().count(), 2); @@ -2639,7 +2676,7 @@ void tst_qqmlecmascript::callQtInvokables() QVERIFY(qvariant_cast<QJSValue>(o->actuals().at(1)).strictlyEquals(QJSValue(19))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 15); QCOMPARE(o->actuals().count(), 2); @@ -2653,14 +2690,14 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().count(), 0); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload(10)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 16); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(10)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 17); QCOMPARE(o->actuals().count(), 2); @@ -2668,21 +2705,21 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant(11)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 18); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(QString("Hello"))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 19); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(9)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19))); + QVERIFY(EVALUATE_VALUE("object.method_default(10)", QV4::Value::fromInt32(19))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 20); QCOMPARE(o->actuals().count(), 2); @@ -2690,7 +2727,7 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant(19)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13))); + QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", QV4::Value::fromInt32(13))); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 20); QCOMPARE(o->actuals().count(), 2); @@ -2698,14 +2735,14 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant(13)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), -3); QCOMPARE(o->actuals().count(), 1); QCOMPARE(o->actuals().at(0), QVariant(9)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 21); QCOMPARE(o->actuals().count(), 2); @@ -2713,7 +2750,7 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 21); QCOMPARE(o->actuals().count(), 2); @@ -2721,91 +2758,91 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->actuals().at(1), QVariant(QString("World"))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonObject({foo:123})", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonObject({foo:123})", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 22); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonObject>(o->actuals().at(0)), QJsonDocument::fromJson("{\"foo\":123}").object()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonArray([123])", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonArray([123])", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 23); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonArray>(o->actuals().at(0)), QJsonDocument::fromJson("[123]").array()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(123)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(123)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(123)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(42.35)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(42.35)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(42.35)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue('ciao')", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue('ciao')", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QStringLiteral("ciao"))); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(true)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(true)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(true)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(false)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(false)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(false)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Null)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_QJsonValue(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 24); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Undefined)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload({foo:123})", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload({foo:123})", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 25); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonObject>(o->actuals().at(0)), QJsonDocument::fromJson("{\"foo\":123}").object()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload([123])", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload([123])", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 26); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonArray>(o->actuals().at(0)), QJsonDocument::fromJson("[123]").array()); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload(null)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload(null)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 27); QCOMPARE(o->actuals().count(), 1); QCOMPARE(qvariant_cast<QJsonValue>(o->actuals().at(0)), QJsonValue(QJsonValue::Null)); o->reset(); - QVERIFY(EVALUATE_VALUE("object.method_overload(undefined)", v8::Undefined())); + QVERIFY(EVALUATE_VALUE("object.method_overload(undefined)", QV4::Value::undefinedValue())); QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), 27); QCOMPARE(o->actuals().count(), 1); @@ -3264,7 +3301,7 @@ void tst_qqmlecmascript::ownershipRootObject() context->setContextObject(&own); QQmlComponent component(&engine, testFileUrl("ownershipRootObject.qml")); - QQmlGuard<QObject> object = component.create(context); + QPointer<QObject> object = component.create(context); QVERIFY(object); engine.collectGarbage(); @@ -3294,7 +3331,7 @@ void tst_qqmlecmascript::ownershipConsistency() QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QQmlComponent component(&engine, testFileUrl("ownershipConsistency.qml")); - QQmlGuard<QObject> object = component.create(context); + QPointer<QObject> object = component.create(context); QVERIFY(object); engine.collectGarbage(); @@ -3500,13 +3537,13 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_data() QTest::newRow("'ciao'") << "'ciao'" << compareStrict; QString comparePropertiesStrict( - "(function(a, b) {" + "(function compareMe(a, b) {" " if (typeof b != 'object')" " return a === b;" " var props = Object.getOwnPropertyNames(b);" " for (var i = 0; i < props.length; ++i) {" " var p = props[i];" - " return arguments.callee(a[p], b[p]);" + " return compareMe(a[p], b[p]);" " }" "})"); QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict; @@ -3553,7 +3590,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines() object->setProperty("compare", compare); object->setProperty("pass", false); - QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); + QTest::ignoreMessage(QtWarningMsg, "JSValue can't be reassigned to another engine."); emit object->signalWithVariant(QVariant::fromValue(value)); QVERIFY(!object->property("pass").toBool()); } @@ -3645,7 +3682,8 @@ void tst_qqmlecmascript::singletonType_data() QTest::newRow("qobject, writing + readonly constraints") << testFileUrl("singletontype/qobjectSingletonTypeWriting.qml") << QString() - << (QStringList() << QString(testFileUrl("singletontype/qobjectSingletonTypeWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) + << (QStringList() << + QString(testFileUrl("singletontype/qobjectSingletonTypeWriting.qml").toString() + QLatin1String(":15: TypeError: Cannot assign to read-only property \"qobjectTestProperty\""))) << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty") << (QVariantList() << 20 << 50 << 10) << (QStringList() << "firstProperty" << "secondProperty") @@ -3656,7 +3694,7 @@ void tst_qqmlecmascript::singletonType_data() QTest::newRow("script, writing + readonly constraints") << testFileUrl("singletontype/scriptSingletonTypeWriting.qml") << QString() - << (QStringList() << QString(testFileUrl("singletontype/scriptSingletonTypeWriting.qml").toString() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\""))) + << (QStringList()) << (QStringList() << "readBack" << "unchanged") << (QVariantList() << 15 << 42) << (QStringList() << "firstProperty" << "secondProperty") @@ -3808,26 +3846,21 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { if (!ctxt->importedScripts.isEmpty()) { QV8Engine *engine = QV8Engine::get(ctxt->engine); - foreach (v8::Persistent<v8::Object> qmlglobal, ctxt->importedScripts) { + foreach (const QV4::PersistentValue& qmlglobal, ctxt->importedScripts) { QQmlContextData *scriptContext, *newContext; - if (qmlglobal.IsEmpty()) + if (qmlglobal.isEmpty()) continue; - scriptContext = engine->contextWrapper()->context(qmlglobal); + scriptContext = QV4::QmlContextWrapper::getContext(qmlglobal); { - v8::HandleScope handle_scope; - v8::Persistent<v8::Context> context = v8::Context::New(); - v8::Context::Scope context_scope(context); - v8::Local<v8::Object> temporaryScope = engine->qmlScope(scriptContext, NULL); + QV4::Value temporaryScope = QV4::QmlContextWrapper::qmlScope(engine, scriptContext, 0); Q_UNUSED(temporaryScope) - - context.Dispose(); } - QV8Engine::gc(); - newContext = engine->contextWrapper()->context(qmlglobal); + engine->gc(); + newContext = QV4::QmlContextWrapper::getContext(qmlglobal); QVERIFY(scriptContext == newContext); } } @@ -3962,7 +3995,7 @@ void tst_qqmlecmascript::importScripts_data() QTest::newRow("malformed import statement") << testFileUrl("jsimportfail/malformedImport.qml") << QString() - << (QStringList() << testFileUrl("jsimportfail/malformedImport.js").toString() + QLatin1String(":1: SyntaxError: Unexpected token .")) + << (QStringList() << testFileUrl("jsimportfail/malformedImport.js").toString() + QLatin1String(":1:1: Syntax error")) << QStringList() << QVariantList(); @@ -4091,6 +4124,7 @@ void tst_qqmlecmascript::scarceResources_other() origPixmap.fill(Qt::blue); QString srp_name, expectedWarning; QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); ScarceResourceObject *eo = 0; QObject *srsc = 0; QObject *object = 0; @@ -4116,7 +4150,7 @@ void tst_qqmlecmascript::scarceResources_other() QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap); eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; // test that scarce resources are handled properly from js functions in qml files @@ -4135,7 +4169,7 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; // test that if an exception occurs while invoking js function from cpp, that the resources are released. @@ -4145,13 +4179,14 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); + expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); + expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; // test that if an Item which has JS ownership but has a scarce resource property is garbage collected, @@ -4161,9 +4196,10 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(object != 0); QVERIFY(!object->property("varProperty").isValid()); // not assigned yet QMetaObject::invokeMethod(object, "assignVarProperty"); - QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property. + QVERIFY(v4->scarceResources.isEmpty()); // the scarce resource is a VME property. QMetaObject::invokeMethod(object, "deassignVarProperty"); - QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc. + gc(engine); + QVERIFY(v4->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc. delete object; /* property variant semantics */ @@ -4188,7 +4224,7 @@ void tst_qqmlecmascript::scarceResources_other() QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap); eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; // test that scarce resources are handled properly from js functions in qml files @@ -4207,7 +4243,7 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; // test that if an exception occurs while invoking js function from cpp, that the resources are released. @@ -4217,13 +4253,14 @@ void tst_qqmlecmascript::scarceResources_other() QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object [object Object] is not a function"); + expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); + expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. - QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + QVERIFY(v4->scarceResources.isEmpty()); // should have been released by this point. delete object; } @@ -4459,6 +4496,7 @@ void tst_qqmlecmascript::scarceResources() QFETCH(QStringList, expectedErrors); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); ScarceResourceObject *eo = 0; QObject *object = 0; @@ -4483,7 +4521,7 @@ void tst_qqmlecmascript::scarceResources() QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus); } - QVERIFY(ep->scarceResources.isEmpty()); + QVERIFY(v4->scarceResources.isEmpty()); delete object; } @@ -4631,13 +4669,6 @@ void tst_qqmlecmascript::propertyVarCpp() delete object; } -static void gc(QQmlEngine &engine) -{ - engine.collectGarbage(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); -} - void tst_qqmlecmascript::propertyVarOwnership() { // Referenced JS objects are not collected @@ -4738,8 +4769,7 @@ void tst_qqmlecmascript::propertyVarImplicitOwnership() QCoreApplication::processEvents(); QVERIFY(!qobjectGuard.isNull()); QMetaObject::invokeMethod(object, "deassignCircular"); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QVERIFY(qobjectGuard.isNull()); // should have been collected now. delete object; } @@ -4773,15 +4803,13 @@ void tst_qqmlecmascript::propertyVarReparent() // now reparent the "Image" object (currently, it has JS ownership) image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent. QMetaObject::invokeMethod(text2, "deassignVp"); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QCOMPARE(text->property("textCanary").toInt(), 11); QCOMPARE(text2->property("textCanary").toInt(), 22); QVERIFY(!imageGuard.isNull()); // should still be alive. QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2 - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted. delete object; } @@ -4817,8 +4845,7 @@ void tst_qqmlecmascript::propertyVarReparentNullContext() // now reparent the "Image" object (currently, it has JS ownership) image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid. QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2 - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QVERIFY(!imageGuard.isNull()); // should still be alive. QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context). delete object; @@ -4840,12 +4867,10 @@ void tst_qqmlecmascript::propertyVarCircular() QPixmap canaryResourcePixmap = canaryResourceVariant.value<QPixmap>(); canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory. QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog. QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QCOMPARE(object->property("canaryInt"), QVariant(2)); QCOMPARE(object->property("canaryResource"), QVariant(1)); QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted. @@ -4874,23 +4899,22 @@ void tst_qqmlecmascript::propertyVarCircular2() QCOMPARE(rootObject->property("rectCanary").toInt(), 5); QCOMPARE(childObject->property("textCanary").toInt(), 10); QMetaObject::invokeMethod(object, "deassignCircular"); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); + gc(engine); QVERIFY(rootObjectTracker.isNull()); // should have been collected QVERIFY(childObjectTracker.isNull()); // should have been collected delete object; } -void tst_qqmlecmascript::propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter) -{ - *(int*)(parameter) += 1; - qPersistentDispose(object); -} +#if defined(Q_CC_GNU) +#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 +#define pop_gcc_flags +#pragma GCC push_options +#pragma GCC optimize ("O0") +#endif +#endif void tst_qqmlecmascript::propertyVarInheritance() { - int propertyVarWeakRefCallbackCount = 0; - // enforce behaviour regarding element inheritance - ensure handle disposal. // The particular component under test here has a chain of references. QQmlComponent component(&engine, testFileUrl("propertyVar.inherit.qml")); @@ -4902,30 +4926,38 @@ void tst_qqmlecmascript::propertyVarInheritance() // we want to be able to track when the varProperties array of the last metaobject is disposed QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>(); QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>(); + QVERIFY(cco5); + QVERIFY(ico5); QQmlVMEMetaObject *icovmemo = QQmlVMEMetaObject::get(ico5); QQmlVMEMetaObject *ccovmemo = QQmlVMEMetaObject::get(cco5); - v8::Persistent<v8::Value> icoCanaryHandle; - v8::Persistent<v8::Value> ccoCanaryHandle; + QV4::WeakValue icoCanaryHandle; + QV4::WeakValue ccoCanaryHandle; { - v8::HandleScope hs; // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only // public function which can return us a handle to something in the varProperties array. - icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"))); - ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ"))); - // we make them weak and invoke the gc, but we should not hit the weak-callback yet - // as the varproperties array of each vmemo still references the resource. - icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); - ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); + QV4::Value tmp = icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ")); + icoCanaryHandle = tmp; + tmp = ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")); + ccoCanaryHandle = tmp; + tmp = QV4::Value::nullValue(); + QVERIFY(!icoCanaryHandle.isEmpty()); + QVERIFY(!ccoCanaryHandle.isEmpty()); gc(engine); - QVERIFY(propertyVarWeakRefCallbackCount == 0); + QVERIFY(!icoCanaryHandle.isEmpty()); + QVERIFY(!ccoCanaryHandle.isEmpty()); } // now we deassign the var prop, which should trigger collection of item subtrees. QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); // ensure that there are only weak handles to the underlying varProperties array remaining. gc(engine); - QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak. + // an equivalent for pragma GCC optimize is still work-in-progress for CLang, so this test will fail. +#if defined(Q_CC_MSVC) + QSKIP("This test does not work reliably with MSVC."); +#endif +#if !defined(Q_CC_CLANG) + QVERIFY(icoCanaryHandle.isEmpty()); + QVERIFY(ccoCanaryHandle.isEmpty()); +#endif delete object; // since there are no parent vmemo's to keep implicit references alive, and the only handles // to what remains are weak, all varProperties arrays must have been collected. @@ -4933,8 +4965,6 @@ void tst_qqmlecmascript::propertyVarInheritance() void tst_qqmlecmascript::propertyVarInheritance2() { - int propertyVarWeakRefCallbackCount = 0; - // The particular component under test here does NOT have a chain of references; the // only link between rootObject and childObject is that rootObject is the parent of childObject. QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml")); @@ -4949,24 +4979,31 @@ void tst_qqmlecmascript::propertyVarInheritance2() QVERIFY(childObject != 0); QCOMPARE(rootObject->property("rectCanary").toInt(), 5); QCOMPARE(childObject->property("textCanary").toInt(), 10); - v8::Persistent<v8::Value> childObjectVarArrayValueHandle; + QV4::WeakValue childObjectVarArrayValueHandle; { - v8::HandleScope hs; - propertyVarWeakRefCallbackCount = 0; // reset callback count. - childObjectVarArrayValueHandle = qPersistentNew(QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp"))); - childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); + QV4::Value tmp = QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp")); + childObjectVarArrayValueHandle = tmp; + tmp = QV4::Value::nullValue(); + QVERIFY(!childObjectVarArrayValueHandle.isEmpty()); gc(engine); - QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet. + QVERIFY(!childObjectVarArrayValueHandle.isEmpty()); // should not have been collected yet. QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject); QCOMPARE(childObject->property("textCanary").toInt(), 10); } QMetaObject::invokeMethod(object, "deassignCircular"); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. - QCoreApplication::processEvents(); - QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now. + gc(engine); + // an equivalent for pragma GCC optimize is still work-in-progress for CLang, so this test will fail. +#if !defined(Q_CC_CLANG) + QVERIFY(childObjectVarArrayValueHandle.isEmpty()); // should have been collected now. +#endif delete object; } +#if defined(pop_gcc_flags) +#pragma GCC pop_options +#endif + + // Ensure that QObject type conversion works on binding assignment void tst_qqmlecmascript::elementAssign() { @@ -5031,7 +5068,6 @@ void tst_qqmlecmascript::booleanConversion() void tst_qqmlecmascript::handleReferenceManagement() { - int dtorCount = 0; { // Linear QObject reference @@ -5043,7 +5079,7 @@ void tst_qqmlecmascript::handleReferenceManagement() cro->setEngine(&hrmEngine); cro->setDtorCount(&dtorCount); QMetaObject::invokeMethod(object, "createReference"); - gc(engine); + gc(hrmEngine); QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference delete object; hrmEngine.collectGarbage(); @@ -5063,7 +5099,7 @@ void tst_qqmlecmascript::handleReferenceManagement() cro->setEngine(&hrmEngine); cro->setDtorCount(&dtorCount); QMetaObject::invokeMethod(object, "circularReference"); - gc(engine); + gc(hrmEngine); QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive. delete object; hrmEngine.collectGarbage(); @@ -5072,230 +5108,6 @@ void tst_qqmlecmascript::handleReferenceManagement() QCOMPARE(dtorCount, 3); } - dtorCount = 0; - { - // Linear handle reference - QQmlEngine hrmEngine; - QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh"); - QVERIFY(crh != 0); - crh->setEngine(&hrmEngine); - crh->setDtorCount(&dtorCount); - QMetaObject::invokeMethod(object, "createReference"); - CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>(); - QVERIFY(first != 0); - QVERIFY(second != 0); - first->addReference(QQmlData::get(second)->v8object); // create reference - // now we have to reparent second and make second owned by JS. - second->setParent(0); - QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership); - gc(engine); - QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected. - delete object; - hrmEngine.collectGarbage(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 3); - } - - dtorCount = 0; - { - // Circular handle reference - QQmlEngine hrmEngine; - QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh"); - QVERIFY(crh != 0); - crh->setEngine(&hrmEngine); - crh->setDtorCount(&dtorCount); - QMetaObject::invokeMethod(object, "circularReference"); - CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>(); - QVERIFY(first != 0); - QVERIFY(second != 0); - first->addReference(QQmlData::get(second)->v8object); // create circular reference - second->addReference(QQmlData::get(first)->v8object); // note: must be weak. - // now we have to reparent and change ownership, and unset the property references. - first->setParent(0); - second->setParent(0); - QQmlEngine::setObjectOwnership(first, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership); - object->setProperty("first", QVariant::fromValue<QObject*>(0)); - object->setProperty("second", QVariant::fromValue<QObject*>(0)); - gc(engine); - QCOMPARE(dtorCount, 2); // despite circular references, both will be collected. - delete object; - hrmEngine.collectGarbage(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 3); - } - - dtorCount = 0; - { - // multiple engine interaction - linear reference - QQmlEngine hrmEngine1; - QQmlEngine hrmEngine2; - QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); - QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); - QObject *object1 = component1.create(); - QObject *object2 = component2.create(); - QVERIFY(object1 != 0); - QVERIFY(object2 != 0); - CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh"); - CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh"); - QVERIFY(crh1 != 0); - QVERIFY(crh2 != 0); - crh1->setEngine(&hrmEngine1); - crh2->setEngine(&hrmEngine2); - crh1->setDtorCount(&dtorCount); - crh2->setDtorCount(&dtorCount); - QMetaObject::invokeMethod(object1, "createReference"); - QMetaObject::invokeMethod(object2, "createReference"); - CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>(); - CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>(); - QVERIFY(first1 != 0); - QVERIFY(second1 != 0); - QVERIFY(first2 != 0); - QVERIFY(second2 != 0); - first1->addReference(QQmlData::get(second2)->v8object); // create reference across engines - // now we have to reparent second2 and make second2 owned by JS. - second2->setParent(0); - QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); - gc(engine); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected. - delete object1; - delete object2; - hrmEngine1.collectGarbage(); - hrmEngine2.collectGarbage(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 6); - } - - dtorCount = 0; - { - // multiple engine interaction - circular reference - QQmlEngine hrmEngine1; - QQmlEngine hrmEngine2; - QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); - QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); - QObject *object1 = component1.create(); - QObject *object2 = component2.create(); - QVERIFY(object1 != 0); - QVERIFY(object2 != 0); - CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh"); - CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh"); - QVERIFY(crh1 != 0); - QVERIFY(crh2 != 0); - crh1->setEngine(&hrmEngine1); - crh2->setEngine(&hrmEngine2); - crh1->setDtorCount(&dtorCount); - crh2->setDtorCount(&dtorCount); - QMetaObject::invokeMethod(object1, "createReference"); - QMetaObject::invokeMethod(object2, "createReference"); - CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>(); - CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>(); - QVERIFY(first1 != 0); - QVERIFY(second1 != 0); - QVERIFY(first2 != 0); - QVERIFY(second2 != 0); - first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1 - second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines - second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2 - first2->addReference(QQmlData::get(first1)->v8object); // close the loop - circular ref across engines - // now we have to reparent and change ownership to JS, and remove property references. - first1->setParent(0); - second1->setParent(0); - first2->setParent(0); - second2->setParent(0); - QQmlEngine::setObjectOwnership(first1, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); - object1->setProperty("first", QVariant::fromValue<QObject*>(0)); - object1->setProperty("second", QVariant::fromValue<QObject*>(0)); - object2->setProperty("first", QVariant::fromValue<QObject*>(0)); - object2->setProperty("second", QVariant::fromValue<QObject*>(0)); - gc(engine); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive. - delete object1; - delete object2; - hrmEngine1.collectGarbage(); - hrmEngine2.collectGarbage(); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 6); - } - - dtorCount = 0; - { - // multiple engine interaction - linear reference with engine deletion - QQmlEngine *hrmEngine1 = new QQmlEngine; - QQmlEngine *hrmEngine2 = new QQmlEngine; - QQmlComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); - QQmlComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); - QObject *object1 = component1.create(); - QObject *object2 = component2.create(); - QVERIFY(object1 != 0); - QVERIFY(object2 != 0); - CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh"); - CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh"); - QVERIFY(crh1 != 0); - QVERIFY(crh2 != 0); - crh1->setEngine(hrmEngine1); - crh2->setEngine(hrmEngine2); - crh1->setDtorCount(&dtorCount); - crh2->setDtorCount(&dtorCount); - QMetaObject::invokeMethod(object1, "createReference"); - QMetaObject::invokeMethod(object2, "createReference"); - CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>(); - CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>(); - CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>(); - QVERIFY(first1 != 0); - QVERIFY(second1 != 0); - QVERIFY(first2 != 0); - QVERIFY(second2 != 0); - first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1 - second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines - second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2 - // now we have to reparent and change ownership to JS. - first1->setParent(crh1); - second1->setParent(0); - first2->setParent(0); - second2->setParent(0); - QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership); - QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); - gc(*hrmEngine1); - gc(*hrmEngine2); - QCOMPARE(dtorCount, 0); - delete hrmEngine2; // should trigger deletion of objects with JS ownership tracked by this engine - gc(*hrmEngine1); - QCOMPARE(dtorCount, 2); // first2 and second2 should have been deleted. - delete object1; - delete object2; - gc(*hrmEngine1); - QCOMPARE(dtorCount, 6); // deleting object1 and object2 should trigger deletion of first1 and first2. - delete hrmEngine1; - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QCOMPARE(dtorCount, 6); // all objects should have been cleaned up prior to deleting hrmEngine1. - } - { // Dynamic variant property reference keeps target alive QQmlEngine hrmEngine; @@ -5303,11 +5115,11 @@ void tst_qqmlecmascript::handleReferenceManagement() QObject *object = component.create(); QVERIFY(object != 0); QMetaObject::invokeMethod(object, "createReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "removeReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureDeletion"); QCOMPARE(object->property("success").toBool(), true); delete object; @@ -5320,11 +5132,11 @@ void tst_qqmlecmascript::handleReferenceManagement() QObject *object = component.create(); QVERIFY(object != 0); QMetaObject::invokeMethod(object, "createReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "removeReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureDeletion"); QCOMPARE(object->property("success").toBool(), true); delete object; @@ -5337,11 +5149,11 @@ void tst_qqmlecmascript::handleReferenceManagement() QObject *object = component.create(); QVERIFY(object != 0); QMetaObject::invokeMethod(object, "createReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureReference"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "manuallyDelete"); - gc(engine); + gc(hrmEngine); QMetaObject::invokeMethod(object, "ensureDeleted"); QCOMPARE(object->property("success").toBool(), true); delete object; @@ -5602,7 +5414,7 @@ void tst_qqmlecmascript::sequenceConversionBindings() { QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml"); - QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString()); + QString warning = QString(QLatin1String("%1:17:27: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString()); QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QQmlComponent component(&engine, qmlFile); QObject *object = component.create(); @@ -5821,7 +5633,7 @@ void tst_qqmlecmascript::qtbug_9792() delete object; } -// Verifies that QQmlGuard<>s used in the vmemetaobject are cleaned correctly +// Verifies that QPointer<>s used in the vmemetaobject are cleaned correctly void tst_qqmlecmascript::qtcreatorbug_1289() { QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml")); @@ -5969,11 +5781,11 @@ void tst_qqmlecmascript::functionAssignmentfromJS_invalid() QVERIFY(!o->property("a").isValid()); QString url = component.url().toString(); - QString warning = url + ":67:17: Unable to assign QString to int"; + QString warning = url + ":67: Unable to assign QString to int"; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); o->setProperty("assignWrongType", true); - warning = url + ":71:29: Unable to assign QString to int"; + warning = url + ":71: Unable to assign QString to int"; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); o->setProperty("assignWrongTypeToValueType", true); @@ -6026,19 +5838,6 @@ void tst_qqmlecmascript::function() delete o; } -void tst_qqmlecmascript::functionException() -{ - // QTBUG-24037 - shouldn't crash. - QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL"); - QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr)); - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Exception occurred during compilation of function: dynamicSlot()"); - QQmlComponent component(&engine, testFileUrl("v8functionException.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QMetaObject::invokeMethod(o, "dynamicSlot"); - delete o; -} - // Test the "Qt.include" method void tst_qqmlecmascript::include() { @@ -6704,9 +6503,7 @@ void tst_qqmlecmascript::doubleEvaluate() void tst_qqmlecmascript::nonNotifyable() { - QV4Compiler::enableV4(false); QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml")); - QV4Compiler::enableV4(true); QQmlTestMessageHandler messageHandler; @@ -6716,7 +6513,7 @@ void tst_qqmlecmascript::nonNotifyable() QString expected1 = QLatin1String("QQmlExpression: Expression ") + component.url().toString() + - QLatin1String(":5 depends on non-NOTIFYable properties:"); + QLatin1String(":5:24 depends on non-NOTIFYable properties:"); QString expected2 = QLatin1String(" ") + QLatin1String(object->metaObject()->className()) + QLatin1String("::value"); @@ -6791,8 +6588,8 @@ void tst_qqmlecmascript::qtbug_22843() QQmlComponent component(&engine, testFileUrl(fileName)); QString url = component.url().toString(); - QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )"); - QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'"); + QString warning1 = url.left(url.length()-3) + QLatin1String("js:4:16: Expected token `;'"); + QString warning2 = url + QLatin1String(":5: TypeError: Property 'func' of object NaN is not a function"); qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>"); QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>))); @@ -6887,7 +6684,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.4.qml")); - QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int"; + QString warning = component.url().toString() + ":4:12: Unable to assign [undefined] to int"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); @@ -6962,7 +6759,8 @@ void tst_qqmlecmascript::switchStatement() void tst_qqmlecmascript::withStatement() { { - QQmlComponent component(&engine, testFileUrl("withStatement.1.qml")); + QUrl url = testFileUrl("withStatement.1.qml"); + QQmlComponent component(&engine, url); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro index 8c6610158b..fd8c463742 100644 --- a/tests/auto/qml/qqmlengine/qqmlengine.pro +++ b/tests/auto/qml/qqmlengine/qqmlengine.pro @@ -6,5 +6,5 @@ include (../../shared/util.pri) SOURCES += tst_qqmlengine.cpp -QT += core-private gui-private qml-private v8-private network testlib +QT += core-private gui-private qml-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlglobal/qqmlglobal.pro b/tests/auto/qml/qqmlglobal/qqmlglobal.pro index 2715b44fad..d0d9fc400e 100644 --- a/tests/auto/qml/qqmlglobal/qqmlglobal.pro +++ b/tests/auto/qml/qqmlglobal/qqmlglobal.pro @@ -4,5 +4,5 @@ SOURCES += tst_qqmlglobal.cpp macx:CONFIG -= app_bundle CONFIG += parallel_test -QT += qml-private testlib v8-private core-private gui-private +QT += qml-private testlib core-private gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlincubator/qqmlincubator.pro b/tests/auto/qml/qqmlincubator/qqmlincubator.pro index 780b69f379..9249061912 100644 --- a/tests/auto/qml/qqmlincubator/qqmlincubator.pro +++ b/tests/auto/qml/qqmlincubator/qqmlincubator.pro @@ -13,5 +13,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private network testlib +QT += core-private gui-private qml-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro index 73f29ab973..648abd2945 100644 --- a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro +++ b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro @@ -7,5 +7,5 @@ CONFIG += parallel_test include (../../shared/util.pri) -QT += core-private gui-private v8-private qml-private testlib +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp index 925eec9403..44ab690f68 100644 --- a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -323,15 +323,6 @@ void tst_qqmlinstruction::dump() } { - QQmlCompiledData::Instruction::StoreV4Binding i; - i.property = 27; - i.value = 2; - i.context = 4; - i.owner = 0; - data->addInstruction(i); - } - - { QQmlCompiledData::Instruction::StoreValueSource i; i.property.coreIndex = 29; i.castValue = 4; @@ -531,32 +522,31 @@ void tst_qqmlinstruction::dump() << "29\t\tASSIGN_SIGNAL_OBJECT\t4" << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" << "31\t\tSTORE_BINDING\t26\t3\t2" - << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" - << "33\t\tSTORE_VALUE_SOURCE\t29\t4" - << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4" - << "35\t\tBEGIN\t\t\t4" - << "36\t\tSTORE_OBJECT_QLIST" - << "37\t\tASSIGN_OBJECT_LIST" - << "38\t\tFETCH_ATTACHED\t\t23" - << "39\t\tFETCH_QLIST\t\t32" - << "40\t\tFETCH\t\t\t33" - << "41\t\tFETCH_VALUE\t\t34\t6\t7" - << "42\t\tPOP" - << "43\t\tPOP_QLIST" - << "44\t\tPOP_VALUE\t\t35\t8" + << "32\t\tSTORE_VALUE_SOURCE\t29\t4" + << "33\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4" + << "34\t\tBEGIN\t\t\t4" + << "35\t\tSTORE_OBJECT_QLIST" + << "36\t\tASSIGN_OBJECT_LIST" + << "37\t\tFETCH_ATTACHED\t\t23" + << "38\t\tFETCH_QLIST\t\t32" + << "39\t\tFETCH\t\t\t33" + << "40\t\tFETCH_VALUE\t\t34\t6\t7" + << "41\t\tPOP" + << "42\t\tPOP_QLIST" + << "43\t\tPOP_VALUE\t\t35\t8" + << "44\t\tDEFER\t\t\t7" << "45\t\tDEFER\t\t\t7" - << "46\t\tDEFER\t\t\t7" - << "47\t\tSTORE_IMPORTED_SCRIPT\t2" - << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11" - << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" - << "50\t\tDONE" - << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2" - << "52\t\tSTORE_TRID_STRING\t78\t7\t-1" - << "53\t\tSTORE_VAR\t\t79\t5\t\t\"color(1, 1, 1, 1)\"" - << "54\t\tSTORE_VAR_OBJECT\t80" - << "55\t\tSTORE_VAR_INTEGER\t81\t23" - << "56\t\tSTORE_VAR_DOUBLE\t82\t66.3" - << "57\t\tSTORE_VAR_BOOL\t\t83\ttrue" + << "46\t\tSTORE_IMPORTED_SCRIPT\t2" + << "47\t\tSTORE_VARIANT_INTEGER\t\t32\t11" + << "48\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" + << "49\t\tDONE" + << "50\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2" + << "51\t\tSTORE_TRID_STRING\t78\t7\t-1" + << "52\t\tSTORE_VAR\t\t79\t5\t\t\"color(1, 1, 1, 1)\"" + << "53\t\tSTORE_VAR_OBJECT\t80" + << "54\t\tSTORE_VAR_INTEGER\t81\t23" + << "55\t\tSTORE_VAR_DOUBLE\t82\t66.3" + << "56\t\tSTORE_VAR_BOOL\t\t83\ttrue" << "-------------------------------------------------------------------------------"; QQmlTestMessageHandler messageHandler; diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro index 942a511b7f..3b0518cfdf 100644 --- a/tests/auto/qml/qqmllanguage/qqmllanguage.pro +++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro @@ -12,7 +12,7 @@ SOURCES += ../../shared/testhttpserver.cpp TESTDATA = data/* -QT += core-private gui-private v8-private qml-private network testlib +QT += core-private gui-private qml-private network testlib include (../../shared/util.pri) DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index fd35a5b873..852034cbde 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1073,7 +1073,6 @@ void tst_qqmllanguage::bindTypeToJSValue() } { MyQmlObject *object = root->findChild<MyQmlObject *>("urlProperty"); QJSValue value = object->qjsvalue(); - QVERIFY(value.isString()); QUrl encoded; encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode); QCOMPARE(value.toString(), component.url().resolved(encoded).toString()); diff --git a/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro index ef044f1663..1555dc2b2c 100644 --- a/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro +++ b/tests/auto/qml/qqmllistmodel/qqmllistmodel.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index eec312ec4f..4d4eb93149 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -460,7 +460,7 @@ void tst_qqmllistmodel::dynamic_data() QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr; QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "" << dr; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr; QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr; diff --git a/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro b/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro index 14f0604a9b..7647c3d713 100644 --- a/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro +++ b/tests/auto/qml/qqmllistmodelworkerscript/qqmllistmodelworkerscript.pro @@ -8,5 +8,5 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp index a0edfb6891..828aaeb1ea 100644 --- a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp +++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp @@ -269,7 +269,7 @@ void tst_qqmllistmodelworkerscript::dynamic_data() QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr; QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "" << dr; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr; QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr; diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 53e49a4b9e..8e3626ddf2 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -931,6 +931,7 @@ void tst_qqmllocale::dateFromLocaleString_data() void tst_qqmllocale::dateFromLocaleString() { + QSKIP("Needs fixes in our date time parser"); QFETCH(QString, locale); QFETCH(QString, format); @@ -963,18 +964,19 @@ void tst_qqmllocale::dateFromLocaleDateString_data() QTest::addColumn<QString>("format"); QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP"; - QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat(); - QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat(); - QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(); - QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(); - QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateFormat(); + QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateFormat(QLocale::ShortFormat); + QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateFormat(); + QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateFormat(QLocale::ShortFormat); + QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateFormat(); + QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateFormat(QLocale::ShortFormat); + QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateFormat(); + QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateFormat(QLocale::ShortFormat); } void tst_qqmllocale::dateFromLocaleDateString() { + QSKIP("Needs fixes in our date time parser"); QFETCH(QString, locale); QFETCH(QString, format); @@ -1007,18 +1009,19 @@ void tst_qqmllocale::dateFromLocaleTimeString_data() QTest::addColumn<QString>("format"); QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP"; - QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat(); - QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat(); - QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(); - QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat); - QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(); - QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("en_US long") << "en_US" << QLocale("en_US").timeFormat(); + QTest::newRow("en_US short") << "en_US" << QLocale("en_US").timeFormat(QLocale::ShortFormat); + QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").timeFormat(); + QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").timeFormat(QLocale::ShortFormat); + QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").timeFormat(); + QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").timeFormat(QLocale::ShortFormat); + QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").timeFormat(); + QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").timeFormat(QLocale::ShortFormat); } void tst_qqmllocale::dateFromLocaleTimeString() { + QSKIP("Needs fixes in our date time parser"); QFETCH(QString, locale); QFETCH(QString, format); diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro index a9a6a32a2b..54a6e0507f 100644 --- a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro +++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro @@ -7,5 +7,5 @@ TESTDATA = data/* include (../../shared/util.pri) CONFIG += parallel_test -QT += core-private gui-private qml-private testlib v8-private +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 509764c833..ab8ff0e1a4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -539,7 +539,7 @@ void tst_qqmlmoduleplugin::importStrictModule_data() << "import com.nokia.InvalidFirstCommandModule 1.0\n" "MyPluginType {}" << QString() - << ":1:1: module identifier directive must be the first command in a qmldir file"; + << ":1:1: module identifier directive must be the first directive in a qmldir file"; } QTEST_MAIN(tst_qqmlmoduleplugin) diff --git a/tests/auto/qml/qqmlproperty/data/invalidBinding.qml b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml index e2bb1d172d..9364cdaea7 100644 --- a/tests/auto/qml/qqmlproperty/data/invalidBinding.qml +++ b/tests/auto/qml/qqmlproperty/data/invalidBinding.qml @@ -4,7 +4,7 @@ Item { property Text text: myText property Rectangle rectangle1: myText - property Rectangle rectangle2: eval('getMyText()') // eval to force non-shared (v8) binding + property Rectangle rectangle2: getMyText() function getMyText() { return myText; } diff --git a/tests/auto/qml/qqmlproperty/qqmlproperty.pro b/tests/auto/qml/qqmlproperty/qqmlproperty.pro index 1ec02177ea..c2177d5fbf 100644 --- a/tests/auto/qml/qqmlproperty/qqmlproperty.pro +++ b/tests/auto/qml/qqmlproperty/qqmlproperty.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private testlib +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 9b83698591..418e2edf27 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -151,7 +151,7 @@ void tst_qqmlproperty::qmlmetaproperty() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -367,7 +367,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -415,7 +415,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -470,7 +470,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -518,7 +518,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -568,7 +568,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -617,7 +617,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -671,7 +671,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -719,7 +719,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -774,7 +774,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -822,7 +822,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -872,7 +872,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -921,7 +921,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); QVERIFY(binding != 0); - QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1); + QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); @@ -1103,7 +1103,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); + QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -1115,7 +1115,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); + QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -1271,7 +1271,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); + QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1285,7 +1285,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1))); + QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1856,7 +1856,7 @@ void tst_qqmlproperty::warnOnInvalidBinding() QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); // V8 error message for invalid binding to anchor - expectedWarning = testUrl.toString() + QString::fromLatin1(":14: Unable to assign QQuickItem_QML_6 to QQuickAnchorLine"); + expectedWarning = testUrl.toString() + QString::fromLatin1(":14:33: Unable to assign QQuickItem_QML_6 to QQuickAnchorLine"); QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); QQmlComponent component(&engine, testUrl); diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro index 5f75015d0d..7cc83cd440 100644 --- a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro +++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro @@ -5,5 +5,5 @@ macx:CONFIG -= app_bundle SOURCES += tst_qqmlpropertycache.cpp CONFIG += parallel_test -QT += core-private gui-private qml-private testlib v8-private +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlqt/qqmlqt.pro b/tests/auto/qml/qqmlqt/qqmlqt.pro index 0be49304fb..0470156e28 100644 --- a/tests/auto/qml/qqmlqt/qqmlqt.pro +++ b/tests/auto/qml/qqmlqt/qqmlqt.pro @@ -8,5 +8,5 @@ macx:CONFIG -= app_bundle TESTDATA = data/* -QT += core-private v8-private qml-private quick-private testlib gui gui-private +QT += core-private qml-private quick-private testlib gui gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlsettings/data/aliases.qml b/tests/auto/qml/qqmlsettings/data/aliases.qml new file mode 100644 index 0000000000..ac746a16a2 --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/aliases.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.1 +import QtQuick 2.2 +import Qt.labs.settings 1.0 + +QtObject { + id: root + + property int intProperty: 123 + property bool boolProperty: true + property real realProperty: 1.23 + property double doubleProperty: 3.45 + property string stringProperty: "foo" + property url urlProperty: "http://www.qt-project.org" + property var intListProperty: [1, 2, 3] + property var stringListProperty: ["a", "b", "c"] + property date dateProperty: "2000-01-02" + // QTBUG-32295: Expected property type + //property time timeProperty: "12:34:56" + property size sizeProperty: Qt.size(12, 34) + property point pointProperty: Qt.point(12, 34) + property rect rectProperty: Qt.rect(1, 2, 3, 4) + property color colorProperty: "red" + property font fontProperty + + property Settings settings: Settings { + id: settings + + property alias intProperty: root.intProperty + property alias boolProperty: root.boolProperty + property alias realProperty: root.realProperty + property alias doubleProperty: root.doubleProperty + property alias stringProperty: root.stringProperty + property alias urlProperty: root.urlProperty + property alias intListProperty: root.intListProperty + property alias stringListProperty: root.stringListProperty + property alias dateProperty: root.dateProperty + // QTBUG-32295: Expected property type + //property alias timeProperty: root.timeProperty + property alias sizeProperty: root.sizeProperty + property alias pointProperty: root.pointProperty + property alias rectProperty: root.rectProperty + property alias colorProperty: root.colorProperty + property alias fontProperty: root.fontProperty + } +} diff --git a/tests/auto/qml/qqmlsettings/data/basic.qml b/tests/auto/qml/qqmlsettings/data/basic.qml new file mode 100644 index 0000000000..1ac377036e --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/basic.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt.labs.settings 1.0 + +Settings { + property bool success: true +} diff --git a/tests/auto/qml/qqmlsettings/data/categories.qml b/tests/auto/qml/qqmlsettings/data/categories.qml new file mode 100644 index 0000000000..77110c0b05 --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/categories.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import Qt.labs.settings 1.0 + +Settings { + category: "initialCategory" + property string value: "initialValue" +} diff --git a/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml new file mode 100644 index 0000000000..41c2f58da7 --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.1 +import QtQuick 2.2 +import Qt.labs.settings 1.0 +import Qt.test 1.0 + +CppObject { + id: obj + + property Settings settings: Settings { + property alias intProperty: obj.intProperty + property alias boolProperty: obj.boolProperty + property alias realProperty: obj.realProperty + property alias doubleProperty: obj.doubleProperty + property alias stringProperty: obj.stringProperty + property alias urlProperty: obj.urlProperty + property alias intListProperty: obj.intListProperty + property alias stringListProperty: obj.stringListProperty + property alias dateProperty: obj.dateProperty + // QTBUG-32295: Expected property type + //property alias timeProperty: obj.timeProperty + property alias sizeProperty: obj.sizeProperty + property alias pointProperty: obj.pointProperty + property alias rectProperty: obj.rectProperty + property alias colorProperty: obj.colorProperty + property alias fontProperty: obj.fontProperty + } +} diff --git a/tests/auto/qml/qqmlsettings/data/siblings.qml b/tests/auto/qml/qqmlsettings/data/siblings.qml new file mode 100644 index 0000000000..4e388b4747 --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/siblings.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import Qt.labs.settings 1.0 + +Item { + id: root + + Item { + id: sibling1 + property string prop1: "value1" + } + + Settings { + property alias alias1: sibling1.prop1 + property alias alias2: sibling2.prop2 + } + + Item { + id: sibling2 + property string prop2: "value2" + } +} diff --git a/tests/auto/qml/qqmlsettings/data/types.qml b/tests/auto/qml/qqmlsettings/data/types.qml new file mode 100644 index 0000000000..7adcc5fc1d --- /dev/null +++ b/tests/auto/qml/qqmlsettings/data/types.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQml 2.1 +import QtQuick 2.2 +import Qt.labs.settings 1.0 + +QtObject { + id: root + + property int intProperty + property bool boolProperty + property real realProperty + property double doubleProperty + property string stringProperty + property url urlProperty + property var intListProperty + property var stringListProperty + property date dateProperty + // QTBUG-32295: Expected property type + // property time timeProperty + property size sizeProperty + property point pointProperty + property rect rectProperty + property color colorProperty + property font fontProperty + + function readSettings() { + __setProperties(settings, root) + } + + function writeSettings() { + __setProperties(root, settings) + } + + function __setProperties(from, to) { + to.intProperty = from.intProperty + to.boolProperty = from.boolProperty + to.realProperty = from.realProperty + to.doubleProperty = from.doubleProperty + to.stringProperty = from.stringProperty + to.urlProperty = from.urlProperty + to.intListProperty = from.intListProperty + to.stringListProperty = from.stringListProperty + to.dateProperty = from.dateProperty + //to.timeProperty = from.timeProperty + to.sizeProperty = from.sizeProperty + to.pointProperty = from.pointProperty + to.rectProperty = from.rectProperty + to.colorProperty = from.colorProperty + to.fontProperty = from.fontProperty + } + + property Settings settings: Settings { + id: settings + + property int intProperty: 123 + property bool boolProperty: true + property real realProperty: 1.23 + property double doubleProperty: 3.45 + property string stringProperty: "foo" + property url urlProperty: "http://www.qt-project.org" + property var intListProperty: [1, 2, 3] + property var stringListProperty: ["a", "b", "c"] + property date dateProperty: "2000-01-02" + // QTBUG-32295: Expected property type + //property time timeProperty: "12:34:56" + property size sizeProperty: Qt.size(12, 34) + property point pointProperty: Qt.point(12, 34) + property rect rectProperty: Qt.rect(1, 2, 3, 4) + property color colorProperty: "red" + property font fontProperty + } +} diff --git a/tests/auto/qml/qqmlsettings/qqmlsettings.pro b/tests/auto/qml/qqmlsettings/qqmlsettings.pro new file mode 100644 index 0000000000..efcef27f7e --- /dev/null +++ b/tests/auto/qml/qqmlsettings/qqmlsettings.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qqmlsettings +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlsettings.cpp + +include (../../shared/util.pri) + +TESTDATA = data/* + +QT += qml testlib +CONFIG += parallel_test diff --git a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp new file mode 100644 index 0000000000..897450823c --- /dev/null +++ b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp @@ -0,0 +1,584 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> +#include <QtCore/QCoreApplication> +#include <QtCore/QScopedPointer> +#include <QtCore/QSettings> +#include <QtCore/QVariant> +#include <QtGui/QColor> +#include <QtGui/QFont> +#include <QtQml/QQmlEngine> +#include <QtQml/QQmlComponent> +#include "../../shared/util.h" + +class tst_QQmlSettings : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void init(); + void cleanup(); + + void basic(); + void types(); + void aliases_data(); + void aliases(); + void categories(); + void siblings(); +}; + +class CppObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty NOTIFY boolPropertyChanged) + Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty NOTIFY realPropertyChanged) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty NOTIFY doublePropertyChanged) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlPropertyChanged) + Q_PROPERTY(QVariant varProperty READ varProperty WRITE setVarProperty NOTIFY varPropertyChanged) + Q_PROPERTY(QVariantList intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged) + Q_PROPERTY(QVariantList stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged) + Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty NOTIFY datePropertyChanged) + // QTBUG-32295: Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty NOTIFY timePropertyChanged) + Q_PROPERTY(QSizeF sizeProperty READ sizeProperty WRITE setSizeProperty NOTIFY sizePropertyChanged) + Q_PROPERTY(QPointF pointProperty READ pointProperty WRITE setPointProperty NOTIFY pointPropertyChanged) + Q_PROPERTY(QRectF rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty NOTIFY colorPropertyChanged) + Q_PROPERTY(QFont fontProperty READ fontProperty WRITE setFontProperty NOTIFY fontPropertyChanged) + +public: + CppObject(QObject *parent = 0) : QObject(parent), + m_intProperty(123), + m_boolProperty(true), + m_realProperty(1.23), + m_doubleProperty(3.45), + m_stringProperty("foo"), + m_urlProperty("http://www.qt-project.org"), + m_intListProperty(QVariantList() << 1 << 2 << 3), + m_stringListProperty(QVariantList() << "a" << "b" << "c"), + m_dateProperty(2000, 1, 2), + // QTBUG-32295: m_timeProperty(12, 34, 56), + m_sizeProperty(12, 34), + m_pointProperty(12, 34), + m_rectProperty(1, 2, 3, 4), + m_colorProperty("red") + { + } + + int intProperty() const { return m_intProperty; } + bool boolProperty() const { return m_boolProperty; } + qreal realProperty() const { return m_realProperty; } + double doubleProperty() const { return m_doubleProperty; } + QString stringProperty() const { return m_stringProperty; } + QUrl urlProperty() const { return m_urlProperty; } + QVariant varProperty() const { return m_varProperty; } + QVariantList intListProperty() const { return m_intListProperty; } + QVariantList stringListProperty() const { return m_stringListProperty; } + QDate dateProperty() const { return m_dateProperty; } + QSizeF sizeProperty() const { return m_sizeProperty; } + QPointF pointProperty() const { return m_pointProperty; } + QRectF rectProperty() const { return m_rectProperty; } + QColor colorProperty() const { return m_colorProperty; } + QFont fontProperty() const { return m_fontProperty; } + +public slots: + void setIntProperty(int arg) + { + if (m_intProperty != arg) { + m_intProperty = arg; + emit intPropertyChanged(arg); + } + } + + void setBoolProperty(bool arg) + { + if (m_boolProperty != arg) { + m_boolProperty = arg; + emit boolPropertyChanged(arg); + } + } + + void setRealProperty(qreal arg) + { + if (m_realProperty != arg) { + m_realProperty = arg; + emit realPropertyChanged(arg); + } + } + + void setDoubleProperty(double arg) + { + if (m_doubleProperty != arg) { + m_doubleProperty = arg; + emit doublePropertyChanged(arg); + } + } + + void setStringProperty(const QString &arg) + { + if (m_stringProperty != arg) { + m_stringProperty = arg; + emit stringPropertyChanged(arg); + } + } + + void setUrlProperty(const QUrl &arg) + { + if (m_urlProperty != arg) { + m_urlProperty = arg; + emit urlPropertyChanged(arg); + } + } + + void setVarProperty(const QVariant &arg) + { + if (m_varProperty != arg) { + m_varProperty = arg; + emit varPropertyChanged(arg); + } + } + + void setIntListProperty(const QVariantList &arg) + { + if (m_intListProperty != arg) { + m_intListProperty = arg; + emit intListPropertyChanged(arg); + } + } + + void setStringListProperty(const QVariantList &arg) + { + if (m_stringListProperty != arg) { + m_stringListProperty = arg; + emit stringListPropertyChanged(arg); + } + } + + void setDateProperty(const QDate &arg) + { + if (m_dateProperty != arg) { + m_dateProperty = arg; + emit datePropertyChanged(arg); + } + } + + void setSizeProperty(const QSizeF &arg) + { + if (m_sizeProperty != arg) { + m_sizeProperty = arg; + emit sizePropertyChanged(arg); + } + } + + void setPointProperty(const QPointF &arg) + { + if (m_pointProperty != arg) { + m_pointProperty = arg; + emit pointPropertyChanged(arg); + } + } + + void setRectProperty(const QRectF &arg) + { + if (m_rectProperty != arg) { + m_rectProperty = arg; + emit rectPropertyChanged(arg); + } + } + + void setColorProperty(const QColor &arg) + { + if (m_colorProperty != arg) { + m_colorProperty = arg; + emit colorPropertyChanged(arg); + } + } + + void setFontProperty(const QFont &arg) + { + if (m_fontProperty != arg) { + m_fontProperty = arg; + emit fontPropertyChanged(arg); + } + } + +signals: + void intPropertyChanged(int arg); + void boolPropertyChanged(bool arg); + void realPropertyChanged(qreal arg); + void doublePropertyChanged(double arg); + void stringPropertyChanged(const QString &arg); + void urlPropertyChanged(const QUrl &arg); + void varPropertyChanged(const QVariant &arg); + void intListPropertyChanged(const QVariantList &arg); + void stringListPropertyChanged(const QVariantList &arg); + void datePropertyChanged(const QDate &arg); + void sizePropertyChanged(const QSizeF &arg); + void pointPropertyChanged(const QPointF &arg); + void rectPropertyChanged(const QRectF &arg); + void colorPropertyChanged(const QColor &arg); + void fontPropertyChanged(const QFont &arg); + +private: + int m_intProperty; + bool m_boolProperty; + qreal m_realProperty; + double m_doubleProperty; + QString m_stringProperty; + QUrl m_urlProperty; + QVariant m_varProperty; + QVariantList m_intListProperty; + QVariantList m_stringListProperty; + QDate m_dateProperty; + QSizeF m_sizeProperty; + QPointF m_pointProperty; + QRectF m_rectProperty; + QColor m_colorProperty; + QFont m_fontProperty; +}; + +void tst_QQmlSettings::initTestCase() +{ + QQmlDataTest::initTestCase(); + + QCoreApplication::setApplicationName("tst_QQmlSettings"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setOrganizationDomain("qt-project.org"); + + qmlRegisterType<CppObject>("Qt.test", 1, 0, "CppObject"); +} + +void tst_QQmlSettings::init() +{ + QSettings settings; + settings.clear(); +} + +void tst_QQmlSettings::cleanup() +{ + QSettings settings; + settings.clear(); +} + +void tst_QQmlSettings::basic() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("basic.qml")); + QScopedPointer<QObject> root(component.create()); + QVERIFY(root.data()); + QVERIFY(root->property("success").toBool()); + QSettings settings; + QTRY_VERIFY(settings.value("success").toBool()); +} + +void tst_QQmlSettings::types() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("types.qml")); + QScopedPointer<QObject> root(component.create()); + QVERIFY(root.data()); + QObject *settings = root->property("settings").value<QObject *>(); + QVERIFY(settings); + + // default property values + QCOMPARE(root->property("intProperty").toInt(), 0); + QCOMPARE(root->property("boolProperty").toBool(), false); + QCOMPARE(root->property("realProperty").toReal(), static_cast<qreal>(0.0)); + QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(0.0)); + QCOMPARE(root->property("stringProperty").toString(), QString()); + QCOMPARE(root->property("urlProperty").toUrl(), QUrl()); + QCOMPARE(root->property("intListProperty").toList(), QVariantList()); + QCOMPARE(root->property("stringListProperty").toList(), QVariantList()); + QCOMPARE(root->property("dateProperty").toDate(), QDate()); + // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime()); + QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF()); + QCOMPARE(root->property("pointProperty").toPointF(), QPointF()); + QCOMPARE(root->property("rectProperty").toRectF(), QRectF()); + QCOMPARE(root->property("colorProperty").value<QColor>(), QColor()); + QCOMPARE(root->property("fontProperty").value<QFont>(), QFont()); + + // default settings values + QCOMPARE(settings->property("intProperty").toInt(), 123); + QCOMPARE(settings->property("boolProperty").toBool(), true); + QCOMPARE(settings->property("realProperty").toReal(), static_cast<qreal>(1.23)); + QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(3.45)); + QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); + QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); + QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); + // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); + QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); + QCOMPARE(settings->property("pointProperty").toPointF(), QPointF(12, 34)); + QCOMPARE(settings->property("rectProperty").toRectF(), QRectF(1, 2, 3, 4)); + QCOMPARE(settings->property("colorProperty").value<QColor>(), QColor(Qt::red)); + QCOMPARE(settings->property("fontProperty").value<QFont>(), QFont()); + + // read settings + QVERIFY(QMetaObject::invokeMethod(root.data(), "readSettings")); + QCOMPARE(root->property("intProperty").toInt(), 123); + QCOMPARE(root->property("boolProperty").toBool(), true); + QCOMPARE(root->property("realProperty").toReal(), static_cast<qreal>(1.23)); + QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(3.45)); + QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); + QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); + QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); + // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); + QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); + QCOMPARE(root->property("pointProperty").toPointF(), QPointF(12, 34)); + QCOMPARE(root->property("rectProperty").toRectF(), QRectF(1, 2, 3, 4)); + QCOMPARE(root->property("colorProperty").value<QColor>(), QColor(Qt::red)); + QCOMPARE(root->property("fontProperty").value<QFont>(), QFont()); + + // change properties + QVERIFY(root->setProperty("intProperty", 456)); + QVERIFY(root->setProperty("boolProperty", false)); + QVERIFY(root->setProperty("realProperty", static_cast<qreal>(4.56))); + QVERIFY(root->setProperty("doubleProperty", static_cast<double>(6.78))); + QVERIFY(root->setProperty("stringProperty", QStringLiteral("bar"))); + QVERIFY(root->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(root->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); + QVERIFY(root->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(root->setProperty("dateProperty", QDate(2010, 02, 01))); + // QTBUG-32295: QVERIFY(root->setProperty("timeProperty", QTime(6, 56, 34))); + QVERIFY(root->setProperty("sizeProperty", QSizeF(56, 78))); + QVERIFY(root->setProperty("pointProperty", QPointF(56, 78))); + QVERIFY(root->setProperty("rectProperty", QRectF(5, 6, 7, 8))); + QVERIFY(root->setProperty("colorProperty", QColor(Qt::blue))); + QFont boldFont; boldFont.setBold(true); + QVERIFY(root->setProperty("fontProperty", boldFont)); + + // write settings + QVERIFY(QMetaObject::invokeMethod(root.data(), "writeSettings")); + QTRY_COMPARE(settings->property("intProperty").toInt(), 456); + QTRY_COMPARE(settings->property("boolProperty").toBool(), false); + QTRY_COMPARE(settings->property("realProperty").toReal(), static_cast<qreal>(4.56)); + QTRY_COMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(6.78)); + QTRY_COMPARE(settings->property("stringProperty").toString(), QStringLiteral("bar")); + QTRY_COMPARE(settings->property("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(settings->property("intListProperty").toList(), QVariantList() << 4 << 5 << 6); + QTRY_COMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(settings->property("dateProperty").toDate(), QDate(2010, 02, 01)); + // QTBUG-32295: QTRY_COMPARE(settings->property("timeProperty").toDate(), QTime(6, 56, 34)); + QTRY_COMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(56, 78)); + QTRY_COMPARE(settings->property("pointProperty").toPointF(), QPointF(56, 78)); + QTRY_COMPARE(settings->property("rectProperty").toRectF(), QRectF(5, 6, 7, 8)); + QTRY_COMPARE(settings->property("colorProperty").value<QColor>(), QColor(Qt::blue)); + QTRY_COMPARE(settings->property("fontProperty").value<QFont>(), boldFont); + + QSettings qs; + QTRY_COMPARE(qs.value("intProperty").toInt(), 456); + QTRY_COMPARE(qs.value("boolProperty").toBool(), false); + QTRY_COMPARE(qs.value("realProperty").toReal(), static_cast<qreal>(4.56)); + QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast<double>(6.78)); + QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); + QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); + QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); + // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); + QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); + QTRY_COMPARE(qs.value("pointProperty").toPointF(), QPointF(56, 78)); + QTRY_COMPARE(qs.value("rectProperty").toRectF(), QRectF(5, 6, 7, 8)); + QTRY_COMPARE(qs.value("colorProperty").value<QColor>(), QColor(Qt::blue)); + QTRY_COMPARE(qs.value("fontProperty").value<QFont>(), boldFont); +} + +void tst_QQmlSettings::aliases_data() +{ + QTest::addColumn<QString>("testFile"); + QTest::newRow("qml") << "aliases.qml"; + QTest::newRow("cpp") << "cpp-aliases.qml"; +} + +void tst_QQmlSettings::aliases() +{ + QFETCH(QString, testFile); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl(testFile)); + QScopedPointer<QObject> root(component.create()); + QVERIFY(root.data()); + QObject *settings = root->property("settings").value<QObject *>(); + QVERIFY(settings); + + // default property values + QCOMPARE(root->property("intProperty").toInt(), 123); + QCOMPARE(root->property("boolProperty").toBool(), true); + QCOMPARE(root->property("realProperty").toReal(), static_cast<qreal>(1.23)); + QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(3.45)); + QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); + QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); + QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); + // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); + QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); + QCOMPARE(root->property("pointProperty").toPointF(), QPointF(12, 34)); + QCOMPARE(root->property("rectProperty").toRectF(), QRectF(1, 2, 3, 4)); + QCOMPARE(root->property("colorProperty").value<QColor>(), QColor(Qt::red)); + QCOMPARE(root->property("fontProperty").value<QFont>(), QFont()); + + // default settings values + QCOMPARE(settings->property("intProperty").toInt(), 123); + QCOMPARE(settings->property("boolProperty").toBool(), true); + QCOMPARE(settings->property("realProperty").toReal(), static_cast<qreal>(1.23)); + QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(3.45)); + QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); + QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); + QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); + // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); + QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); + QCOMPARE(settings->property("pointProperty").toPointF(), QPointF(12, 34)); + QCOMPARE(settings->property("rectProperty").toRectF(), QRectF(1, 2, 3, 4)); + QCOMPARE(settings->property("colorProperty").value<QColor>(), QColor(Qt::red)); + QCOMPARE(settings->property("fontProperty").value<QFont>(), QFont()); + + // change settings + QVERIFY(settings->setProperty("intProperty", 456)); + QVERIFY(settings->setProperty("boolProperty", false)); + QVERIFY(settings->setProperty("realProperty", static_cast<qreal>(4.56))); + QVERIFY(settings->setProperty("doubleProperty", static_cast<double>(6.78))); + QVERIFY(settings->setProperty("stringProperty", QStringLiteral("bar"))); + QVERIFY(settings->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(settings->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); + QVERIFY(settings->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(settings->setProperty("dateProperty", QDate(2010, 02, 01))); + // QTBUG-32295: QVERIFY(settings->setProperty("timeProperty", QTime(6, 56, 34))); + QVERIFY(settings->setProperty("sizeProperty", QSizeF(56, 78))); + QVERIFY(settings->setProperty("pointProperty", QPointF(56, 78))); + QVERIFY(settings->setProperty("rectProperty", QRectF(5, 6, 7, 8))); + QVERIFY(settings->setProperty("colorProperty", QColor(Qt::blue))); + QFont boldFont; boldFont.setBold(true); + QVERIFY(settings->setProperty("fontProperty", boldFont)); + + QSettings qs; + QTRY_COMPARE(qs.value("intProperty").toInt(), 456); + QTRY_COMPARE(qs.value("boolProperty").toBool(), false); + QTRY_COMPARE(qs.value("realProperty").toReal(), static_cast<qreal>(4.56)); + QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast<double>(6.78)); + QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); + QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); + QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); + // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); + QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); + QTRY_COMPARE(qs.value("pointProperty").toPointF(), QPointF(56, 78)); + QTRY_COMPARE(qs.value("rectProperty").toRectF(), QRectF(5, 6, 7, 8)); + QTRY_COMPARE(qs.value("colorProperty").value<QColor>(), QColor(Qt::blue)); + QTRY_COMPARE(qs.value("fontProperty").value<QFont>(), boldFont); +} + +void tst_QQmlSettings::categories() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("categories.qml")); + + { + // initial state + QSettings qs; + QVERIFY(!qs.childGroups().contains("initialCategory")); + QVERIFY(!qs.childGroups().contains("changedCategory")); + QVERIFY(!qs.childKeys().contains("value")); + } + + { + // load & write default values + QScopedPointer<QObject> settings(component.create()); + QVERIFY(settings.data()); + QCOMPARE(settings->property("category").toString(), QStringLiteral("initialCategory")); + QCOMPARE(settings->property("value").toString(), QStringLiteral("initialValue")); + } + + { + // verify written settings & change the value + QSettings qs; + QVERIFY(qs.childGroups().contains("initialCategory")); + qs.beginGroup("initialCategory"); + QVERIFY(qs.childKeys().contains("value")); + QCOMPARE(qs.value("value").toString(), QStringLiteral("initialValue")); + qs.setValue("value", QStringLiteral("changedValue")); + } + + { + // load changed value & change the category + QScopedPointer<QObject> settings(component.create()); + QVERIFY(settings.data()); + QCOMPARE(settings->property("category").toString(), QStringLiteral("initialCategory")); + QCOMPARE(settings->property("value").toString(), QStringLiteral("changedValue")); + QVERIFY(settings->setProperty("category", QStringLiteral("changedCategory"))); + } + + { + // verify written settings + QSettings qs; + QVERIFY(qs.childGroups().contains("changedCategory")); + qs.beginGroup("changedCategory"); + QVERIFY(qs.childKeys().contains("value")); + QCOMPARE(qs.value("value").toString(), QStringLiteral("changedValue")); + qs.setValue("value", QStringLiteral("changedValue")); + qs.endGroup(); + } +} + +void tst_QQmlSettings::siblings() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("siblings.qml")); + delete component.create(); + + // verify setting aliases to destructed siblings + QSettings settings; + QCOMPARE(settings.value("alias1").toString(), QStringLiteral("value1")); + QCOMPARE(settings.value("alias2").toString(), QStringLiteral("value2")); +} + +QTEST_MAIN(tst_QQmlSettings) + +#include "tst_qqmlsettings.moc" diff --git a/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro index bd58608925..c32f3c6c34 100644 --- a/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro +++ b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro @@ -8,5 +8,5 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private sql testlib +QT += core-private gui-private qml-private quick-private sql testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlvaluetypeproviders/qqmlvaluetypeproviders.pro b/tests/auto/qml/qqmlvaluetypeproviders/qqmlvaluetypeproviders.pro index a482db40b4..7ef81e0cc4 100644 --- a/tests/auto/qml/qqmlvaluetypeproviders/qqmlvaluetypeproviders.pro +++ b/tests/auto/qml/qqmlvaluetypeproviders/qqmlvaluetypeproviders.pro @@ -13,5 +13,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private gui testlib +QT += core-private gui-private qml-private quick-private gui testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro index 1d02773146..e318966e56 100644 --- a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro +++ b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro @@ -13,5 +13,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private gui testlib +QT += core-private gui-private qml-private quick-private gui testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index a8e598b11c..7c0507dce3 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -946,7 +946,7 @@ void tst_qqmlvaluetypes::bindingAssignment() // function assignment should fail without crashing { QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6:13: Invalid use of Qt.binding() in a binding declaration."); - QString warning2 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":10: Error: Cannot assign JavaScript function to value-type property"); + QString warning2 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":10: Cannot assign JavaScript function to value-type property"); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); QQmlComponent component(&engine, testFileUrl("bindingAssignment.2.qml")); @@ -1050,7 +1050,7 @@ void tst_qqmlvaluetypes::autoBindingRemoval() { QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); - QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect"; + QString warning = component.url().toString() + ":6:11: Unable to assign [undefined] to QRect"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml index b3a54e9b53..8c027840a1 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml @@ -11,17 +11,17 @@ QtObject { // Attempt to overwrite and delete values var x = new XMLHttpRequest(); - x.UNSENT = 9; - x.OPENED = 9; - x.HEADERS_RECEIVED = 9; - x.LOADING = 9; - x.DONE = 9; + try { x.UNSENT = 9; } catch (e) {} + try { x.OPENED = 9; } catch (e) {} + try { x.HEADERS_RECEIVED = 9; } catch (e) {} + try { x.LOADING = 9; } catch (e) {} + try { x.DONE = 9; } catch (e) {} - delete x.UNSENT; - delete x.OPENED; - delete x.HEADERS_RECEIVED; - delete x.LOADING; - delete x.DONE; + try { delete x.UNSENT; } catch (e) {} + try { delete x.OPENED; } catch (e) {} + try { delete x.HEADERS_RECEIVED; } catch (e) {} + try { delete x.LOADING; } catch (e) {} + try { delete x.DONE; } catch (e) {} unsent = x.UNSENT opened = x.OPENED diff --git a/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml b/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml new file mode 100644 index 0000000000..b65ace2f78 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/showDotAndDotDot.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + showDotAndDotDot: false +} diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index ef24e0a2d2..7045263130 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -71,6 +71,7 @@ public slots: private slots: void basicProperties(); + void showFiles(); void resetFiltering(); void refresh(); void cdUp(); @@ -78,6 +79,8 @@ private slots: // WinCE does not have drive concept, so lets execute this test only on desktop Windows. void changeDrive(); #endif + void showDotAndDotDot(); + void showDotAndDotDot_data(); private: void checkNoErrors(const QQmlComponent& component); @@ -113,13 +116,23 @@ void tst_qquickfolderlistmodel::basicProperties() QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); QVERIFY(flm != 0); + QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); // from basic.qml + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(QDir::currentPath())); + + // wait for the initial directory listing (it will find at least the "data" dir, + // and other dirs on Windows). + QTRY_VERIFY(flm->property("count").toInt() > 0); + + QSignalSpy folderChangedSpy(flm, SIGNAL(folderChanged())); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + QVERIFY(folderChangedSpy.wait()); + QCOMPARE(flm->property("count").toInt(), 5); QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl()); QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath())); QCOMPARE(flm->property("sortField").toInt(), int(Name)); QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showFiles").toBool(), true); QCOMPARE(flm->property("showDirs").toBool(), true); QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); QCOMPARE(flm->property("showOnlyReadable").toBool(), false); @@ -130,6 +143,23 @@ void tst_qquickfolderlistmodel::basicProperties() QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("")); } +void tst_qquickfolderlistmodel::showFiles() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", dataDirectoryUrl()); + QTRY_COMPARE(flm->property("count").toInt(), 5); // wait for refresh + QCOMPARE(flm->property("showFiles").toBool(), true); + + flm->setProperty("showFiles", false); + QCOMPARE(flm->property("showFiles").toBool(), false); + QTRY_COMPARE(flm->property("count").toInt(), 1); // wait for refresh +} + void tst_qquickfolderlistmodel::resetFiltering() { // see QTBUG-17837 @@ -170,7 +200,7 @@ void tst_qquickfolderlistmodel::refresh() QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(),5); // wait for refresh int count = flm->rowCount(); @@ -256,6 +286,49 @@ void tst_qquickfolderlistmodel::changeDrive() } #endif +void tst_qquickfolderlistmodel::showDotAndDotDot() +{ + QFETCH(QUrl, folder); + QFETCH(QUrl, rootFolder); + QFETCH(bool, showDotAndDotDot); + QFETCH(bool, showDot); + QFETCH(bool, showDotDot); + + QQmlComponent component(&engine, testFileUrl("showDotAndDotDot.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", folder); + flm->setProperty("rootFolder", rootFolder); + flm->setProperty("showDotAndDotDot", showDotAndDotDot); + + int count = 5; + if (showDot) count++; + if (showDotDot) count++; + QTRY_COMPARE(flm->property("count").toInt(), count); // wait for refresh + + if (showDot) + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String(".")); + if (showDotDot) + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("..")); +} + +void tst_qquickfolderlistmodel::showDotAndDotDot_data() +{ + QTest::addColumn<QUrl>("folder"); + QTest::addColumn<QUrl>("rootFolder"); + QTest::addColumn<bool>("showDotAndDotDot"); + QTest::addColumn<bool>("showDot"); + QTest::addColumn<bool>("showDotDot"); + + QTest::newRow("false") << dataDirectoryUrl() << QUrl() << false << false << false; + QTest::newRow("true") << dataDirectoryUrl() << QUrl() << true << true << true; + QTest::newRow("true but root") << dataDirectoryUrl() << dataDirectoryUrl() << true << true << false; + +} + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" diff --git a/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro index 56c89fab49..268b45f4e7 100644 --- a/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro +++ b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private testlib +QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index ed8fb9f56f..1530ce83e2 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -235,6 +235,7 @@ void tst_QQuickWorkerScript::script_included() waitForEchoMessage(worker); const QMetaObject *mo = worker->metaObject(); + QEXPECT_FAIL("", "It is not possible to write to the global object right now", Continue); QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World"); qApp->processEvents(); @@ -257,7 +258,7 @@ void tst_QQuickWorkerScript::scriptError_onLoad() QVERIFY(worker != 0); QTRY_COMPARE(qquickworkerscript_lastWarning, - testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier")); + testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3:10: Expected token `,'")); qInstallMessageHandler(previousMsgHandler); qApp->processEvents(); diff --git a/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro b/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro index 36ece8d7e0..c6d442ecac 100644 --- a/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro +++ b/tests/auto/qml/qtqmlmodules/qtqmlmodules.pro @@ -8,5 +8,5 @@ macx:CONFIG -= app_bundle TESTDATA = data/* -QT += core-private v8-private qml-private testlib gui gui-private +QT += core-private qml-private testlib gui gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qv4debugger/qv4debugger.pro b/tests/auto/qml/qv4debugger/qv4debugger.pro new file mode 100644 index 0000000000..2a318955f3 --- /dev/null +++ b/tests/auto/qml/qv4debugger/qv4debugger.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qv4debugger +macx:CONFIG -= app_bundle + +SOURCES += tst_qv4debugger.cpp + +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp new file mode 100644 index 0000000000..7d8f02a952 --- /dev/null +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> + +#include <QJSEngine> +#include <private/qv4engine_p.h> +#include <private/qv4debugging_p.h> +#include <private/qv8engine_p.h> + +static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) +{ + QEventLoop loop; + QObject::connect(obj, signal, &loop, SLOT(quit())); + QTimer timer; + QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); + if (timeout > 0) { + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.setSingleShot(true); + timer.start(timeout); + } + loop.exec(); + return timeoutSpy.isEmpty(); +} + +class TestEngine : public QJSEngine +{ + Q_OBJECT +public: + TestEngine() + { + qMetaTypeId<InjectedFunction>(); + } + + Q_INVOKABLE void evaluate(const QString &script, const QString &fileName, int lineNumber = 1) + { + QJSEngine::evaluate(script, fileName, lineNumber); + emit evaluateFinished(); + } + + QV4::ExecutionEngine *v4Engine() { return QV8Engine::getV4(this); } + + typedef QV4::Value (*InjectedFunction)(QV4::SimpleCallContext*); + + Q_INVOKABLE void injectFunction(const QString &functionName, TestEngine::InjectedFunction injectedFunction) + { + QV4::ExecutionEngine *v4 = v4Engine(); + + QV4::String *name = v4->newString(functionName); + QV4::Value function = QV4::Value::fromObject(v4->newBuiltinFunction(v4->rootContext, name, injectedFunction)); + v4->globalObject->put(name, function); + } + +signals: + void evaluateFinished(); +}; + +Q_DECLARE_METATYPE(TestEngine::InjectedFunction) + +class TestAgent : public QV4::Debugging::DebuggerAgent +{ + Q_OBJECT +public: + TestAgent() + : m_wasPaused(false) + { + } + + virtual void debuggerPaused(QV4::Debugging::Debugger *debugger) + { + Q_ASSERT(m_debuggers.count() == 1 && m_debuggers.first() == debugger); + m_wasPaused = true; + m_statesWhenPaused << debugger->currentExecutionState(); + + foreach (const TestBreakPoint &bp, m_breakPointsToAddWhenPaused) + debugger->addBreakPoint(bp.fileName, bp.lineNumber); + m_breakPointsToAddWhenPaused.clear(); + + debugger->resume(); + } + + int debuggerCount() const { return m_debuggers.count(); } + + struct TestBreakPoint + { + TestBreakPoint() : lineNumber(-1) {} + TestBreakPoint(const QString &fileName, int lineNumber) + : fileName(fileName), lineNumber(lineNumber) {} + QString fileName; + int lineNumber; + }; + + bool m_wasPaused; + QList<QV4::Debugging::Debugger::ExecutionState> m_statesWhenPaused; + QList<TestBreakPoint> m_breakPointsToAddWhenPaused; +}; + +class tst_qv4debugger : public QObject +{ + Q_OBJECT +private slots: + void init(); + void cleanup(); + + void breakAnywhere(); + void pendingBreakpoint(); + void liveBreakPoint(); + void removePendingBreakPoint(); + void addBreakPointWhilePaused(); + void removeBreakPointForNextInstruction(); + +private: + void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1) + { + QMetaObject::invokeMethod(m_engine, "evaluate", Qt::QueuedConnection, + Q_ARG(QString, script), Q_ARG(QString, fileName), + Q_ARG(int, lineNumber)); + waitForSignal(m_engine, SIGNAL(evaluateFinished()), /*timeout*/0); + } + + TestEngine *m_engine; + QV4::ExecutionEngine *m_v4; + TestAgent *m_debuggerAgent; + QThread *m_javaScriptThread; +}; + +void tst_qv4debugger::init() +{ + m_javaScriptThread = new QThread; + m_engine = new TestEngine; + m_v4 = m_engine->v4Engine(); + m_v4->enableDebugger(); + m_engine->moveToThread(m_javaScriptThread); + m_javaScriptThread->start(); + m_debuggerAgent = new TestAgent; + m_debuggerAgent->addDebugger(m_v4->debugger); +} + +void tst_qv4debugger::cleanup() +{ + m_javaScriptThread->exit(); + m_javaScriptThread->wait(); + delete m_engine; + delete m_javaScriptThread; + m_engine = 0; + m_v4 = 0; + QCOMPARE(m_debuggerAgent->debuggerCount(), 0); + delete m_debuggerAgent; + m_debuggerAgent = 0; +} + +void tst_qv4debugger::breakAnywhere() +{ + QString script = + "var i = 42;\n" + "var j = i + 1\n" + "var k = i\n"; + m_debuggerAgent->pause(m_v4->debugger); + evaluateJavaScript(script, "testFile"); + QVERIFY(m_debuggerAgent->m_wasPaused); +} + +void tst_qv4debugger::pendingBreakpoint() +{ + QString script = + "var i = 42;\n" + "var j = i + 1\n" + "var k = i\n"; + m_debuggerAgent->addBreakPoint(m_v4->debugger, "testfile", 2); + evaluateJavaScript(script, "testfile"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); + QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + QCOMPARE(state.fileName, QString("testfile")); + QCOMPARE(state.lineNumber, 2); +} + +void tst_qv4debugger::liveBreakPoint() +{ + QString script = + "var i = 42;\n" + "var j = i + 1\n" + "var k = i\n"; + m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("liveBreakPoint", 3); + m_debuggerAgent->pause(m_v4->debugger); + evaluateJavaScript(script, "liveBreakPoint"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2); + QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(1); + QCOMPARE(state.fileName, QString("liveBreakPoint")); + QCOMPARE(state.lineNumber, 3); +} + +void tst_qv4debugger::removePendingBreakPoint() +{ + QString script = + "var i = 42;\n" + "var j = i + 1\n" + "var k = i\n"; + m_debuggerAgent->addBreakPoint(m_v4->debugger, "removePendingBreakPoint", 2); + m_debuggerAgent->removeBreakPoint(m_v4->debugger, "removePendingBreakPoint", 2); + evaluateJavaScript(script, "removePendingBreakPoint"); + QVERIFY(!m_debuggerAgent->m_wasPaused); +} + +void tst_qv4debugger::addBreakPointWhilePaused() +{ + QString script = + "var i = 42;\n" + "var j = i + 1\n" + "var k = i\n"; + m_debuggerAgent->addBreakPoint(m_v4->debugger, "addBreakPointWhilePaused", 1); + m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("addBreakPointWhilePaused", 2); + evaluateJavaScript(script, "addBreakPointWhilePaused"); + QVERIFY(m_debuggerAgent->m_wasPaused); + QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2); + + QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(0); + QCOMPARE(state.fileName, QString("addBreakPointWhilePaused")); + QCOMPARE(state.lineNumber, 1); + + state = m_debuggerAgent->m_statesWhenPaused.at(1); + QCOMPARE(state.fileName, QString("addBreakPointWhilePaused")); + QCOMPARE(state.lineNumber, 2); +} + +static QV4::Value someCall(QV4::SimpleCallContext *ctx) +{ + ctx->engine->debugger->removeBreakPoint("removeBreakPointForNextInstruction", 2); + return QV4::Value::undefinedValue(); +} + +void tst_qv4debugger::removeBreakPointForNextInstruction() +{ + QString script = + "someCall();\n" + "var i = 42;"; + + QMetaObject::invokeMethod(m_engine, "injectFunction", Qt::BlockingQueuedConnection, + Q_ARG(QString, "someCall"), Q_ARG(TestEngine::InjectedFunction, someCall)); + + m_debuggerAgent->addBreakPoint(m_v4->debugger, "removeBreakPointForNextInstruction", 2); + + evaluateJavaScript(script, "removeBreakPointForNextInstruction"); + QVERIFY(!m_debuggerAgent->m_wasPaused); +} + +QTEST_MAIN(tst_qv4debugger) + +#include "tst_qv4debugger.moc" diff --git a/tests/auto/qml/v4/data/colorType.qml b/tests/auto/qml/v4/data/colorType.qml deleted file mode 100644 index f6a98a4a3e..0000000000 --- a/tests/auto/qml/v4/data/colorType.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property bool useMyColor: true - property color myColor: "red" - property color myOtherColor: "green" - - property color test1: useMyColor ? myColor : myOtherColor - property color test2: useMyColor ? "red" : "green" - property color test3: useMyColor ? myColor : "green" - - property bool test4: !myColor ? false : true - - property bool test5: myColor != "red" - property bool test6: myColor == "#ff0000" - property bool test7: myColor != "#00ff00" -} - diff --git a/tests/auto/qml/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml deleted file mode 100644 index 704f7c6c5a..0000000000 --- a/tests/auto/qml/v4/data/conditionalExpr.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int n: 2 - property int a: n ? 1 : 0 - property int b: if (n) { 1 } else { 0 } - result: (a && b) ? 0 : 1 -} diff --git a/tests/auto/qml/v4/data/conversions.1.qml b/tests/auto/qml/v4/data/conversions.1.qml deleted file mode 100644 index b3abde770a..0000000000 --- a/tests/auto/qml/v4/data/conversions.1.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning bool prop to other proptypes. - boolProp: true - intProp: boolProp - floatProp: boolProp - doubleProp: boolProp - qrealProp: boolProp - qstringProp: boolProp - qurlProp: boolProp - vec3Prop: Qt.vector3d(boolProp, boolProp, boolProp) -} diff --git a/tests/auto/qml/v4/data/conversions.2.qml b/tests/auto/qml/v4/data/conversions.2.qml deleted file mode 100644 index 2fd0453ac2..0000000000 --- a/tests/auto/qml/v4/data/conversions.2.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning int prop to other proptypes. - boolProp: intProp - intProp: 4 - floatProp: intProp - doubleProp: intProp - qrealProp: intProp - qstringProp: intProp - qurlProp: intProp - vec3Prop: Qt.vector3d(intProp, intProp, intProp) -} diff --git a/tests/auto/qml/v4/data/conversions.3.qml b/tests/auto/qml/v4/data/conversions.3.qml deleted file mode 100644 index 66f0761a25..0000000000 --- a/tests/auto/qml/v4/data/conversions.3.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning float prop to other proptypes. - boolProp: floatProp - intProp: floatProp - floatProp: 4.4 - doubleProp: floatProp - qrealProp: floatProp - qstringProp: floatProp - qurlProp: floatProp - vec3Prop: Qt.vector3d(floatProp, floatProp, floatProp) -} diff --git a/tests/auto/qml/v4/data/conversions.4.qml b/tests/auto/qml/v4/data/conversions.4.qml deleted file mode 100644 index ccf0035313..0000000000 --- a/tests/auto/qml/v4/data/conversions.4.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning double prop to other prop types - boolProp: doubleProp - intProp: doubleProp - floatProp: doubleProp - doubleProp: 4.444444444 - qrealProp: doubleProp - qstringProp: doubleProp - qurlProp: doubleProp - vec3Prop: Qt.vector3d(doubleProp, doubleProp, doubleProp) -} diff --git a/tests/auto/qml/v4/data/conversions.5.qml b/tests/auto/qml/v4/data/conversions.5.qml deleted file mode 100644 index 26dc3b7195..0000000000 --- a/tests/auto/qml/v4/data/conversions.5.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning qreal prop to other prop types - boolProp: qrealProp - intProp: qrealProp - floatProp: qrealProp - doubleProp: qrealProp - qrealProp: 4.44 - qstringProp: qrealProp - qurlProp: qrealProp - vec3Prop: Qt.vector3d(qrealProp, qrealProp, qrealProp) -} diff --git a/tests/auto/qml/v4/data/conversions.6.qml b/tests/auto/qml/v4/data/conversions.6.qml deleted file mode 100644 index 573b227ada..0000000000 --- a/tests/auto/qml/v4/data/conversions.6.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning string prop to other proptypes. - boolProp: qstringProp - intProp: qstringProp - floatProp: qstringProp - doubleProp: qstringProp - qrealProp: qstringProp - qstringProp: "4" - qurlProp: qstringProp - vec3Prop: Qt.vector3d(qstringProp, qstringProp, qstringProp) -} diff --git a/tests/auto/qml/v4/data/conversions.7.qml b/tests/auto/qml/v4/data/conversions.7.qml deleted file mode 100644 index 5112b06b1e..0000000000 --- a/tests/auto/qml/v4/data/conversions.7.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning url prop to other proptypes. - boolProp: qurlProp - intProp: qurlProp - floatProp: qurlProp - doubleProp: qurlProp - qrealProp: qurlProp - qstringProp: qurlProp - qurlProp: "4" - vec3Prop: Qt.vector3d(qurlProp, qurlProp, qurlProp) -} diff --git a/tests/auto/qml/v4/data/conversions.8.qml b/tests/auto/qml/v4/data/conversions.8.qml deleted file mode 100644 index 18bf160e7e..0000000000 --- a/tests/auto/qml/v4/data/conversions.8.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.v4 1.0 - -Conversion { - // test assigning vector prop to other proptypes. - boolProp: vec3Prop - intProp: vec3Prop - floatProp: vec3Prop - doubleProp: vec3Prop - qrealProp: vec3Prop - qstringProp: vec3Prop - qurlProp: vec3Prop - vec3Prop: Qt.vector3d(4, 4, 4) -} diff --git a/tests/auto/qml/v4/data/doubleBoolJump.qml b/tests/auto/qml/v4/data/doubleBoolJump.qml deleted file mode 100644 index 2eea73b573..0000000000 --- a/tests/auto/qml/v4/data/doubleBoolJump.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - QtObject { - property real output: i1.p1 || i2.p2 == "text" ? 0.7 : 0 - } - - QtObject { - id: i2 - property string p2 - } - - QtObject { - id: i1 - property bool p1: false - } -} - diff --git a/tests/auto/qml/v4/data/equals.qml b/tests/auto/qml/v4/data/equals.qml deleted file mode 100644 index 2862bb7ac9..0000000000 --- a/tests/auto/qml/v4/data/equals.qml +++ /dev/null @@ -1,51 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject myprop1: null - property QtObject myprop2: QtObject {} - property real zero: 0 - property bool falseProp: false - - property bool test1: myprop1 == false - property bool test2: myprop1 == null - property bool test3: 5 == myprop1 - property bool test4: null == myprop1 - property bool test5: myprop1 != false - property bool test6: myprop1 != null - property bool test7: 5 != myprop1 - property bool test8: null != myprop1 - - property bool test9: myprop2 == false - property bool test10: myprop2 == null - property bool test11: 5 == myprop2 - property bool test12: null == myprop2 - property bool test13: myprop2 != false - property bool test14: myprop2 != null - property bool test15: 5 != myprop2 - property bool test16: null != myprop2 - - property bool test17: myprop1 == myprop1 - property bool test18: myprop1 != myprop1 - property bool test19: myprop1 == myprop2 - property bool test20: myprop1 != myprop2 - property bool test21: myprop2 == myprop2 - property bool test22: myprop2 != myprop2 - - property bool test23: myprop1 == "hello" - property bool test24: myprop1 != "hello" - property bool test25: myprop2 == "hello" - property bool test26: myprop2 != "hello" - - property bool test27: falseProp == zero - property bool test28: falseProp != zero - property bool test29: falseProp == 1 - property bool test30: falseProp != 1 - property bool test31: true == zero - property bool test32: true != zero - property bool test33: true == 1 - property bool test34: true != 1 - - property bool test35: "a\ -b" === "ab" -} - diff --git a/tests/auto/qml/v4/data/fetchException.qml b/tests/auto/qml/v4/data/fetchException.qml deleted file mode 100644 index 6431fcfae8..0000000000 --- a/tests/auto/qml/v4/data/fetchException.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - property Item data - property int a: data.x, 1 -} diff --git a/tests/auto/qml/v4/data/integerOperations.qml b/tests/auto/qml/v4/data/integerOperations.qml deleted file mode 100644 index 805f4566fb..0000000000 --- a/tests/auto/qml/v4/data/integerOperations.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.0 - -Item { - property int testa1: i1.p1 - property int testa2: -testa1 - i1.p1 - - property int testb1: i1.p1 & 2 - property int testb2: i1.p2 & 2 - property int testb3: 2 & i1.p1 - property int testb4: 2 & i1.p2 - property int testb5: i1.p1 & i1.p3 - property int testb6: i1.p2 & i1.p3 - property int testb7: i1.p3 & i1.p1 - property int testb8: i1.p3 & i1.p2 - - property int testc1: i1.p1 | 2 - property int testc2: i1.p2 | 2 - property int testc3: 2 | i1.p1 - property int testc4: 2 | i1.p2 - property int testc5: i1.p1 | i1.p3 - property int testc6: i1.p2 | i1.p3 - property int testc7: i1.p3 | i1.p1 - property int testc8: i1.p3 | i1.p2 - - property int testd1: i1.p1 ^ 7 - property int testd2: 7 ^ i1.p1 - property int testd3: i1.p1 ^ i1.p4 - property int testd4: i1.p4 ^ i1.p1 - - property int teste1: i1.p4 << 2 - property int teste2: i1.p5 << 2 - property int teste3: 2 << i1.p4 - property int teste4: i1.p4 << i1.p3 - property int teste5: i1.p5 << i1.p3 - property int teste6: i1.p3 << i1.p4 - - property int testf1: i1.p4 >> 2 - property int testf2: i1.p5 >> 2 - property int testf3: 2 >> i1.p4 - property int testf4: i1.p4 >> i1.p3 - property int testf5: i1.p5 >> i1.p3 - property int testf6: i1.p3 >> i1.p4 - - property int testg1: i1.p4 >>> 2 - property int testg2: i1.p5 >>> 2 - property int testg3: 2 >>> i1.p4 - property int testg4: i1.p4 >>> i1.p3 - property int testg5: i1.p5 >>> i1.p3 - property int testg6: i1.p3 >>> i1.p4 - - QtObject { - id: i1 - property int p1: 333 - property int p2: -666 - property int p3: 2 - property int p4: 7 - property int p5: -7 - } - } diff --git a/tests/auto/qml/v4/data/jsvalueHandling.qml b/tests/auto/qml/v4/data/jsvalueHandling.qml deleted file mode 100644 index d15e878a52..0000000000 --- a/tests/auto/qml/v4/data/jsvalueHandling.qml +++ /dev/null @@ -1,69 +0,0 @@ -import QtQuick 2.0 -import Qt.v4 1.0 - -JSValueTest { - property bool pBool: true - property int pInt: 666 - property real pReal: 3.1415927 - property string pString: 'foo' - property url pUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property color pColor: Qt.rgba(1, 0, 0, 0.5) - property QtObject pObject: QtObject { property string foo: 'bar' } - property var pVar: pUrl - - // Test assignment to QJSValue - boolVar: pBool - intVar: pInt - realVar: pReal - stringVar: pString - urlVar: pUrl - colorVar: pColor - objectVar: pObject - nullVar: null - varVar: pVar - - // Test equivalence - property bool boolConversionSuccess: (boolVar == true) - property bool intConversionSuccess: (intVar == 666) - property bool realConversionSuccess: (realVar == 3.1415927) - property bool stringConversionSuccess: (stringVar == 'foo') - - property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property bool urlConversionSuccess: (urlVar == comparisonUrl) - - property color comparisonColor: Qt.rgba(1, 0, 0, 0.5) - property bool colorConversionSuccess: (colorVar == comparisonColor) - - property bool objectConversionSuccess: (objectVar == pObject) - property bool nullConversionSuccess: (nullVar == null) - - property bool varConversionSuccess: (varVar == comparisonUrl) - - // Operations are not handled by V4 - they should pass through correctly - property var pVarNot: !boolVar - property var pVarComplement: ~intVar - property var pVarEqual: (boolVar == pBool) - property var pVarLiteralEqual: (boolVar == true) - property var pVarUnequal: (urlVar == colorVar) - property var pVarComparison: (intVar <= intVar) - property var pVarShift: (intVar >> 1) - - Component.onCompleted: { - if (!boolConversionSuccess) console.warn('QV4: bool conversion failed'); - if (!intConversionSuccess) console.warn('QV4: int conversion failed'); - if (!realConversionSuccess) console.warn('QV4: real conversion failed'); - if (!stringConversionSuccess) console.warn('QV4: string conversion failed'); - if (!urlConversionSuccess) console.warn('QV4: url conversion failed'); - if (!colorConversionSuccess) console.warn('QV4: color conversion failed'); - if (!objectConversionSuccess) console.warn('QV4: object conversion failed'); - if (!nullConversionSuccess) console.warn('QV4: null conversion failed'); - if (!varConversionSuccess) console.warn('QV4: var conversion failed'); - if (pVarNot != false) console.warn('QV4: var negation impeded'); - if (pVarComplement != ~666) console.warn('QV4: var complement impeded'); - if (pVarEqual != true) console.warn('QV4: var equality impeded'); - if (pVarLiteralEqual != true) console.warn('QV4: var/literal equality impeded'); - if (pVarUnequal != false) console.warn('QV4: var unequality impeded'); - if (pVarComparison != true) console.warn('QV4: var comparison impeded'); - if (pVarShift != 333) console.warn('QV4: var shift impeded'); - } -} diff --git a/tests/auto/qml/v4/data/logicalAnd.2.qml b/tests/auto/qml/v4/data/logicalAnd.2.qml deleted file mode 100644 index cc3d75bd90..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" && "bar" - result: s == "bar" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.3.qml b/tests/auto/qml/v4/data/logicalAnd.3.qml deleted file mode 100644 index 6527f05d07..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.3.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "" - property bool flag: true - - result: (s && flag) == "" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.4.qml b/tests/auto/qml/v4/data/logicalAnd.4.qml deleted file mode 100644 index fbcee91699..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.4.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" - property bool flag: true - - result: (!flag && s) == false -} diff --git a/tests/auto/qml/v4/data/logicalAnd.5.qml b/tests/auto/qml/v4/data/logicalAnd.5.qml deleted file mode 100644 index f0698463fe..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.5.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool flag: true - - result: (null && flag) == null -} diff --git a/tests/auto/qml/v4/data/logicalAnd.6.qml b/tests/auto/qml/v4/data/logicalAnd.6.qml deleted file mode 100644 index e98b5c99cd..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.6.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "" - property bool flag: true - property string subresult: s && flag - - result: subresult === "" -} diff --git a/tests/auto/qml/v4/data/logicalAnd.7.qml b/tests/auto/qml/v4/data/logicalAnd.7.qml deleted file mode 100644 index 0f19d3fb40..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.7.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt.v4 1.0 - -Result { - property real nan: Number.NaN - property bool flag: true - property real subresult: nan && flag - - result: isNaN(subresult) -} diff --git a/tests/auto/qml/v4/data/logicalAnd.qml b/tests/auto/qml/v4/data/logicalAnd.qml deleted file mode 100644 index 40fc3616c2..0000000000 --- a/tests/auto/qml/v4/data/logicalAnd.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 10 - result: a == 10 && a == 2 -} diff --git a/tests/auto/qml/v4/data/logicalOr.2.qml b/tests/auto/qml/v4/data/logicalOr.2.qml deleted file mode 100644 index 54fb78b127..0000000000 --- a/tests/auto/qml/v4/data/logicalOr.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" || "bar" - result: s == "foo" -} diff --git a/tests/auto/qml/v4/data/logicalOr.qml b/tests/auto/qml/v4/data/logicalOr.qml deleted file mode 100644 index 406a7d83eb..0000000000 --- a/tests/auto/qml/v4/data/logicalOr.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 10 - result: a == 1 || a == 2 -} diff --git a/tests/auto/qml/v4/data/mathAbs.qml b/tests/auto/qml/v4/data/mathAbs.qml deleted file mode 100644 index eb504ae4d8..0000000000 --- a/tests/auto/qml/v4/data/mathAbs.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.abs(i1.p1) - property real test2: Math.abs(i1.p2) - - property int test3: Math.abs(i1.p3) - property int test4: Math.abs(i1.p4) - - property real subtest5: Math.abs() - property real subtest6: Math.abs(i1.p6) - property bool test5: isNaN(subtest5) - property bool test6: isNaN(subtest6) - - property real subtest7: Math.abs(i1.p7) - property bool test7: isNaN(subtest7) - property int test8: Math.abs(i1.p8) - - property real subtest9: Math.abs(i1.p9) - property real subtest10: Math.abs(i1.p10) - property bool test9: subtest9 === Number.POSITIVE_INFINITY - property bool test10: subtest10 === Number.POSITIVE_INFINITY - - property int test11: Math.abs(i1.p11) - property real subtest12: Math.abs(i1.p12) - property bool test12: subtest12 === 0 && (1/subtest12) === Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.5 - property int p3: 18 - property int p4: -72 - property real p6: Number.NaN - property string p7: "hello world" - property string p8: "82" - property real p9: Number.NEGATIVE_INFINITY - property real p10: Number.POSITIVE_INFINITY - property real p11: 0 - property real p12: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathCeil.qml b/tests/auto/qml/v4/data/mathCeil.qml deleted file mode 100644 index 1f65066233..0000000000 --- a/tests/auto/qml/v4/data/mathCeil.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.ceil(i1.p1) - property real test2: Math.ceil(i1.p2) - - property real subtest3: Math.ceil() - property real subtest4: Math.ceil(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.ceil(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.ceil(i1.p6) - - property real subtest7: Math.ceil(i1.p7) - property real subtest8: Math.ceil(i1.p8) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real test9: Math.ceil(i1.p9) - property real subtest10: Math.ceil(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real subtest11: Math.ceil(i1.p11) - property bool test11: subtest11 === 0 && (1/subtest11) === -Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property real p11: -0.5 - } - } diff --git a/tests/auto/qml/v4/data/mathCos.qml b/tests/auto/qml/v4/data/mathCos.qml deleted file mode 100644 index 44c47e9f15..0000000000 --- a/tests/auto/qml/v4/data/mathCos.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.cos(i1.p1) - property real test2: Math.cos(i1.p2) - - property real subtest3: Math.cos() - property real subtest4: Math.cos(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.cos(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.cos(i1.p6) - - property real subtest7: Math.cos(i1.p7) - property real subtest8: Math.cos(i1.p8) - property bool test7: isNaN(subtest7) - property bool test8: isNaN(subtest8) - - property real subtest9: Math.cos(i1.p9) - property bool test9: subtest9 === 1 - property real subtest10: Math.cos(i1.p10) - property bool test10: subtest10 === 1 - - property real subtest11: Math.PI / 6.66 - property real test11: Math.cos(subtest11) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathFloor.qml b/tests/auto/qml/v4/data/mathFloor.qml deleted file mode 100644 index 3473dccd10..0000000000 --- a/tests/auto/qml/v4/data/mathFloor.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.floor(i1.p1) - property real test2: Math.floor(i1.p2) - - property real subtest3: Math.floor() - property real subtest4: Math.floor(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.floor(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.floor(i1.p6) - - property real subtest7: Math.floor(i1.p7) - property real subtest8: Math.floor(i1.p8) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real test9: Math.floor(i1.p9) - property real subtest10: Math.floor(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/mathMax.qml b/tests/auto/qml/v4/data/mathMax.qml deleted file mode 100644 index cd8a88a3e7..0000000000 --- a/tests/auto/qml/v4/data/mathMax.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.max(i1.p1, i1.p2) - property real test2: Math.max(i1.p2, i1.p3) - - property real subtest3: Math.max() - property real subtest4: Math.max(i1.p4) - property bool test3: subtest3 === -Infinity - property bool test4: isNaN(subtest4) - - property real subtest5: Math.max(i1.p5, i1.p1) - property bool test5: isNaN(subtest5) - property real test6: Math.max(i1.p6, i1.p3) - - property real test7: Math.max(i1.p7, i1.p2) - property real subtest8: Math.max(i1.p8, i1.p2) - property bool test8: subtest8 === Number.POSITIVE_INFINITY - - property real subtest9: Math.max(i1.p10, i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === Infinity - - // Reverse the inputs to Math.max - property real subtest10: Math.max(i1.p9, i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === Infinity - - property real test11: Math.max(i1.p11, i1.p1) - property real test12: Math.max(i1.p11, i1.p2) - property real test13: Math.max(i1.p1, i1.p2, i1.p3) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property int p3: 7 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property var p11: null - } -} diff --git a/tests/auto/qml/v4/data/mathMin.qml b/tests/auto/qml/v4/data/mathMin.qml deleted file mode 100644 index 4ae5408b58..0000000000 --- a/tests/auto/qml/v4/data/mathMin.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.min(i1.p1, i1.p2) - property real test2: Math.min(i1.p2, i1.p3) - - property real subtest3: Math.min() - property real subtest4: Math.min(i1.p4) - property bool test3: subtest3 === Infinity - property bool test4: isNaN(subtest4) - - property real subtest5: Math.min(i1.p5, i1.p1) - property bool test5: isNaN(subtest5) - property real test6: Math.min(i1.p6, i1.p3) - - property real subtest7: Math.min(i1.p7, i1.p2) - property bool test7: subtest7 === Number.NEGATIVE_INFINITY - property real test8: Math.min(i1.p8, i1.p2) - - property real subtest9: Math.min(i1.p10, i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === -Infinity - - // Reverse the inputs to Math.min - property real subtest10: Math.min(i1.p9, i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real test11: Math.min(i1.p11, i1.p1) - property real test12: Math.min(i1.p11, i1.p2) - property real test13: Math.min(i1.p1, i1.p2, i1.p3) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property int p3: 95 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - property var p11: null - } - } diff --git a/tests/auto/qml/v4/data/mathSin.qml b/tests/auto/qml/v4/data/mathSin.qml deleted file mode 100644 index c48ec03fee..0000000000 --- a/tests/auto/qml/v4/data/mathSin.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: Math.sin(i1.p1) - property real test2: Math.sin(i1.p2) - - property real subtest3: Math.sin() - property real subtest4: Math.sin(i1.p4) - property bool test3: isNaN(subtest3) - property bool test4: isNaN(subtest4) - - property real subtest5: Math.sin(i1.p5) - property bool test5: isNaN(subtest5) - property real test6: Math.sin(i1.p6) - - property real subtest7: Math.sin(i1.p7) - property real subtest8: Math.sin(i1.p8) - property bool test7: isNaN(subtest7) - property bool test8: isNaN(subtest8) - - property real subtest9: Math.sin(i1.p9) - property bool test9: subtest9 === 0 && (1/subtest9) === Infinity - property real subtest10: Math.sin(i1.p10) - property bool test10: subtest10 === 0 && (1/subtest10) === -Infinity - - property real subtest11: Math.PI / 6.66 - property real test11: Math.sin(subtest11) - - QtObject { - id: i1 - property real p1: -3.7 - property real p2: 4.4 - property real p4: Number.NaN - property string p5: "hello world" - property string p6: "82.6" - property real p7: Number.NEGATIVE_INFINITY - property real p8: Number.POSITIVE_INFINITY - property real p9: 0 - property real p10: -0 - } - } diff --git a/tests/auto/qml/v4/data/nestedLogicalAnd.qml b/tests/auto/qml/v4/data/nestedLogicalAnd.qml deleted file mode 100644 index 1358fcea64..0000000000 --- a/tests/auto/qml/v4/data/nestedLogicalAnd.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool val1: false - property bool val2: true - property bool val3: false - - property bool b1: (true && true && false) - property bool b2: (true && (false && true)) - property bool b3: ((true && true) && true) - property bool b4: (val1 && (val2 && val3)) ? true : false - - result: !b1 && !b2 && b3 && !b4 -} diff --git a/tests/auto/qml/v4/data/nestedLogicalOr.qml b/tests/auto/qml/v4/data/nestedLogicalOr.qml deleted file mode 100644 index c4478a3e7b..0000000000 --- a/tests/auto/qml/v4/data/nestedLogicalOr.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool val1: false - property bool val2: true - property bool val3: false - - property bool b1: (false || false || true) - property bool b2: (false || (false || true)) - property bool b3: ((false || false) || true) - property bool b4: (val1 || (val2 || val3)) ? true : false - - result: b1 && b2 && b3 && b4 -} diff --git a/tests/auto/qml/v4/data/nestedObjectAccess.qml b/tests/auto/qml/v4/data/nestedObjectAccess.qml deleted file mode 100644 index 56cd17e41e..0000000000 --- a/tests/auto/qml/v4/data/nestedObjectAccess.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - result: nested.result -} diff --git a/tests/auto/qml/v4/data/nestedObjectAccess2.qml b/tests/auto/qml/v4/data/nestedObjectAccess2.qml deleted file mode 100644 index 2f0e0db01c..0000000000 --- a/tests/auto/qml/v4/data/nestedObjectAccess2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - result: nested2.result -} diff --git a/tests/auto/qml/v4/data/nullQObject.qml b/tests/auto/qml/v4/data/nullQObject.qml deleted file mode 100644 index 00185b3988..0000000000 --- a/tests/auto/qml/v4/data/nullQObject.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item { - property QtObject obj - property QtObject test - test: obj -} diff --git a/tests/auto/qml/v4/data/objectToBool.qml b/tests/auto/qml/v4/data/objectToBool.qml deleted file mode 100644 index 8c8a67bee0..0000000000 --- a/tests/auto/qml/v4/data/objectToBool.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject prop1: null - property QtObject prop2: QtObject {} - - property bool test1: prop1 ? true : false - property bool test2: prop2 ? true : false - - property bool test3: prop1 == false - property bool test4: prop1 === false - - property bool test5: prop2 == false - property bool test6: prop2 === false -} - diff --git a/tests/auto/qml/v4/data/qrealToIntRounding.qml b/tests/auto/qml/v4/data/qrealToIntRounding.qml deleted file mode 100644 index ee3d405073..0000000000 --- a/tests/auto/qml/v4/data/qrealToIntRounding.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property int data: 1 - - property int test1: 6.6 + data - property int test2: 6.2 + data - property int test3: 6 + data -} - diff --git a/tests/auto/qml/v4/data/qtbug_21883.qml b/tests/auto/qml/v4/data/qtbug_21883.qml deleted file mode 100644 index a51f97c944..0000000000 --- a/tests/auto/qml/v4/data/qtbug_21883.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - property Result dummy: Result -} diff --git a/tests/auto/qml/v4/data/qtbug_22816.qml b/tests/auto/qml/v4/data/qtbug_22816.qml deleted file mode 100644 index bfa8d4948c..0000000000 --- a/tests/auto/qml/v4/data/qtbug_22816.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - QtObject { - id: object - property bool prop1: true - function myfunction() { return true; } - property bool prop2: object.prop1 && myfunction(); - } - - property bool test1: object.prop1 && object.prop2 - property bool test2: object.prop1 - - Component.onCompleted: { - object.prop1 = false; - } -} - diff --git a/tests/auto/qml/v4/data/singletonType.qml b/tests/auto/qml/v4/data/singletonType.qml deleted file mode 100644 index 3fcbcae64d..0000000000 --- a/tests/auto/qml/v4/data/singletonType.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt.test 1.0 as ModApi -import QtQuick 2.0 - -Item { - property int testProp: ModApi.V4.ip - property int testProp2: 2 - - function getRandom() { - testProp2 = ModApi.V4.random(); - // testProp should also have changed. - } -} diff --git a/tests/auto/qml/v4/data/strictEquals.qml b/tests/auto/qml/v4/data/strictEquals.qml deleted file mode 100644 index 503ca50454..0000000000 --- a/tests/auto/qml/v4/data/strictEquals.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property QtObject myprop1: null - property QtObject myprop2: QtObject {} - property real zero: 0 - property bool falseProp: false - - property bool test1: myprop1 === false - property bool test2: myprop1 === null - property bool test3: 5 === myprop1 - property bool test4: null === myprop1 - property bool test5: myprop1 !== false - property bool test6: myprop1 !== null - property bool test7: 5 !== myprop1 - property bool test8: null !== myprop1 - - property bool test9: myprop2 === false - property bool test10: myprop2 === null - property bool test11: 5 === myprop2 - property bool test12: null === myprop2 - property bool test13: myprop2 !== false - property bool test14: myprop2 !== null - property bool test15: 5 !== myprop2 - property bool test16: null !== myprop2 - - property bool test17: myprop1 === myprop1 - property bool test18: myprop1 !== myprop1 - property bool test19: myprop1 === myprop2 - property bool test20: myprop1 !== myprop2 - property bool test21: myprop2 === myprop2 - property bool test22: myprop2 !== myprop2 - - property bool test23: myprop1 === "hello" - property bool test24: myprop1 !== "hello" - property bool test25: myprop2 === "hello" - property bool test26: myprop2 !== "hello" - - property bool test27: falseProp === zero - property bool test28: falseProp !== zero - property bool test29: falseProp === 1 - property bool test30: falseProp !== 1 - property bool test31: true === zero - property bool test32: true !== zero - property bool test33: true === 1 - property bool test34: true !== 1 - - property bool test35: zero === 5.0 - property bool test36: zero !== 5.0 - property bool test37: zero === 1 - property bool test38: zero !== 1 -} - diff --git a/tests/auto/qml/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml deleted file mode 100644 index d9eab5389e..0000000000 --- a/tests/auto/qml/v4/data/stringComparison.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property string string1: "aaba" - property string string2: "aa" - property string string3: "aaab" - property string string4: "c" - property string string5: string2 + string4 - - property bool test1: string1 > string2 - property bool test2: string2 < string1 - property bool test3: string1 > string3 - property bool test4: string3 < string1 - property bool test5: string1 < string4 - property bool test6: string4 > string1 - property bool test7: string1 < string5 - property bool test8: string5 > string1 - - property bool test9: string1 == "aaba" - property bool test10: string1 != "baa" - property bool test11: string1 === "aaba" - property bool test12: string1 !== "baa" - property bool test13: string4 == "c" - property bool test14: string4 != "d" - property bool test15: string4 === "c" - property bool test16: string4 !== "d" - property bool test17: string5 === "aac" - property bool test18: string5 !== "aad" - - property bool test19: string1 >= string2 - property bool test20: string2 <= string1 - property bool test21: string1 >= string3 - property bool test22: string3 <= string1 - property bool test23: string1 <= string4 - property bool test24: string4 >= string1 - property bool test25: string4 <= "c" - property bool test26: string4 >= "c" - property bool test27: string5 <= "aac" - property bool test28: string5 >= "aac" -} - diff --git a/tests/auto/qml/v4/data/subscriptions.1.qml b/tests/auto/qml/v4/data/subscriptions.1.qml deleted file mode 100644 index 607233819e..0000000000 --- a/tests/auto/qml/v4/data/subscriptions.1.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 400 - height: 400 - - property real targetHeight: menuItems.height + 1 - property real heightValue: if (1) menuItems.height //this must be v8? - property bool boolProp: menuItems.height > heightValue //this must be v4? - - Column { - id: menuItems - Item { height: 200; width: 10 } - } -} diff --git a/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml deleted file mode 100644 index a8e05eeda1..0000000000 --- a/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: thisTest - - property bool cond: true - property real a: 1 - property real result: cond ? a : a - - PropertyAction { running: true; target: thisTest; property: "a"; value: 2; } -} diff --git a/tests/auto/qml/v4/data/unaryMinus.qml b/tests/auto/qml/v4/data/unaryMinus.qml deleted file mode 100644 index 410654fc3c..0000000000 --- a/tests/auto/qml/v4/data/unaryMinus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: -i1.p2 - property int test2: -i1.p2 - property real test3: -i1.p1 - property int test4: -i1.p1 - property real test5: -i1.p3 - property int test6: -i1.p3 - property real test7: -i1.p4 - property int test8: -i1.p4 - property real test9: -i1.p5 - property int test10: -i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } - } - diff --git a/tests/auto/qml/v4/data/unaryPlus.qml b/tests/auto/qml/v4/data/unaryPlus.qml deleted file mode 100644 index cd5315a7cc..0000000000 --- a/tests/auto/qml/v4/data/unaryPlus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: +i1.p2 - property int test2: +i1.p2 - property real test3: +i1.p1 - property int test4: +i1.p1 - property real test5: +i1.p3 - property int test6: +i1.p3 - property real test7: +i1.p4 - property int test8: +i1.p4 - property real test9: +i1.p5 - property int test10: +i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } -} - diff --git a/tests/auto/qml/v4/data/unnecessaryReeval.qml b/tests/auto/qml/v4/data/unnecessaryReeval.qml deleted file mode 100644 index 48662d7a2d..0000000000 --- a/tests/auto/qml/v4/data/unnecessaryReeval.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 8 - property int b: 19 - result: (a == 8)?b:7 -} diff --git a/tests/auto/qml/v4/data/varHandling.qml b/tests/auto/qml/v4/data/varHandling.qml deleted file mode 100644 index c19e6a256f..0000000000 --- a/tests/auto/qml/v4/data/varHandling.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property bool pBool: true - property int pInt: 666 - property real pReal: 3.1415927 - property string pString: 'foo' - property url pUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property color pColor: Qt.rgba(1, 0, 0, 0.5) - property QtObject pObject: QtObject { property string foo: 'bar' } - - // Test assignment to var - property var pBoolVar: pBool - property var pIntVar: pInt - property var pRealVar: pReal - property var pStringVar: pString - property var pUrlVar: pUrl - property var pColorVar: pColor - property var pObjectVar: pObject - property var pNullVar: null - property var pVarVar: pUrlVar - - // Test equivalence - property bool boolConversionSuccess: (pBoolVar == true) - property bool intConversionSuccess: (pIntVar == 666) - property bool realConversionSuccess: (pRealVar == 3.1415927) - property bool stringConversionSuccess: (pStringVar == 'foo') - - property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property bool urlConversionSuccess: (pUrlVar == comparisonUrl) - - property color comparisonColor: Qt.rgba(1, 0, 0, 0.5) - property bool colorConversionSuccess: (pColorVar == comparisonColor) - - property bool objectConversionSuccess: (pObjectVar == pObject) - property bool nullConversionSuccess: (pNullVar == null) - - property bool varConversionSuccess: (pVarVar == comparisonUrl) - - // Operations are not handled by V4 - they should pass through correctly - property var pVarNot: !pBoolVar - property var pVarComplement: ~pIntVar - property var pVarEqual: (pBoolVar == pBoolVar) - property var pVarLiteralEqual: (pBoolVar == true) - property var pVarUnequal: (pUrlVar == pColorVar) - property var pVarComparison: (pIntVar <= pIntVar) - property var pVarShift: (pIntVar >> 1) - - Component.onCompleted: { - if (!boolConversionSuccess) console.warn('QV4: bool conversion failed'); - if (!intConversionSuccess) console.warn('QV4: int conversion failed'); - if (!realConversionSuccess) console.warn('QV4: real conversion failed'); - if (!stringConversionSuccess) console.warn('QV4: string conversion failed'); - if (!urlConversionSuccess) console.warn('QV4: url conversion failed'); - if (!colorConversionSuccess) console.warn('QV4: color conversion failed'); - if (!objectConversionSuccess) console.warn('QV4: object conversion failed'); - if (!nullConversionSuccess) console.warn('QV4: null conversion failed'); - if (!varConversionSuccess) console.warn('QV4: var conversion failed'); - if (pVarNot != false) console.warn('QV4: var negation impeded'); - if (pVarComplement != ~666) console.warn('QV4: var complement impeded'); - if (pVarEqual != true) console.warn('QV4: var equality impeded'); - if (pVarLiteralEqual != true) console.warn('QV4: var/literal equality impeded'); - if (pVarUnequal != false) console.warn('QV4: var unequality impeded'); - if (pVarComparison != true) console.warn('QV4: var comparison impeded'); - if (pVarShift != 333) console.warn('QV4: var shift impeded'); - } -} diff --git a/tests/auto/qml/v4/data/variantHandling.qml b/tests/auto/qml/v4/data/variantHandling.qml deleted file mode 100644 index 3d48eef57e..0000000000 --- a/tests/auto/qml/v4/data/variantHandling.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property bool pBool: true - property int pInt: 666 - property real pReal: 3.1415927 - property string pString: 'foo' - property url pUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property color pColor: Qt.rgba(1, 0, 0, 0.5) - property QtObject pObject: QtObject { property string foo: 'bar' } - - // Test assignment to variant - property variant pBoolVar: pBool - property variant pIntVar: pInt - property variant pRealVar: pReal - property variant pStringVar: pString - property variant pUrlVar: pUrl - property variant pColorVar: pColor - property variant pObjectVar: pObject - property variant pNullVar: null - property variant pVarVar: pUrlVar - - // Test equivalence - property bool boolConversionSuccess: (pBoolVar == true) - property bool intConversionSuccess: (pIntVar == 666) - property bool realConversionSuccess: (pRealVar == 3.1415927) - property bool stringConversionSuccess: (pStringVar == 'foo') - - property url comparisonUrl: 'http://tools.ietf.org/html/rfc3986#section-1.1.2' - property bool urlConversionSuccess: (pUrlVar == comparisonUrl) - - property color comparisonColor: Qt.rgba(1, 0, 0, 0.5) - property bool colorConversionSuccess: (pColorVar == comparisonColor) - - property bool objectConversionSuccess: (pObjectVar == pObject) - property bool nullConversionSuccess: (pNullVar == null) - - property bool variantConversionSuccess: (pVarVar == comparisonUrl) - - // Operations are not handled by V4 - they should pass through correctly - property variant pVarNot: !pBoolVar - property variant pVarComplement: ~pIntVar - property variant pVarEqual: (pBoolVar == pBoolVar) - property variant pVarLiteralEqual: (pBoolVar == true) - property variant pVarUnequal: (pUrlVar == pColorVar) - property variant pVarComparison: (pIntVar <= pIntVar) - property variant pVarShift: (pIntVar >> 1) - - Component.onCompleted: { - if (!boolConversionSuccess) console.warn('QV4: bool conversion failed'); - if (!intConversionSuccess) console.warn('QV4: int conversion failed'); - if (!realConversionSuccess) console.warn('QV4: real conversion failed'); - if (!stringConversionSuccess) console.warn('QV4: string conversion failed'); - if (!urlConversionSuccess) console.warn('QV4: url conversion failed'); - if (!colorConversionSuccess) console.warn('QV4: color conversion failed'); - if (!objectConversionSuccess) console.warn('QV4: object conversion failed'); - if (!nullConversionSuccess) console.warn('QV4: null conversion failed'); - if (!variantConversionSuccess) console.warn('QV4: variant conversion failed'); - if (pVarNot != false) console.warn('QV4: variant negation impeded'); - if (pVarComplement != ~666) console.warn('QV4: variant complement impeded'); - if (pVarEqual != true) console.warn('QV4: variant equality impeded'); - if (pVarLiteralEqual != true) console.warn('QV4: variant/literal equality impeded'); - if (pVarUnequal != false) console.warn('QV4: variant unequality impeded'); - if (pVarComparison != true) console.warn('QV4: variant comparison impeded'); - if (pVarShift != 333) console.warn('QV4: variant shift impeded'); - } -} diff --git a/tests/auto/qml/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h deleted file mode 100644 index ee516f2927..0000000000 --- a/tests/auto/qml/v4/testtypes.h +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include <QtCore/qobject.h> -#include <QtCore/qurl.h> -#include <QVector3D> -#include <QJSValue> - -class NestedObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int dummy READ dummy); - Q_PROPERTY(int result READ result FINAL CONSTANT); - -public: - int dummy() const { return 7; } - int result() const { return 37; } -}; - -class ResultObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult FINAL) - Q_PROPERTY(NestedObject *nested READ nested CONSTANT) - Q_PROPERTY(NestedObject *nested2 READ nested2 FINAL CONSTANT) -public: - ResultObject() : m_result(0), m_resultCounter(0) {} - - int resultCounter() const { return m_resultCounter; } - void resetResultCounter() { m_resultCounter = 0; } - - int result() const { return m_result; } - void setResult(int result) { m_result = result; m_resultCounter++; } - - NestedObject *nested() { return &m_nested; } - NestedObject *nested2() { return &m_nested2; } - -private: - int m_result; - int m_resultCounter; - - NestedObject m_nested; - NestedObject m_nested2; -}; - -class ConversionObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool boolProp READ boolProp WRITE setBoolProp NOTIFY boolPropChanged) - Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) - Q_PROPERTY(float floatProp READ floatProp WRITE setFloatProp NOTIFY floatPropChanged) - Q_PROPERTY(double doubleProp READ doubleProp WRITE setDoubleProp NOTIFY doublePropChanged) - Q_PROPERTY(qreal qrealProp READ qrealProp WRITE setQrealProp NOTIFY qrealPropChanged) - Q_PROPERTY(QString qstringProp READ qstringProp WRITE setQstringProp NOTIFY qstringPropChanged) - Q_PROPERTY(QUrl qurlProp READ qurlProp WRITE setQurlProp NOTIFY qurlPropChanged) - Q_PROPERTY(QVector3D vec3Prop READ vec3Prop WRITE setVec3Prop NOTIFY vec3PropChanged) - Q_PROPERTY(QJSValue jsvalueProp READ jsvalueProp WRITE setJsvalueProp NOTIFY jsvaluePropChanged) - -public: - ConversionObject() : m_boolProp(false), m_intProp(0), m_floatProp(0.0), m_doubleProp(0.0), m_qrealProp(0.0) {} - ~ConversionObject() {} - - bool boolProp() const { return m_boolProp; } - void setBoolProp(bool v) { m_boolProp = v; emit boolPropChanged(); } - int intProp() const { return m_intProp; } - void setIntProp(int v) { m_intProp = v; emit intPropChanged(); } - float floatProp() const { return m_floatProp; } - void setFloatProp(float v) { m_floatProp = v; emit floatPropChanged(); } - double doubleProp() const { return m_doubleProp; } - void setDoubleProp(double v) { m_doubleProp = v; emit doublePropChanged(); } - qreal qrealProp() const { return m_qrealProp; } - void setQrealProp(qreal v) { m_qrealProp = v; emit qrealPropChanged(); } - QString qstringProp() const { return m_qstringProp; } - void setQstringProp(const QString& v) { m_qstringProp = v; emit qstringPropChanged(); } - QUrl qurlProp() const { return m_qurlProp; } - void setQurlProp(const QUrl& v) { m_qurlProp = v; emit qurlPropChanged(); } - QVector3D vec3Prop() const { return m_vec3Prop; } - void setVec3Prop(const QVector3D& v) { m_vec3Prop = v; emit vec3PropChanged(); } - QJSValue jsvalueProp() const { return m_jsvalueProp; } - void setJsvalueProp(const QJSValue &v) { m_jsvalueProp = v; emit jsvaluePropChanged(); } - -signals: - void boolPropChanged(); - void intPropChanged(); - void floatPropChanged(); - void doublePropChanged(); - void qrealPropChanged(); - void qstringPropChanged(); - void qurlPropChanged(); - void vec3PropChanged(); - void jsvaluePropChanged(); - -private: - bool m_boolProp; - int m_intProp; - float m_floatProp; - double m_doubleProp; - qreal m_qrealProp; - QString m_qstringProp; - QUrl m_qurlProp; - QVector3D m_vec3Prop; - QJSValue m_jsvalueProp; -}; - -class JSValueTest : public QObject -{ - Q_OBJECT - Q_PROPERTY(QJSValue boolVar READ boolVar WRITE setBoolVar NOTIFY boolVarChanged) - Q_PROPERTY(QJSValue intVar READ intVar WRITE setIntVar NOTIFY intVarChanged) - Q_PROPERTY(QJSValue realVar READ realVar WRITE setRealVar NOTIFY realVarChanged) - Q_PROPERTY(QJSValue stringVar READ stringVar WRITE setStringVar NOTIFY stringVarChanged) - Q_PROPERTY(QJSValue urlVar READ urlVar WRITE setUrlVar NOTIFY urlVarChanged) - Q_PROPERTY(QJSValue colorVar READ colorVar WRITE setColorVar NOTIFY colorVarChanged) - Q_PROPERTY(QJSValue objectVar READ objectVar WRITE setObjectVar NOTIFY objectVarChanged) - Q_PROPERTY(QJSValue nullVar READ nullVar WRITE setNullVar NOTIFY nullVarChanged) - Q_PROPERTY(QJSValue varVar READ varVar WRITE setVarVar NOTIFY varVarChanged) - -public: - JSValueTest() {} - ~JSValueTest() {} - - QJSValue boolVar() const { return m_boolVar; } - void setBoolVar(const QJSValue &v) { m_boolVar = v; emit boolVarChanged(); } - - QJSValue intVar() const { return m_intVar; } - void setIntVar(const QJSValue &v) { m_intVar = v; emit intVarChanged(); } - - QJSValue realVar() const { return m_realVar; } - void setRealVar(const QJSValue &v) { m_realVar = v; emit realVarChanged(); } - - QJSValue stringVar() const { return m_stringVar; } - void setStringVar(const QJSValue &v) { m_stringVar = v; emit stringVarChanged(); } - - QJSValue urlVar() const { return m_urlVar; } - void setUrlVar(const QJSValue &v) { m_urlVar = v; emit urlVarChanged(); } - - QJSValue colorVar() const { return m_colorVar; } - void setColorVar(const QJSValue &v) { m_colorVar = v; emit colorVarChanged(); } - - QJSValue objectVar() const { return m_objectVar; } - void setObjectVar(const QJSValue &v) { m_objectVar = v; emit objectVarChanged(); } - - QJSValue nullVar() const { return m_nullVar; } - void setNullVar(const QJSValue &v) { m_nullVar = v; emit nullVarChanged(); } - - QJSValue varVar() const { return m_varVar; } - void setVarVar(const QJSValue &v) { m_varVar = v; emit varVarChanged(); } - -signals: - void boolVarChanged(); - void intVarChanged(); - void realVarChanged(); - void stringVarChanged(); - void urlVarChanged(); - void colorVarChanged(); - void objectVarChanged(); - void nullVarChanged(); - void varVarChanged(); - -private: - QJSValue m_boolVar; - QJSValue m_intVar; - QJSValue m_realVar; - QJSValue m_stringVar; - QJSValue m_urlVar; - QJSValue m_colorVar; - QJSValue m_objectVar; - QJSValue m_nullVar; - QJSValue m_varVar; -}; - -void registerTypes(); - -#endif // TESTTYPES_H - diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp deleted file mode 100644 index e08bccd016..0000000000 --- a/tests/auto/qml/v4/tst_v4.cpp +++ /dev/null @@ -1,1125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <qtest.h> -#include <QtCore/qobject.h> -#include <QtCore/qfileinfo.h> -#include <QtCore/qdir.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlcomponent.h> -#include <QtCore/qdebug.h> -#include <QtGui/qcolor.h> -#include <QtCore/qnumeric.h> - -#include <private/qv4compiler_p.h> - -#include "../../shared/util.h" -#include "testtypes.h" - -class tst_v4 : public QQmlDataTest -{ - Q_OBJECT -public: - tst_v4() {} - -private slots: - void initTestCase(); - - void unnecessaryReeval(); - void logicalOr(); - void nestedLogicalOr(); - void logicalAnd(); - void nestedLogicalAnd(); - void conditionalExpr(); - void qtscript(); - void qtscript_data(); - void nestedObjectAccess(); - void subscriptionsInConditionalExpressions(); - void qtbug_21883(); - void qtbug_22816(); - void stringComparison(); - void unaryMinus(); - void unaryPlus(); - void colorType(); - void mathAbs(); - void mathCeil(); - void mathFloor(); - void mathMax(); - void mathMin(); - void mathCos(); - void mathSin(); - void singletonType(); - void integerOperations(); - - void conversions_data(); - void conversions(); - void subscriptions(); - - void debuggingDumpInstructions(); // this test should be last. - -private: - QQmlEngine engine; -}; - -void tst_v4::initTestCase() -{ - QQmlDataTest::initTestCase(); - registerTypes(); -} - -void tst_v4::qtscript() -{ - QFETCH(QString, file); - QV4Compiler::enableBindingsTest(true); - - QQmlComponent component(&engine, testFileUrl(file)); - - QQmlTestMessageHandler messageHandler; - - QObject *o = component.create(); - delete o; - - QEXPECT_FAIL("jsvalueHandling", "QTBUG-26951 - QJSValue has a different representation of NULL to QV8Engine", Continue); - const int v4ErrorCount = messageHandler.messages().filter(QLatin1String("QV4")).size(); - QVERIFY2(v4ErrorCount == 0, qPrintable(messageHandler.messageString())); - - QV4Compiler::enableBindingsTest(false); -} - -void tst_v4::qtscript_data() -{ - QTest::addColumn<QString>("file"); - - QTest::newRow("equals") << "equals.qml"; - QTest::newRow("strict equals") << "strictEquals.qml"; - QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml"; - QTest::newRow("exception on fetch") << "fetchException.qml"; - QTest::newRow("logical or") << "logicalOr.qml"; - QTest::newRow("conditional expressions") << "conditionalExpr.qml"; - QTest::newRow("double bool jump") << "doubleBoolJump.qml"; - QTest::newRow("unary minus") << "unaryMinus.qml"; - QTest::newRow("null qobject") << "nullQObject.qml"; - QTest::newRow("qobject -> bool") << "objectToBool.qml"; - QTest::newRow("conversion from bool") << "conversions.1.qml"; - QTest::newRow("conversion from int") << "conversions.2.qml"; - QTest::newRow("conversion from float") << "conversions.3.qml"; - QTest::newRow("conversion from double") << "conversions.4.qml"; - QTest::newRow("conversion from real") << "conversions.5.qml"; - QTest::newRow("conversion from string") << "conversions.6.qml"; - QTest::newRow("conversion from url") << "conversions.7.qml"; - QTest::newRow("conversion from vec3") << "conversions.8.qml"; - QTest::newRow("variantHandling") << "variantHandling.qml"; - QTest::newRow("varHandling") << "varHandling.qml"; - QTest::newRow("jsvalueHandling") << "jsvalueHandling.qml"; - QTest::newRow("integerOperations") << "integerOperations.qml"; -} - -void tst_v4::unnecessaryReeval() -{ - QQmlComponent component(&engine, testFileUrl("unnecessaryReeval.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 19); - ro->resetResultCounter(); - - ro->setProperty("b", 6); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 6); - ro->resetResultCounter(); - - ro->setProperty("a", 14); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 7); - ro->resetResultCounter(); - - ro->setProperty("b", 14); - QCOMPARE(ro->resultCounter(), 0); - QCOMPARE(ro->result(), 7); - - delete o; -} - -void tst_v4::logicalOr() -{ - { - QQmlComponent component(&engine, testFileUrl("logicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalOr.2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } -} - -void tst_v4::nestedLogicalOr() -{ - //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) - QQmlComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; -} - -void tst_v4::logicalAnd() -{ - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.3.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - // QTBUG-24660 - QQmlComponent component(&engine, testFileUrl("logicalAnd.4.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.5.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.6.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("logicalAnd.7.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } -} - -void tst_v4::nestedLogicalAnd() -{ - QQmlComponent component(&engine, testFileUrl("nestedLogicalAnd.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; -} - -void tst_v4::conditionalExpr() -{ - { - QQmlComponent component(&engine, testFileUrl("conditionalExpr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } -} - -// This would previously use the metaObject of the root element to result the nested access. -// That is, the index for accessing "result" would have been RootObject::result, instead of -// NestedObject::result. -void tst_v4::nestedObjectAccess() -{ - { - QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 37); - - delete o; - } - - { - QQmlComponent component(&engine, testFileUrl("nestedObjectAccess2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast<ResultObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 37); - - delete o; - } -} - -void tst_v4::subscriptionsInConditionalExpressions() -{ - QQmlComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QObject *ro = qobject_cast<QObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->property("result").toReal(), qreal(2)); - - delete o; -} - -// Crash test -void tst_v4::qtbug_21883() -{ - QQmlComponent component(&engine, testFileUrl("qtbug_21883.qml")); - - QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); - - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - -void tst_v4::qtbug_22816() -{ - QQmlComponent component(&engine, testFileUrl("qtbug_22816.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), false); - QCOMPARE(o->property("test2").toBool(), false); - delete o; -} - -void tst_v4::stringComparison() -{ - QQmlComponent component(&engine, testFileUrl("stringComparison.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toBool(), true); - QCOMPARE(o->property("test12").toBool(), true); - QCOMPARE(o->property("test13").toBool(), true); - QCOMPARE(o->property("test14").toBool(), true); - QCOMPARE(o->property("test15").toBool(), true); - QCOMPARE(o->property("test16").toBool(), true); - QCOMPARE(o->property("test17").toBool(), true); - QCOMPARE(o->property("test18").toBool(), true); - QCOMPARE(o->property("test19").toBool(), true); - QCOMPARE(o->property("test20").toBool(), true); - QCOMPARE(o->property("test21").toBool(), true); - QCOMPARE(o->property("test22").toBool(), true); - delete o; -} - -void tst_v4::unaryMinus() -{ - QQmlComponent component(&engine, testFileUrl("unaryMinus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-18)); - QCOMPARE(o->property("test2").toInt(), -18); - QCOMPARE(o->property("test3").toReal(), qreal(3.7)); - QCOMPARE(o->property("test4").toInt(), 4); - QCOMPARE(o->property("test5").toReal(), qreal(3.3)); - QCOMPARE(o->property("test6").toInt(), 3); - QCOMPARE(o->property("test7").toReal(), qreal(7)); - QCOMPARE(o->property("test8").toInt(), 7); - QCOMPARE(o->property("test9").toReal(), qreal(-4.4)); - QCOMPARE(o->property("test10").toInt(), -4); - - delete o; -} - -void tst_v4::unaryPlus() -{ - QQmlComponent component(&engine, testFileUrl("unaryPlus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(18)); - QCOMPARE(o->property("test2").toInt(), 18); - QCOMPARE(o->property("test3").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test4").toInt(), -4); - QCOMPARE(o->property("test5").toReal(), qreal(-3.3)); - QCOMPARE(o->property("test6").toInt(), -3); - QCOMPARE(o->property("test7").toReal(), qreal(-7)); - QCOMPARE(o->property("test8").toInt(), -7); - QCOMPARE(o->property("test9").toReal(), qreal(4.4)); - QCOMPARE(o->property("test10").toInt(), 4); - - delete o; -} - -void tst_v4::colorType() -{ - QQmlComponent component(&engine, testFileUrl("colorType.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test2").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test3").value<QColor>(), QColor("red")); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - delete o; -} - -void tst_v4::mathAbs() -{ - QQmlComponent component(&engine, testFileUrl("mathAbs.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(3.7)); - QCOMPARE(o->property("test2").toReal(), qreal(4.5)); - QCOMPARE(o->property("test3").toInt(), 18); - QCOMPARE(o->property("test4").toInt(), 72); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toInt(), 82); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toInt(), 0); - QCOMPARE(o->property("test12").toBool(), true); - - delete o; -} - -void tst_v4::mathCeil() -{ - QQmlComponent component(&engine, testFileUrl("mathCeil.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-3)); - QCOMPARE(o->property("test2").toReal(), qreal(5)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(83)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toInt(), 0); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toBool(), true); - - delete o; -} - -void tst_v4::mathFloor() -{ - QQmlComponent component(&engine, testFileUrl("mathFloor.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-4)); - QCOMPARE(o->property("test2").toReal(), qreal(4)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toInt(), 0); - QCOMPARE(o->property("test10").toBool(), true); - - delete o; -} - -void tst_v4::mathMax() -{ - QQmlComponent component(&engine, testFileUrl("mathMax.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(4.4)); - QCOMPARE(o->property("test2").toReal(), qreal(7)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82.6)); - QCOMPARE(o->property("test7").toReal(), qreal(4.4)); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toReal(), qreal(0)); - QCOMPARE(o->property("test12").toReal(), qreal(4.4)); - QCOMPARE(o->property("test13").toReal(), qreal(7)); - - delete o; -} - -void tst_v4::mathMin() -{ - QQmlComponent component(&engine, testFileUrl("mathMin.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test2").toReal(), qreal(4.4)); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toReal(), qreal(82.6)); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toReal(), qreal(4.4)); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test12").toReal(), qreal(0)); - QCOMPARE(o->property("test13").toReal(), qreal(-3.7)); - delete o; -} - -static bool fuzzyCompare(qreal a, qreal b) -{ - const qreal EPSILON = 0.0001; - return (a + EPSILON > b) && (a - EPSILON < b); -} - -void tst_v4::mathCos() -{ - QQmlComponent component(&engine, testFileUrl("mathCos.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QVERIFY(fuzzyCompare(o->property("test1").toReal(), qreal(-0.848100))); - QVERIFY(fuzzyCompare(o->property("test2").toReal(), qreal(-0.307333))); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test6").toReal(), qreal(0.606941))); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test11").toReal(), qreal(0.890792))); - - delete o; -} - -void tst_v4::mathSin() -{ - QQmlComponent component(&engine, testFileUrl("mathSin.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QVERIFY(fuzzyCompare(o->property("test1").toReal(), qreal(0.529836))); - QVERIFY(fuzzyCompare(o->property("test2").toReal(), qreal(-0.951602))); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test6").toReal(), qreal(0.794747))); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QVERIFY(fuzzyCompare(o->property("test11").toReal(), qreal(0.454411))); - - delete o; -} - -void tst_v4::integerOperations() -{ - QQmlComponent component(&engine, testFileUrl("integerOperations.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("testa1").toInt(), 333); - QCOMPARE(o->property("testa2").toInt(), -666); - - QCOMPARE(o->property("testb1").toInt(), 0); - QCOMPARE(o->property("testb2").toInt(), 2); - QCOMPARE(o->property("testb3").toInt(), 0); - QCOMPARE(o->property("testb4").toInt(), 2); - QCOMPARE(o->property("testb5").toInt(), 0); - QCOMPARE(o->property("testb6").toInt(), 2); - QCOMPARE(o->property("testb7").toInt(), 0); - QCOMPARE(o->property("testb8").toInt(), 2); - - QCOMPARE(o->property("testc1").toInt(), 335); - QCOMPARE(o->property("testc2").toInt(), -666); - QCOMPARE(o->property("testc3").toInt(), 335); - QCOMPARE(o->property("testc4").toInt(), -666); - QCOMPARE(o->property("testc5").toInt(), 335); - QCOMPARE(o->property("testc6").toInt(), -666); - QCOMPARE(o->property("testc7").toInt(), 335); - QCOMPARE(o->property("testc8").toInt(), -666); - - QCOMPARE(o->property("testd1").toInt(), 330); - QCOMPARE(o->property("testd2").toInt(), 330); - QCOMPARE(o->property("testd3").toInt(), 330); - QCOMPARE(o->property("testd4").toInt(), 330); - - QCOMPARE(o->property("teste1").toInt(), 28); - QCOMPARE(o->property("teste2").toInt(), -28); - QCOMPARE(o->property("teste3").toInt(), 256); - QCOMPARE(o->property("teste4").toInt(), 28); - QCOMPARE(o->property("teste5").toInt(), -28); - QCOMPARE(o->property("teste6").toInt(), 256); - - QCOMPARE(o->property("testf1").toInt(), 1); - QCOMPARE(o->property("testf2").toInt(), -2); - QCOMPARE(o->property("testf3").toInt(), 0); - QCOMPARE(o->property("testf4").toInt(), 1); - QCOMPARE(o->property("testf5").toInt(), -2); - QCOMPARE(o->property("testf6").toInt(), 0); - - QCOMPARE(o->property("testg1").toInt(), 1); - QCOMPARE(o->property("testg2").toInt(), 0x3FFFFFFE); - QCOMPARE(o->property("testg3").toInt(), 0); - QCOMPARE(o->property("testg4").toInt(), 1); - QCOMPARE(o->property("testg5").toInt(), 0x3FFFFFFE); - QCOMPARE(o->property("testg6").toInt(), 0); - - delete o; -} - -class V4SingletonType : public QObject -{ - Q_OBJECT - Q_PROPERTY(int ip READ ip WRITE setIp NOTIFY ipChanged FINAL) -public: - V4SingletonType() : m_ip(12) {} - ~V4SingletonType() {} - - Q_INVOKABLE int random() { static int prng = 3; prng++; m_ip++; emit ipChanged(); return prng; } - - int ip() const { return m_ip; } - void setIp(int v) { m_ip = v; emit ipChanged(); } - -signals: - void ipChanged(); - -private: - int m_ip; -}; - -static QObject *v4_module_api_factory(QQmlEngine*, QJSEngine*) -{ - return new V4SingletonType; -} - -void tst_v4::singletonType() -{ - // register singleton type, providing typeinfo via template - qmlRegisterSingletonType<V4SingletonType>("Qt.test", 1, 0, "V4", v4_module_api_factory); - QQmlComponent component(&engine, testFileUrl("singletonType.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("testProp").toInt(), 12); - QCOMPARE(o->property("testProp2").toInt(), 2); - QMetaObject::invokeMethod(o, "getRandom"); - QCOMPARE(o->property("testProp").toInt(), 13); - QCOMPARE(o->property("testProp2").toInt(), 4); - delete o; -} - -void tst_v4::conversions_data() -{ - QTest::addColumn<QUrl>("file"); - QTest::addColumn<QStringList>("warnings"); - QTest::addColumn<bool>("boolProp"); - QTest::addColumn<int>("intProp"); - QTest::addColumn<float>("floatProp"); - QTest::addColumn<double>("doubleProp"); - QTest::addColumn<qreal>("qrealProp"); - QTest::addColumn<QString>("qstringProp"); - QTest::addColumn<QUrl>("qurlProp"); - QTest::addColumn<QVector3D>("vec3Prop"); - - QTest::newRow("from bool") << testFileUrl("conversions.1.qml") - << (QStringList() << (testFileUrl("conversions.1.qml").toString() + QLatin1String(":11:15: Unable to assign bool to QUrl"))) - << true - << (int)true - << (float)1.0 - << (double)1.0 - << (qreal)1.0 - << QString(QLatin1String("true")) - << QUrl() // cannot assign bool to url. - << QVector3D(1, 1, 1); - - QTest::newRow("from integer") << testFileUrl("conversions.2.qml") - << (QStringList() << (testFileUrl("conversions.2.qml").toString() + QLatin1String(":11:15: Unable to assign int to QUrl"))) - << (bool)4 - << 4 - << (float)4.0 - << (double)4.0 - << (qreal)4.0 - << QString(QLatin1String("4")) - << QUrl() // cannot assign int to url. - << QVector3D(4, 4, 4); - - QTest::newRow("from float") << testFileUrl("conversions.3.qml") - << (QStringList() << (testFileUrl("conversions.3.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.4 - << (int)4.4 - << (float)4.4 - << (double)((float)4.4) - << (qreal)((float)4.4) - << QString::number((double)((float)4.4), 'g', 16) - << QUrl() // cannot assign number to url. - << QVector3D(4.4, 4.4, 4.4); - - QTest::newRow("from double") << testFileUrl("conversions.4.qml") - << (QStringList() << (testFileUrl("conversions.4.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.444444444 - << (int)4.444444444 - << (float)4.444444444 - << (double)4.444444444 - << (qreal)4.444444444 - << QString::number((double)4.444444444, 'g', 16) - << QUrl() // cannot assign number to url. - << QVector3D(4.444444444, 4.444444444, 4.444444444); - - QTest::newRow("from qreal") << testFileUrl("conversions.5.qml") - << (QStringList() << (testFileUrl("conversions.5.qml").toString() + QLatin1String(":11:15: Unable to assign number to QUrl"))) - << (bool)4.44 - << (int)4.44 - << (float)4.44 - << (double)4.44 - << (qreal)4.44 - << QString(QLatin1String("4.44")) - << QUrl() // cannot assign number to url. - << QVector3D(4.44, 4.44, 4.44); - - QTest::newRow("from string") << testFileUrl("conversions.6.qml") - << (QStringList()) - << true - << 4 - << (float)4.0 - << (double)4.0 - << (qreal)4.0 - << QString(QLatin1String("4")) - << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QVector3D(4, 4, 4); - - QTest::newRow("from url") << testFileUrl("conversions.7.qml") - << (QStringList() << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":6:14: Unable to assign QUrl to int")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":7:16: Unable to assign QUrl to number")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":8:17: Unable to assign QUrl to number")) - << (testFileUrl("conversions.7.qml").toString() + QLatin1String(":9:16: Unable to assign QUrl to number"))) - << true - << 0 - << (float) 0 - << (double) 0 - << (qreal) 0 - << QString(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QUrl(testFileUrl("").toString() + QString(QLatin1String("4"))) - << QVector3D(qQNaN(), qQNaN(), qQNaN()); - - QTest::newRow("from vector") << testFileUrl("conversions.8.qml") - << (QStringList() << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":11: Unable to assign QVector3D to QUrl")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":10: Unable to assign QVector3D to QString")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":9: Unable to assign QVector3D to double")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":8: Unable to assign QVector3D to double")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":7: Unable to assign QVector3D to float")) - << (testFileUrl("conversions.8.qml").toString() + QLatin1String(":6: Unable to assign QVector3D to int"))) - << true // non-null therefore true - << (int)0 // the other values should be the default-ctor values. - << (float)0 - << (double)0 - << (qreal)0 - << QString() - << QUrl() - << QVector3D(4, 4, 4); // except this one. -} - -#define COMPARE_NUMBER(type, prop, expected) \ - if (qIsNaN(expected)) \ - QVERIFY(qIsNaN(qvariant_cast<type>(prop))); \ - else \ - QCOMPARE((prop), QVariant::fromValue<type>(expected)); - -void tst_v4::conversions() -{ - QFETCH(QUrl, file); - QFETCH(QStringList, warnings); - QFETCH(bool, boolProp); - QFETCH(int, intProp); - QFETCH(float, floatProp); - QFETCH(double, doubleProp); - QFETCH(qreal, qrealProp); - QFETCH(QString, qstringProp); - QFETCH(QUrl, qurlProp); - QFETCH(QVector3D, vec3Prop); - - foreach (const QString &w, warnings) - QTest::ignoreMessage(QtWarningMsg, qPrintable(w)); - - QQmlComponent component(&engine, file); - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("boolProp"), QVariant::fromValue<bool>(boolProp)); - QCOMPARE(o->property("intProp"), QVariant::fromValue<int>(intProp)); - COMPARE_NUMBER(float, o->property("floatProp"), floatProp); - COMPARE_NUMBER(double, o->property("doubleProp"), doubleProp); - COMPARE_NUMBER(qreal, o->property("qrealProp"), qrealProp); - QCOMPARE(o->property("qstringProp"), QVariant::fromValue<QString>(qstringProp)); - QCOMPARE(o->property("qurlProp"), QVariant::fromValue<QUrl>(qurlProp)); - - QVector3D vec3 = qvariant_cast<QVector3D>(o->property("vec3Prop")); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.x()), vec3Prop.x()); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.y()), vec3Prop.y()); - COMPARE_NUMBER(qreal, QVariant::fromValue<qreal>(vec3.z()), vec3Prop.z()); - delete o; -} - -void tst_v4::subscriptions() -{ - { - QQmlComponent component(&engine, testFileUrl("subscriptions.1.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QObject *ro = qobject_cast<QObject *>(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->property("targetHeight"), QVariant::fromValue<qreal>(201)); - - delete o; - } -} - -static QByteArray getAddress(int address) -{ - return QByteArray::number(address); -} - -static QByteArray getLeading(int address) -{ - QByteArray leading; - if (address != -1) { - leading = getAddress(address); - leading.prepend(QByteArray(8 - leading.count(), ' ')); - } - return leading; -} - -#include <private/qv4instruction_p.h> -void tst_v4::debuggingDumpInstructions() -{ - QStringList expectedPreAddress; - expectedPreAddress << "\t\tNoop"; - expectedPreAddress << "\t0:0:"; - expectedPreAddress << "\t\tSubscribeId\t\tId_Offset(0) -> Subscribe_Slot(0)"; - expectedPreAddress << "\t\tFetchAndSubscribe\tObject_Reg(0) Fast_Accessor(0x0) -> Output_Reg(0) Subscription_Slot(0)"; - expectedPreAddress << "\t\tLoadId\t\t\tId_Offset(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadScope\t\t-> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadRoot\t\t-> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadSingletonObject\t\t) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadAttached\t\tObject_Reg(0) Attached_Index(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryNot\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryMinusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryMinusInt\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryPlusNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tUnaryPlusInt\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToInt\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToNumber\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToString\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertBoolToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToNumber\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToString\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertIntToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertJSValueToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToInt\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToString\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNumberToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToInt\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToNumber\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToUrl\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToColor\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertStringToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertUrlToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertUrlToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertUrlToString\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertUrlToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertUrlToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertColorToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertColorToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertColorToString\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertColorToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertColorToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertObjectToBool\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertObjectToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertObjectToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertObjectToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertVarToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNullToJSValue\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNullToObject\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNullToVariant\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tConvertNullToVar\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tResolveUrl\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathSinNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathCosNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathAbsNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathRoundNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathFloorNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathCeilNumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathPINumber\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadNull\t\tConstant(null) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadNumber\t\tConstant(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadInt\t\t\tConstant(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadBool\t\tConstant(false) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLoadString\t\tString_DataIndex(0) String_Length(0) -> Output_Register(0)"; - expectedPreAddress << "\t\tEnableV4Test\t\tString_DataIndex(0) String_Length(0)"; - expectedPreAddress << "\t\tTestV4Store\t\tInput_Reg(0) Reg_Type(0)"; - expectedPreAddress << "\t\tBitAndInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tBitOrInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tBitXorInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tAddNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tAddString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tSubNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMulNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tDivNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tModNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tRShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tURShiftInt\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLtNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLeNumber\t\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualNumber\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLtString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tGeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tLeString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualString\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualString\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNotEqualObject\t\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStrictNotEqualObject\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathMaxNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tMathMinNumber\tInput_Reg(0) Input_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tNewString\t\tRegister(0)"; - expectedPreAddress << "\t\tNewUrl\t\t\tRegister(0)"; - expectedPreAddress << "\t\tCleanupRegister\t\tRegister(0)"; - expectedPreAddress << "\t\tCopy\t\t\tInput_Reg(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tFetch\t\t\tObject_Reg(0) Property_Index(0) -> Output_Reg(0)"; - expectedPreAddress << "\t\tStore\t\t\tInput_Reg(0) -> Object_Reg(0) Property_Index(0)"; - expectedPreAddress << "\t\tJump\t\t\tAddress(UNIT_TEST_JUMP_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->jump.count) - expectedPreAddress << "\t\tBranchTrue\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if true == Input_Reg(0)]"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBranchFalse\t\tAddress(UNIT_TEST_BRANCH_ADDRESS) [if false == Input_Reg(0)]"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBranch\t\t\tAddress(UNIT_TEST_BRANCH_ADDRESS)"; //(address + size() + i->branchop.offset) - expectedPreAddress << "\t\tBlock\t\t\tMask(0)"; - expectedPreAddress << "\t\tThrow\t\t\tInputReg(0)"; - expectedPreAddress << "\t\tInitString\t\tString_DataIndex(0) -> String_Slot(0)"; - QStringList expected; - - QQmlTestMessageHandler messageHandler; - - QQmlJS::Bytecode bc; -#define DUMP_INSTR_IN_UNIT_TEST(I, FMT) { QQmlJS::V4InstrData<QQmlJS::V4Instr::I> i; memset(&i, 0, sizeof(i)); bc.append(i); } - FOR_EACH_V4_INSTR(DUMP_INSTR_IN_UNIT_TEST); -#undef DUMP_INSTR_IN_UNIT_TEST // NOTE: we memset in order to ensure stable output. - const char *start = bc.constData(); - const char *end = start + bc.size(); - const char *codeAddr = start; - int whichExpected = 0; -#define DUMP_INSTR_SIZE_IN_UNIT_TEST(I, FMT) { \ - QString currExpected = whichExpected < expectedPreAddress.size() ? expectedPreAddress.at(whichExpected++) : QString(); \ - currExpected.prepend(getLeading(codeAddr - start)); \ - expected.append(currExpected); \ - codeAddr += QQmlJS::V4Instr::size(static_cast<QQmlJS::V4Instr::Type>(QQmlJS::V4Instr::I)); \ - } - FOR_EACH_V4_INSTR(DUMP_INSTR_SIZE_IN_UNIT_TEST); -#undef DUMP_INSTR_SIZE_IN_UNIT_TEST // so that we generate the correct address for each instruction comparison - bc.dump(start, end); - - // ensure that the output was expected. - const int messageCount = messageHandler.messages().count(); - QCOMPARE(messageCount, expected.count()); - for (int ii = 0; ii < messageCount; ++ii) { - // Calculating the destination address of a null jump/branch instruction is tricky - // so instead we simply don't compare that part of those instructions. - QRegExp ignoreAddress("\\bAddress\\((\\w*)\\)"); - ignoreAddress.setMinimal(true); - QString expectOut = expected.at(ii); expectOut.replace(ignoreAddress, ""); - QString actualOut = messageHandler.messages().at(ii); actualOut.replace(ignoreAddress, ""); - QCOMPARE(actualOut, expectOut); - } -} - - -QTEST_MAIN(tst_v4) - -#include "tst_v4.moc" diff --git a/tests/auto/qml/v4/v4.pro b/tests/auto/qml/v4/v4.pro deleted file mode 100644 index 8c7c30e399..0000000000 --- a/tests/auto/qml/v4/v4.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qqmlv4 -macx:CONFIG -= app_bundle - -SOURCES += tst_v4.cpp \ - testtypes.cpp -HEADERS += testtypes.h - -include (../../shared/util.pri) - -TESTDATA = data/* - -CONFIG += parallel_test - -QT += core-private gui-private v8-private qml-private network testlib -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro index e3b1caa689..4069ad4c68 100644 --- a/tests/auto/quick/dialogs/dialogs.pro +++ b/tests/auto/quick/dialogs/dialogs.pro @@ -10,7 +10,7 @@ linux-*:CONFIG+=insignificant_test # QTBUG-30513 - test is unstable win32:CONFIG+=insignificant_test # QTBUG-30513 - test is unstable CONFIG += parallel_test -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib TESTDATA = data/* diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro index 7f95771766..6543aa1b2b 100644 --- a/tests/auto/quick/examples/examples.pro +++ b/tests/auto/quick/examples/examples.pro @@ -8,5 +8,5 @@ DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test #temporary -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickanchors/qquickanchors.pro b/tests/auto/quick/qquickanchors/qquickanchors.pro index b2e1c9df36..184066753b 100644 --- a/tests/auto/quick/qquickanchors/qquickanchors.pro +++ b/tests/auto/quick/qquickanchors/qquickanchors.pro @@ -11,5 +11,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro index 747a2afdff..1e294b9ae0 100644 --- a/tests/auto/quick/qquickanimations/qquickanimations.pro +++ b/tests/auto/quick/qquickanimations/qquickanimations.pro @@ -11,5 +11,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro index cbe9cf76fe..f005c03a82 100644 --- a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro +++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml index b72e755ed9..b18250291e 100644 --- a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml +++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml @@ -70,4 +70,116 @@ Canvas { compare(canvas.contextInPaint, canvas.getContext("2d")); } } + + // See: http://www.w3.org/TR/css3-fonts/#font-prop + TestCase { + name: "ContextFontValidation" + when: canvas.available + + function test_pixelSize() { + wait(100); + compare(contextSpy.count, 1); + + var ctx = canvas.getContext("2d"); + compare(ctx.font, "sans-serif,-1,10,5,50,0,0,0,0,0"); + + ctx.font = "80.1px cursive"; + // Can't verify the chosen font family since it's different for each platform. + compare(ctx.font.substr(ctx.font.indexOf(",") + 1), "-1,80,5,50,0,0,0,0,0"); + } + + function test_valid() { + wait(100); + compare(contextSpy.count, 1); + + var ctx = canvas.getContext("2d"); + + var validFonts = [ + { string: "12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12px serif", expected: "serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12pt sans-serif", expected: "sans-serif,12,-1,5,50,0,0,0,0,0" }, + { string: "12pt serif", expected: "serif,12,-1,5,50,0,0,0,0,0" }, + { string: "normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "normal normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "italic 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" }, + { string: "italic normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" }, + { string: "italic normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,1,0,0,0,0" }, + { string: "oblique 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" }, + { string: "oblique normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" }, + { string: "oblique normal normal 12px sans-serif", expected: "sans-serif,-1,12,5,50,2,0,0,0,0" }, + { string: "bold 12px sans-serif", expected: "sans-serif,-1,12,5,75,0,0,0,0,0" }, + { string: "0 12px sans-serif", expected: "sans-serif,-1,12,5,0,0,0,0,0,0" }, + { string: "small-caps 12px sans-serif", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12px \"sans-serif\"", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12px 'sans-serif'", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + // sans-serif will always be chosen, but this still tests that multiple families can be read. + { string: "12px 'sans-serif' 'cursive'", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12px sans-serif 'cursive' monospace", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: "12px sans-serif 'cursive' monospace ", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: " 12px sans-serif 'cursive' monospace ", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" }, + { string: " 12px sans-serif 'cursive' monospace ", expected: "sans-serif,-1,12,5,50,0,0,0,0,0" } + ]; + for (var i = 0; i < validFonts.length; ++i) { + ctx.font = validFonts[i].string; + compare(ctx.font.substr(ctx.font.indexOf(",") + 1), + validFonts[i].expected.substr(validFonts[i].expected.indexOf(",") + 1)); + } + } + + function test_invalid() { + wait(100); + compare(contextSpy.count, 1); + + var ctx = canvas.getContext("2d"); + var originalFont = ctx.font; + + var fontStrings = [ + "", + "12px", + "sans-serif", + "z12px sans-serif", + "1z2px sans-serif", + "12zpx sans-serif", + "12pxz sans-serif", + "sans-serif 12px", + "12px !@weeeeeeee!@!@Don'tNameYourFontThis", + "12px )(&*^^^%#$@*!!@#$JSPOR)", + "normal normal normal normal 12px sans-serif", + "normal normal bold bold 12px sans-serif", + "bold bold 12px sans-serif", + "12px 'cursive\"", + "12px 'cursive\" sans-serif", + "12px 'cursive" + ]; + + var ignoredWarnings = [ + "Context2D: Font string is empty.", + "Context2D: Missing or misplaced font family in font string (it must come after the font size).", + "Context2D: Invalid font size unit in font string.", + "Context2D: A font size of \"z12\" is invalid.", + "Context2D: A font size of \"1z2\" is invalid.", + "Context2D: A font size of \"12z\" is invalid.", + "Context2D: Invalid font size unit in font string.", + "Context2D: Missing or misplaced font family in font string (it must come after the font size).", + "Context2D: Unclosed quote in font string.", + "Context2D: The font families specified are invalid: )(&*^^^%#$@*!!@#$JSPOR)", + "Context2D: Duplicate token \"normal\" found in font string.", + "Context2D: Duplicate token \"bold\" found in font string.", + "Context2D: Duplicate token \"bold\" found in font string.", + "Context2D: Mismatched quote in font string.", + "Context2D: Mismatched quote in font string.", + "Context2D: Unclosed quote in font string." + ]; + + // Sanity check... + compare(ignoredWarnings.length, fontStrings.length); + + for (var i = 0; i < fontStrings.length; ++i) { + ignoreWarning(ignoredWarnings[i]); + ctx.font = fontStrings[i]; + compare(ctx.font, originalFont); + } + } + } } diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro index 67d5fc12f0..dfc8d7541b 100644 --- a/tests/auto/quick/qquickflickable/qquickflickable.pro +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -9,6 +9,6 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 CONFIG+=insignificant_test diff --git a/tests/auto/quick/qquickflipable/qquickflipable.pro b/tests/auto/quick/qquickflipable/qquickflipable.pro index d07aab8d71..3e4d04a401 100644 --- a/tests/auto/quick/qquickflipable/qquickflipable.pro +++ b/tests/auto/quick/qquickflipable/qquickflipable.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro index ab3de5b522..40b43fa2c0 100644 --- a/tests/auto/quick/qquickgridview/qquickgridview.pro +++ b/tests/auto/quick/qquickgridview/qquickgridview.pro @@ -10,8 +10,9 @@ include (../shared/util.pri) TESTDATA = data/* +QT += core-private gui-private qml-private quick-private testlib + win32:CONFIG += insignificant_test # QTBUG-33017 macx:CONFIG += insignificant_test # QTBUG-33017 -QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickitem/qquickitem.pro b/tests/auto/quick/qquickitem/qquickitem.pro index 5641ca5a6d..9bcba5de33 100644 --- a/tests/auto/quick/qquickitem/qquickitem.pro +++ b/tests/auto/quick/qquickitem/qquickitem.pro @@ -8,7 +8,8 @@ macx:CONFIG -= app_bundle TESTDATA = data/* +QT += core-private gui-private qml-private quick-private testlib + win32:CONFIG += insignificant_test # QTBUG-32664 -QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/quick/qquickitem2/data/standardkeys.qml index ba81e591fc..c29a143c28 100644 --- a/tests/auto/qml/v4/testtypes.cpp +++ b/tests/auto/quick/qquickitem2/data/standardkeys.qml @@ -38,14 +38,20 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "testtypes.h" -#include <QtQml/qqml.h> +import QtQuick 2.2 -void registerTypes() -{ - qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result"); - qmlRegisterType<NestedObject>(); - qmlRegisterType<ConversionObject>("Qt.v4", 1, 0, "Conversion"); - qmlRegisterType<JSValueTest>("Qt.v4", 1, 0, "JSValueTest"); +Item { + focus: true + + property bool pressed: false + property bool released: false + + Keys.onPressed: { + pressed = event.matches(standardKey) + } + + Keys.onReleased: { + released = event.matches(standardKey) + } } diff --git a/tests/auto/quick/qquickitem2/qquickitem2.pro b/tests/auto/quick/qquickitem2/qquickitem2.pro index 62c6ee361c..ac4200a8a3 100644 --- a/tests/auto/quick/qquickitem2/qquickitem2.pro +++ b/tests/auto/quick/qquickitem2/qquickitem2.pro @@ -8,5 +8,5 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 992e81aa64..d15a46feca 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -78,6 +78,8 @@ private slots: void nextItemInFocusChain2(); void keys(); + void standardKeys_data(); + void standardKeys(); void keysProcessingOrder(); void keysim(); void keyNavigation(); @@ -1089,6 +1091,64 @@ void tst_QQuickItem::keys() delete testObject; } +Q_DECLARE_METATYPE(QEvent::Type); +Q_DECLARE_METATYPE(QKeySequence::StandardKey); + +void tst_QQuickItem::standardKeys_data() +{ + QTest::addColumn<QKeySequence::StandardKey>("standardKey"); + QTest::addColumn<QKeySequence::StandardKey>("contextProperty"); + QTest::addColumn<QEvent::Type>("eventType"); + QTest::addColumn<bool>("pressed"); + QTest::addColumn<bool>("released"); + + QTest::newRow("Press: Open") << QKeySequence::Open << QKeySequence::Open << QEvent::KeyPress << true << false; + QTest::newRow("Press: Close") << QKeySequence::Close << QKeySequence::Close << QEvent::KeyPress << true << false; + QTest::newRow("Press: Save") << QKeySequence::Save << QKeySequence::Save << QEvent::KeyPress << true << false; + QTest::newRow("Press: Quit") << QKeySequence::Quit << QKeySequence::Quit << QEvent::KeyPress << true << false; + + QTest::newRow("Release: New") << QKeySequence::New << QKeySequence::New << QEvent::KeyRelease << false << true; + QTest::newRow("Release: Delete") << QKeySequence::Delete << QKeySequence::Delete << QEvent::KeyRelease << false << true; + QTest::newRow("Release: Undo") << QKeySequence::Undo << QKeySequence::Undo << QEvent::KeyRelease << false << true; + QTest::newRow("Release: Redo") << QKeySequence::Redo << QKeySequence::Redo << QEvent::KeyRelease << false << true; + + QTest::newRow("Mismatch: Cut") << QKeySequence::Cut << QKeySequence::Copy << QEvent::KeyPress << false << false; + QTest::newRow("Mismatch: Copy") << QKeySequence::Copy << QKeySequence::Paste << QEvent::KeyPress << false << false; + QTest::newRow("Mismatch: Paste") << QKeySequence::Paste << QKeySequence::Cut << QEvent::KeyRelease << false << false; + QTest::newRow("Mismatch: Quit") << QKeySequence::Quit << QKeySequence::New << QEvent::KeyRelease << false << false; +} + +void tst_QQuickItem::standardKeys() +{ + QFETCH(QKeySequence::StandardKey, standardKey); + QFETCH(QKeySequence::StandardKey, contextProperty); + QFETCH(QEvent::Type, eventType); + QFETCH(bool, pressed); + QFETCH(bool, released); + + QKeySequence keySequence(standardKey); + if (keySequence.isEmpty()) + QSKIP("Undefined key sequence."); + + QQuickView view; + view.rootContext()->setContextProperty("standardKey", contextProperty); + view.setSource(testFileUrl("standardkeys.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QQuickItem *item = qobject_cast<QQuickItem*>(view.rootObject()); + QVERIFY(item); + + const int key = keySequence[0] & Qt::Key_unknown; + const int modifiers = keySequence[0] & Qt::KeyboardModifierMask; + QKeyEvent keyEvent(eventType, key, static_cast<Qt::KeyboardModifiers>(modifiers)); + QGuiApplication::sendEvent(&view, &keyEvent); + + QCOMPARE(item->property("pressed").toBool(), pressed); + QCOMPARE(item->property("released").toBool(), released); +} + void tst_QQuickItem::keysProcessingOrder() { QQuickView *window = new QQuickView(0); diff --git a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro index d7e75a9924..999f0cf23d 100644 --- a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro +++ b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro @@ -9,7 +9,7 @@ TESTDATA = data/* include(../../shared/util.pri) CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib OTHER_FILES += \ data/Smooth.qml \ diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro index b0b1fc2518..a745c1ae46 100644 --- a/tests/auto/quick/qquicklistview/qquicklistview.pro +++ b/tests/auto/quick/qquicklistview/qquicklistview.pro @@ -12,7 +12,7 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 mac:CONFIG += insignificant_test # QTBUG-27740 diff --git a/tests/auto/quick/qquickpainteditem/qquickpainteditem.pro b/tests/auto/quick/qquickpainteditem/qquickpainteditem.pro index 1f03b0ed5d..381167cd09 100644 --- a/tests/auto/quick/qquickpainteditem/qquickpainteditem.pro +++ b/tests/auto/quick/qquickpainteditem/qquickpainteditem.pro @@ -6,5 +6,5 @@ SOURCES += tst_qquickpainteditem.cpp CONFIG += parallel_test -QT += core-private gui-private qml-private quick-private v8-private network testlib +QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickpath/qquickpath.pro b/tests/auto/quick/qquickpath/qquickpath.pro index f91c872ad9..4898f28c14 100644 --- a/tests/auto/quick/qquickpath/qquickpath.pro +++ b/tests/auto/quick/qquickpath/qquickpath.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro index fb02caebdc..e6cf9a488f 100644 --- a/tests/auto/quick/qquickpathview/qquickpathview.pro +++ b/tests/auto/quick/qquickpathview/qquickpathview.pro @@ -9,6 +9,6 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib qtHaveModule(widgets): QT += widgets DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro index c625080d7c..f6a046e622 100644 --- a/tests/auto/quick/qquickpositioners/qquickpositioners.pro +++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro @@ -9,6 +9,5 @@ macx:CONFIG -= app_bundle TESTDATA = data/* -CONFIG += parallel_test QT += testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro index 5e3872de83..4694172ac4 100644 --- a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro +++ b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro index 1254c3b4d7..2f0395d3ea 100644 --- a/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro +++ b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro @@ -10,5 +10,5 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickstates/qquickstates.pro b/tests/auto/quick/qquickstates/qquickstates.pro index 753d8d42d4..1b638dfa67 100644 --- a/tests/auto/quick/qquickstates/qquickstates.pro +++ b/tests/auto/quick/qquickstates/qquickstates.pro @@ -9,5 +9,5 @@ include (../../shared/util.pri) TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro index 4e3844bc58..c25a27b745 100644 --- a/tests/auto/quick/qquicktext/qquicktext.pro +++ b/tests/auto/quick/qquicktext/qquicktext.pro @@ -12,7 +12,7 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private network testlib +QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 mac:CONFIG += insignificant_test # QTBUG-27740 diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index 51a5b2547f..6b93791545 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -110,8 +110,8 @@ private slots: void letterSpacing(); void wordSpacing(); - void clickLink_data(); - void clickLink(); + void linkInteraction_data(); + void linkInteraction(); void implicitSize_data(); void implicitSize(); @@ -1504,15 +1504,30 @@ void tst_qquicktext::wordSpacing() class EventSender : public QQuickItem { public: - void sendEvent(QMouseEvent *event) { - if (event->type() == QEvent::MouseButtonPress) - mousePressEvent(event); - else if (event->type() == QEvent::MouseButtonRelease) - mouseReleaseEvent(event); - else if (event->type() == QEvent::MouseMove) - mouseMoveEvent(event); - else + void sendEvent(QEvent *event) { + switch (event->type()) { + case QEvent::MouseButtonPress: + mousePressEvent(static_cast<QMouseEvent *>(event)); + break; + case QEvent::MouseButtonRelease: + mouseReleaseEvent(static_cast<QMouseEvent *>(event)); + break; + case QEvent::MouseMove: + mouseMoveEvent(static_cast<QMouseEvent *>(event)); + break; + case QEvent::HoverEnter: + hoverEnterEvent(static_cast<QHoverEvent *>(event)); + break; + case QEvent::HoverLeave: + hoverLeaveEvent(static_cast<QHoverEvent *>(event)); + break; + case QEvent::HoverMove: + hoverMoveEvent(static_cast<QHoverEvent *>(event)); + break; + default: qWarning() << "Trying to send unsupported event type"; + break; + } } }; @@ -1522,10 +1537,12 @@ class LinkTest : public QObject public: LinkTest() {} - QString link; + QString clickedLink; + QString hoveredLink; public slots: - void linkClicked(QString l) { link = l; } + void linkClicked(QString l) { clickedLink = l; } + void linkHovered(QString l) { hoveredLink = l; } }; class TextMetrics @@ -1611,13 +1628,15 @@ public: typedef QVector<QPointF> PointVector; Q_DECLARE_METATYPE(PointVector); -void tst_qquicktext::clickLink_data() +void tst_qquicktext::linkInteraction_data() { QTest::addColumn<QString>("text"); QTest::addColumn<qreal>("width"); QTest::addColumn<QString>("bindings"); QTest::addColumn<PointVector>("mousePositions"); - QTest::addColumn<QString>("link"); + QTest::addColumn<QString>("clickedLink"); + QTest::addColumn<QString>("hoverEnterLink"); + QTest::addColumn<QString>("hoverMoveLink"); const QString singleLineText = "this text has a <a href=\\\"http://qt-project.org/single\\\">link</a> in it"; const QString singleLineLink = "http://qt-project.org/single"; @@ -1634,196 +1653,229 @@ void tst_qquicktext::clickLink_data() << singleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(18).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on text") << singleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(13).center()) - << QString(); + << QString() + << QString() << QString(); QTest::newRow("drag within link") << singleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(17).center() << metrics.characterRectangle(19).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("drag away from link") << singleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(18).center() << metrics.characterRectangle(13).center()) - << QString(); + << QString() + << singleLineLink << QString(); QTest::newRow("drag on to link") << singleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(13).center() << metrics.characterRectangle(18).center()) - << QString(); + << QString() + << QString() << singleLineLink; QTest::newRow("click on bottom right aligned link") << singleLineText << 240. << "horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignBottom" << (PointVector() << metrics.characterRectangle(18, Qt::AlignRight, Qt::AlignBottom).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on center aligned link") << singleLineText << 240. << "horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter" << (PointVector() << metrics.characterRectangle(18, Qt::AlignHCenter, Qt::AlignVCenter).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on rich text link") << singleLineText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(18).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on rich text") << singleLineText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(13).center()) - << QString(); + << QString() + << QString() << QString(); QTest::newRow("click on bottom right aligned rich text link") << singleLineText << 240. << "textFormat: Text.RichText; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignBottom" << (PointVector() << metrics.characterRectangle(18, Qt::AlignRight, Qt::AlignBottom).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; QTest::newRow("click on center aligned rich text link") << singleLineText << 240. << "textFormat: Text.RichText; horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter" << (PointVector() << metrics.characterRectangle(18, Qt::AlignHCenter, Qt::AlignVCenter).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; } { const TextMetrics metrics("this text has a li", Qt::ElideRight); QTest::newRow("click on right elided link") << singleLineText << metrics.width() + 2 << "elide: Text.ElideRight" << (PointVector() << metrics.characterRectangle(17).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; } { const TextMetrics metrics("ink in it", Qt::ElideLeft); QTest::newRow("click on left elided link") << singleLineText << metrics.width() + 2 << "elide: Text.ElideLeft" << (PointVector() << metrics.characterRectangle(2).center()) - << singleLineLink; + << singleLineLink + << singleLineLink << singleLineLink; } { const TextMetrics metrics("this text\nhas multiple\nlines in it"); QTest::newRow("click on second line") << multipleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(18).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; QTest::newRow("click on third line") << multipleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(25).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; QTest::newRow("drag from second line to third") << multipleLineText << 240. << "" << (PointVector() << metrics.characterRectangle(18).center() << metrics.characterRectangle(25).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; QTest::newRow("click on rich text second line") << multipleLineText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(18).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; QTest::newRow("click on rich text third line") << multipleLineText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(25).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; QTest::newRow("drag rich text from second line to third") << multipleLineText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(18).center() << metrics.characterRectangle(25).center()) - << multipleLineLink; + << multipleLineLink + << multipleLineLink << multipleLineLink; } { const TextMetrics metrics("this text has a nested link in it"); QTest::newRow("click on left outer link") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(22).center()) - << outerLink; + << outerLink + << outerLink << outerLink; QTest::newRow("click on right outer link") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(27).center()) - << outerLink; + << outerLink + << outerLink << outerLink; QTest::newRow("click on inner link left") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(23).center()) - << innerLink; + << innerLink + << innerLink << innerLink; QTest::newRow("click on inner link right") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(26).center()) - << innerLink; + << innerLink + << innerLink << innerLink; QTest::newRow("drag from inner to outer link") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(25).center() << metrics.characterRectangle(30).center()) - << QString(); + << QString() + << innerLink << outerLink; QTest::newRow("drag from outer to inner link") << nestedText << 240. << "" << (PointVector() << metrics.characterRectangle(30).center() << metrics.characterRectangle(25).center()) - << QString(); + << QString() + << outerLink << innerLink; QTest::newRow("click on left outer rich text link") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(22).center()) - << outerLink; + << outerLink + << outerLink << outerLink; QTest::newRow("click on right outer rich text link") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(27).center()) - << outerLink; + << outerLink + << outerLink << outerLink; QTest::newRow("click on inner rich text link left") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(23).center()) - << innerLink; + << innerLink + << innerLink << innerLink; QTest::newRow("click on inner rich text link right") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(26).center()) - << innerLink; + << innerLink + << innerLink << innerLink; QTest::newRow("drag from inner to outer rich text link") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(25).center() << metrics.characterRectangle(30).center()) - << QString(); + << QString() + << innerLink << outerLink; QTest::newRow("drag from outer to inner rich text link") << nestedText << 240. << "textFormat: Text.RichText" << (PointVector() << metrics.characterRectangle(30).center() << metrics.characterRectangle(25).center()) - << QString(); + << QString() + << outerLink << innerLink; } } -void tst_qquicktext::clickLink() +void tst_qquicktext::linkInteraction() { QFETCH(QString, text); QFETCH(qreal, width); QFETCH(QString, bindings); QFETCH(PointVector, mousePositions); - QFETCH(QString, link); + QFETCH(QString, clickedLink); + QFETCH(QString, hoverEnterLink); + QFETCH(QString, hoverMoveLink); QString componentStr = - "import QtQuick 2.0\nText {\n" + "import QtQuick 2.2\nText {\n" "width: " + QString::number(width) + "\n" "height: 320\n" "text: \"" + text + "\"\n" @@ -1837,28 +1889,46 @@ void tst_qquicktext::clickLink() LinkTest test; QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString))); + QObject::connect(textObject, SIGNAL(linkHovered(QString)), &test, SLOT(linkHovered(QString))); QVERIFY(mousePositions.count() > 0); QPointF mousePosition = mousePositions.first(); { + QHoverEvent he(QEvent::HoverEnter, mousePosition, QPointF()); + static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&he); + QMouseEvent me(QEvent::MouseButtonPress, mousePosition, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me); } + QCOMPARE(test.hoveredLink, hoverEnterLink); + QCOMPARE(textObject->hoveredLink(), hoverEnterLink); + for (int i = 1; i < mousePositions.count(); ++i) { mousePosition = mousePositions.at(i); + QHoverEvent he(QEvent::HoverMove, mousePosition, QPointF()); + static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&he); + QMouseEvent me(QEvent::MouseMove, mousePosition, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me); } + QCOMPARE(test.hoveredLink, hoverMoveLink); + QCOMPARE(textObject->hoveredLink(), hoverMoveLink); + { + QHoverEvent he(QEvent::HoverLeave, mousePosition, QPointF()); + static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&he); + QMouseEvent me(QEvent::MouseButtonRelease, mousePosition, Qt::LeftButton, Qt::NoButton, Qt::NoModifier); static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me); } - QCOMPARE(test.link, link); + QCOMPARE(test.clickedLink, clickedLink); + QCOMPARE(test.hoveredLink, QString()); + QCOMPARE(textObject->hoveredLink(), QString()); delete textObject; } diff --git a/tests/auto/quick/qquicktextedit/data/linkActivated.qml b/tests/auto/quick/qquicktextedit/data/linkInteraction.qml index d3bba82b59..d3bba82b59 100644 --- a/tests/auto/quick/qquicktextedit/data/linkActivated.qml +++ b/tests/auto/quick/qquicktextedit/data/linkInteraction.qml diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro index 1a247c5aa1..2386d713a7 100644 --- a/tests/auto/quick/qquicktextedit/qquicktextedit.pro +++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro @@ -11,7 +11,7 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private network-private testlib +QT += core-private gui-private qml-private quick-private network-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index a5cf91603b..ff9554718b 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -64,6 +64,7 @@ #include "../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> #include <QtGui/qstylehints.h> +#include <qmath.h> #ifdef Q_OS_MAC #include <Carbon/Carbon.h> @@ -143,7 +144,7 @@ private slots: void positionAt_data(); void positionAt(); - void linkActivated(); + void linkInteraction(); void cursorDelegate_data(); void cursorDelegate(); @@ -182,6 +183,8 @@ private slots: void getText(); void getFormattedText_data(); void getFormattedText(); + void append_data(); + void append(); void insert_data(); void insert(); void remove_data(); @@ -2365,9 +2368,9 @@ void tst_qquicktextedit::positionAt() QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0); } -void tst_qquicktextedit::linkActivated() +void tst_qquicktextedit::linkInteraction() { - QQuickView window(testFileUrl("linkActivated.qml")); + QQuickView window(testFileUrl("linkInteraction.qml")); QVERIFY(window.rootObject() != 0); window.show(); window.requestActivate(); @@ -2377,6 +2380,7 @@ void tst_qquicktextedit::linkActivated() QVERIFY(texteditObject != 0); QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString))); + QSignalSpy hover(texteditObject, SIGNAL(linkHovered(QString))); const QString link("http://example.com/"); @@ -2385,21 +2389,31 @@ void tst_qquicktextedit::linkActivated() QTest::mouseClick(&window, Qt::LeftButton, 0, linkPos.toPoint()); QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(hover.count(), 1); QCOMPARE(spy.last()[0].toString(), link); + QCOMPARE(hover.last()[0].toString(), link); + QCOMPARE(texteditObject->hoveredLink(), link); QTest::mouseClick(&window, Qt::LeftButton, 0, textPos.toPoint()); - QTest::qWait(50); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(hover.count(), 2); + QCOMPARE(hover.last()[0].toString(), QString()); + QCOMPARE(texteditObject->hoveredLink(), QString()); texteditObject->setReadOnly(true); QTest::mouseClick(&window, Qt::LeftButton, 0, linkPos.toPoint()); QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(hover.count(), 3); QCOMPARE(spy.last()[0].toString(), link); + QCOMPARE(hover.last()[0].toString(), link); + QCOMPARE(texteditObject->hoveredLink(), link); QTest::mouseClick(&window, Qt::LeftButton, 0, textPos.toPoint()); - QTest::qWait(50); - QCOMPARE(spy.count(), 2); + QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(hover.count(), 4); + QCOMPARE(hover.last()[0].toString(), QString()); + QCOMPARE(texteditObject->hoveredLink(), QString()); } void tst_qquicktextedit::cursorDelegate_data() @@ -3836,6 +3850,158 @@ void tst_qquicktextedit::getFormattedText() } } +void tst_qquicktextedit::append_data() +{ + QTest::addColumn<QString>("text"); + QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat"); + QTest::addColumn<int>("selectionStart"); + QTest::addColumn<int>("selectionEnd"); + QTest::addColumn<QString>("appendText"); + QTest::addColumn<QString>("expectedText"); + QTest::addColumn<int>("expectedSelectionStart"); + QTest::addColumn<int>("expectedSelectionEnd"); + QTest::addColumn<int>("expectedCursorPosition"); + QTest::addColumn<bool>("selectionChanged"); + QTest::addColumn<bool>("cursorPositionChanged"); + + QTest::newRow("cursor kept intact (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("cursor kept intact (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 18 << 18 << 18 + << false << false; + + QTest::newRow("cursor follows (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("\nHello") + << standard.at(0).length() + 6 << standard.at(0).length() + 6 << standard.at(0).length() + 6 + << false << true; + + QTest::newRow("selection kept intact (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 18 + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 0 << 18 << 18 + << false << false; + + QTest::newRow("selection kept intact (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 18 + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 14 << 18 << 18 + << false << false; + + QTest::newRow("selection kept intact, cursor follows (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 18 << standard.at(0).length() + 6 << standard.at(0).length() + 6 + << false << true; + + QTest::newRow("reversed selection kept intact") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 14 + << QString("Hello") + << standard.at(0) + QString("\nHello") + << 14 << 18 << 14 + << false << false; + + QTest::newRow("rich text into plain text") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << QString("<b>Hello</b>") + << standard.at(0) + QString("\n<b>Hello</b>") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("rich text into rich text") + << standard.at(0) << QQuickTextEdit::RichText + << 0 << 0 + << QString("<b>Hello</b>") + << standard.at(0) + QChar(QChar::ParagraphSeparator) + QString("Hello") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("rich text into auto text") + << standard.at(0) << QQuickTextEdit::AutoText + << 0 << 0 + << QString("<b>Hello</b>") + << standard.at(0) + QString("\nHello") + << 0 << 0 << 0 + << false << false; +} + +void tst_qquicktextedit::append() +{ + QFETCH(QString, text); + QFETCH(QQuickTextEdit::TextFormat, textFormat); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(QString, appendText); + QFETCH(QString, expectedText); + QFETCH(int, expectedSelectionStart); + QFETCH(int, expectedSelectionEnd); + QFETCH(int, expectedCursorPosition); + QFETCH(bool, selectionChanged); + QFETCH(bool, cursorPositionChanged); + + QString componentStr = "import QtQuick 2.2\nTextEdit { text: \"" + text + "\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create()); + QVERIFY(textEdit != 0); + + textEdit->setTextFormat(textFormat); + textEdit->select(selectionStart, selectionEnd); + + QSignalSpy selectionSpy(textEdit, SIGNAL(selectedTextChanged())); + QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); + QSignalSpy textSpy(textEdit, SIGNAL(textChanged())); + QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged())); + + textEdit->append(appendText); + + if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && ( + Qt::mightBeRichText(text) || Qt::mightBeRichText(appendText)))) { + QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText); + } else { + QCOMPARE(textEdit->text(), expectedText); + + } + QCOMPARE(textEdit->length(), expectedText.length()); + + QCOMPARE(textEdit->selectionStart(), expectedSelectionStart); + QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd); + QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition); + + if (selectionStart > selectionEnd) + qSwap(selectionStart, selectionEnd); + + QEXPECT_FAIL("into selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue); + QEXPECT_FAIL("into reversed selection", "selectedTextChanged signal isn't emitted on edits within selection", Continue); + QCOMPARE(selectionSpy.count() > 0, selectionChanged); + QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); + QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue); + QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); + QCOMPARE(textSpy.count() > 0, text != expectedText); + QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged); +} + void tst_qquicktextedit::insert_data() { QTest::addColumn<QString>("text"); diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro index 3240d99e90..c14b09c545 100644 --- a/tests/auto/quick/qquicktextinput/qquicktextinput.pro +++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro @@ -11,6 +11,6 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 06b757d198..1c2ab4d948 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -55,6 +55,7 @@ #include <QDebug> #include <QDir> #include <math.h> +#include <qmath.h> #ifdef Q_OS_MAC #include <Carbon/Carbon.h> @@ -5690,7 +5691,7 @@ void tst_qquicktextinput::QTBUG_19956_regexp() { QUrl url = testFileUrl("qtbug-19956regexp.qml"); - QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp"; + QString warning = url.toString() + ":11:17: Unable to assign [undefined] to QRegExp"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); QQuickView window(url); diff --git a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro index 60ae065910..d9aff688ab 100644 --- a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro +++ b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro @@ -9,8 +9,6 @@ include (../shared/util.pri) TESTDATA = data/* -CONFIG += parallel_test - -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib qtHaveModule(widgets): QT += widgets DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickwindow/qquickwindow.pro b/tests/auto/quick/qquickwindow/qquickwindow.pro index 917e3a5196..46cf96423f 100644 --- a/tests/auto/quick/qquickwindow/qquickwindow.pro +++ b/tests/auto/quick/qquickwindow/qquickwindow.pro @@ -6,7 +6,7 @@ include (../../shared/util.pri) macx:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib TESTDATA = data/* diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.qml b/tests/auto/quick/qquickxmllistmodel/data/groups.qml new file mode 100644 index 0000000000..c1b574a822 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/groups.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "groups.xml" + query: "//animal[@name='Garfield']/parent::group" + + XmlRole { name: "id"; query: "@id/string()" } + XmlRole { name: "name"; query: "@name/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/groups.xml b/tests/auto/quick/qquickxmllistmodel/data/groups.xml new file mode 100644 index 0000000000..5de4d2ec71 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/groups.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<groups version="2.0"> + <group id="1" name="Animals" type="root"> + <group id="11" name="dogs"> + <animal id="111" name="Lassie"/> + <animal id="112" name="Laika"/> + <animal id="113" name="Wile E. Coyote" type="fictional"/> + </group> + <group id="12" name="cats"> + <animal id="121" name="Garfield" type="fictional"/> + <animal id="122" name="Sylvester" type="fictional"/> + </group> + <group id="13" name="birds"> + <animal id="131" name="Donald Duck" type="fictional"/> + <animal id="132" name="Phoenix" type="fictional"/> + </group> + </group> +</groups> diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro index 047d8ca560..574481c456 100644 --- a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro +++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro @@ -10,5 +10,8 @@ TESTDATA = data/* CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private network testlib xmlpatterns +QT += core-private gui-private qml-private network testlib xmlpatterns DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +OTHER_FILES += \ + data/groups.qml diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp index 847cc5078d..1f7a8029dc 100644 --- a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp +++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -101,6 +101,7 @@ private slots: void threading(); void threading_data(); void propertyChanges(); + void selectAncestor(); void roleCrash(); @@ -964,6 +965,18 @@ void tst_qquickxmllistmodel::propertyChanges() delete model; } +void tst_qquickxmllistmodel::selectAncestor() +{ + QQmlComponent component(&engine, testFileUrl("groups.qml")); + QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->rowCount(), 1); + + QModelIndex index = model->index(0, 0); + QCOMPARE(model->data(index, Qt::UserRole).toInt(), 12); + QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("cats")); +} + void tst_qquickxmllistmodel::roleCrash() { // don't crash diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro index 1e2c50a6d1..b195b97dcf 100644 --- a/tests/auto/quick/rendernode/rendernode.pro +++ b/tests/auto/quick/rendernode/rendernode.pro @@ -9,7 +9,7 @@ TESTDATA = data/* include(../../shared/util.pri) CONFIG += parallel_test -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib OTHER_FILES += \ data/RenderOrder.qml \ diff --git a/tests/auto/quick/shared/util.pri b/tests/auto/quick/shared/util.pri index 28036f109c..bd2d202f1d 100644 --- a/tests/auto/quick/shared/util.pri +++ b/tests/auto/quick/shared/util.pri @@ -1,5 +1,5 @@ -QT += core-private gui-private v8-private qml-private quick-private +QT += core-private gui-private qml-private quick-private HEADERS += $$PWD/visualtestutil.h \ $$PWD/viewtestutil.h diff --git a/tests/auto/quick/touchmouse/touchmouse.pro b/tests/auto/quick/touchmouse/touchmouse.pro index af6d536cbc..445bee08ae 100644 --- a/tests/auto/quick/touchmouse/touchmouse.pro +++ b/tests/auto/quick/touchmouse/touchmouse.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_touchmouse -QT += core-private gui-private qml-private quick-private v8-private testlib +QT += core-private gui-private qml-private quick-private testlib macx:CONFIG -= app_bundle diff --git a/tests/auto/shared/testhttpserver.cpp b/tests/auto/shared/testhttpserver.cpp index 205d5cec5d..fd681710de 100644 --- a/tests/auto/shared/testhttpserver.cpp +++ b/tests/auto/shared/testhttpserver.cpp @@ -137,7 +137,19 @@ bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &bod bodyData = bodyFile.readAll(); } - waitData = expectFile.readAll(); + QByteArray line; + bool headers_done = false; + while (!(line = expectFile.readLine()).isEmpty()) { + line.replace('\r', ""); + if (line.at(0) == '\n') { + headers_done = true; + continue; + } + if (headers_done) + waitData.body.append(line); + else + waitData.headers.append(line); + } /* while (waitData.endsWith('\n')) waitData = waitData.left(waitData.count() - 1); @@ -199,39 +211,38 @@ void TestHTTPServer::readyRead() QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender()); if (!socket || socket->state() == QTcpSocket::ClosingState) return; - QByteArray ba = socket->readAll(); - if (!dirs.isEmpty()) { - serveGET(socket, ba); + serveGET(socket, socket->readAll()); return; } - if (m_hasFailed || waitData.isEmpty()) { - qWarning() << "TestHTTPServer: Unexpected data" << ba; + if (m_hasFailed || (waitData.body.isEmpty() && waitData.headers.count() == 0)) { + qWarning() << "TestHTTPServer: Unexpected data" << socket->readAll(); return; } - for (int ii = 0; ii < ba.count(); ++ii) { - const char c = ba.at(ii); - if (c == '\r' && waitData.isEmpty()) - continue; - else if (!waitData.isEmpty() && c == waitData.at(0)) - waitData = waitData.mid(1); - else if (c == '\r') - continue; - else { - QByteArray data = ba.mid(ii); - qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData; + QByteArray line; + while (!(line = socket->readLine()).isEmpty()) { + line.replace('\r', ""); + if (line.at(0) == '\n') { + QByteArray data = socket->readAll(); + if (waitData.body != data) { + qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData.body; + m_hasFailed = true; + socket->disconnectFromHost(); + return; + } + } + else if (!waitData.headers.contains(line)) { + qWarning() << "TestHTTPServer: Unexpected header:" << line << "\nExpected headers: " << waitData.headers; m_hasFailed = true; socket->disconnectFromHost(); return; } } - if (waitData.isEmpty()) { - socket->write(replyData); - socket->disconnectFromHost(); - } + socket->write(replyData); + socket->disconnectFromHost(); } bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName) diff --git a/tests/auto/shared/testhttpserver.h b/tests/auto/shared/testhttpserver.h index 15e08afd0c..ce0501f170 100644 --- a/tests/auto/shared/testhttpserver.h +++ b/tests/auto/shared/testhttpserver.h @@ -81,7 +81,10 @@ private: QHash<QTcpSocket *, QByteArray> dataCache; QList<QPair<QTcpSocket *, QByteArray> > toSend; - QByteArray waitData; + struct WaitData { + QList <QByteArray>headers; + QByteArray body; + } waitData; QByteArray replyData; QByteArray bodyData; bool m_hasFailed; diff --git a/tests/benchmarks/particles/affectors/affectors.pro b/tests/benchmarks/particles/affectors/affectors.pro index 687422c7ec..51d65d7243 100644 --- a/tests/benchmarks/particles/affectors/affectors.pro +++ b/tests/benchmarks/particles/affectors/affectors.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib +QT += core-private gui-private qml-private quick-private opengl-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/particles/emission/emission.pro b/tests/benchmarks/particles/emission/emission.pro index 7ffded64b3..f4445f7d8a 100644 --- a/tests/benchmarks/particles/emission/emission.pro +++ b/tests/benchmarks/particles/emission/emission.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib +QT += core-private gui-private qml-private quick-private opengl-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/qml/animation/animation.pro b/tests/benchmarks/qml/animation/animation.pro index 7490c5fe39..e089884a7e 100644 --- a/tests/benchmarks/qml/animation/animation.pro +++ b/tests/benchmarks/qml/animation/animation.pro @@ -1,11 +1,10 @@ +CONFIG += testcase TEMPLATE = app TARGET = tst_animation -QT += qml +QT += qml testlib core-private gui-private qml-private quick-private macx:CONFIG -= app_bundle SOURCES += tst_animation.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += testlib core-private gui-private qml-private quick-private v8-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/qml/compilation/compilation.pro b/tests/benchmarks/qml/compilation/compilation.pro index 63c3da694f..a55864f696 100644 --- a/tests/benchmarks/qml/compilation/compilation.pro +++ b/tests/benchmarks/qml/compilation/compilation.pro @@ -1,7 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_compilation -QT += qml qml-private testlib core-private v8-private +QT += qml qml-private testlib core-private macx:CONFIG -= app_bundle CONFIG += release diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 148396622b..eac3dcc2dd 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -120,7 +120,6 @@ void tst_compilation::jsparser() QBENCHMARK { QQmlJS::Engine engine; - QQmlJS::NodePool nodePool(file, &engine); QQmlJS::Lexer lexer(&engine); lexer.setCode(code, -1); @@ -146,11 +145,14 @@ void tst_compilation::scriptparser() QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); + //TODO(pvarga): check preparseData + QByteArray preparseData; QUrl url = QUrl::fromLocalFile(file); + QString urlString = url.toString(); QBENCHMARK { QQmlScript::Parser parser; - parser.parse(data, url); + parser.parse(data, preparseData, url, urlString); parser.tree(); } } diff --git a/tests/benchmarks/qml/creation/creation.pro b/tests/benchmarks/qml/creation/creation.pro index 8d26ef88df..0cfac64d5f 100644 --- a/tests/benchmarks/qml/creation/creation.pro +++ b/tests/benchmarks/qml/creation/creation.pro @@ -1,11 +1,10 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_creation +QT += core-private gui-private qml-private quick-private widgets testlib macx:CONFIG -= app_bundle SOURCES += tst_creation.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private qml-private qtquick1-private widgets testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 4b5c1d1950..b6b402a6c0 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -48,7 +48,6 @@ #include <QGraphicsItem> #include <QQuickItem> #include <QQmlContext> -#include <QtQuick1/private/qdeclarativetextinput_p.h> #include <private/qobject_p.h> class tst_creation : public QObject @@ -96,7 +95,7 @@ public: : QObject(parent) {} QQmlListProperty<QObject> resources() { - return QQmlListProperty<QObject>(this, 0, resources_append); + return QQmlListProperty<QObject>(this, 0, resources_append, 0, 0, 0); } static void resources_append(QQmlListProperty<QObject> *p, QObject *o) { @@ -107,9 +106,6 @@ public: tst_creation::tst_creation() { qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType"); - - //get rid of initialization effects - QDeclarative1TextInput te; } inline QUrl TEST_FILE(const QString &filename) @@ -321,9 +317,7 @@ void tst_creation::itemtree_qml() void tst_creation::itemtree_scene_cpp() { - QGraphicsScene scene; QQuickItem *root = new QQuickItem; - scene.addItem(root); QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { diff --git a/tests/benchmarks/qml/holistic/testtypes.cpp b/tests/benchmarks/qml/holistic/testtypes.cpp index 0a9e36dc3a..9b1bb86850 100644 --- a/tests/benchmarks/qml/holistic/testtypes.cpp +++ b/tests/benchmarks/qml/holistic/testtypes.cpp @@ -82,13 +82,13 @@ void registerTypes() qmlRegisterType<ScarceResourceProvider>("Qt.test", 1,0, "MyScarceResourceProvider"); qmlRegisterType<ArbitraryVariantProvider>("Qt.test", 1,0, "MyArbitraryVariantProvider"); - qmlRegisterSingletonType("Qt.test",1,0,script_api); // register (script) singleton Type for an existing uri which contains elements - qmlRegisterSingletonType<testQObjectApi>("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another singleton Type was previously regd. Should replace! - qmlRegisterSingletonType("Qt.test.scriptApi",1,0,script_api); // register (script) singleton Type for a uri which doesn't contain elements - qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements - qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, minor version set - qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, major version set - qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) singleton Type for a uri which doesn't contain elements + qmlRegisterSingletonType("Qt.test",1,0,"Script",script_api); // register (script) singleton Type for an existing uri which contains elements + qmlRegisterSingletonType<testQObjectApi>("Qt.test",1,0,"QObject",qobject_api); // register (qobject) for an existing uri for which another singleton Type was previously regd. Should replace! + qmlRegisterSingletonType("Qt.test.scriptApi",1,0,"Script",script_api); // register (script) singleton Type for a uri which doesn't contain elements + qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,0,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements + qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",1,3,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, minor version set + qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApi",2,0,"QObject",qobject_api); // register (qobject) singleton Type for a uri which doesn't contain elements, major version set + qmlRegisterSingletonType<testQObjectApi>("Qt.test.qobjectApiParented",1,0,"QObject",qobject_api_engine_parent); // register (parented qobject) singleton Type for a uri which doesn't contain elements } //#include "testtypes.moc" diff --git a/tests/benchmarks/qml/painting/paintbenchmark.cpp b/tests/benchmarks/qml/painting/paintbenchmark.cpp index b99161749d..1fc7813c04 100644 --- a/tests/benchmarks/qml/painting/paintbenchmark.cpp +++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp @@ -180,6 +180,8 @@ void paint_RoundedRect(QPainter &p) } } +// Disable this test case since this cannot be compiled with Qt5. +#if 0 void paint_QPixmapCachedRoundedRect(QPainter &p) { static bool first = true; @@ -218,6 +220,7 @@ void paint_QPixmapCachedRoundedRect(QPainter &p) } } } +#endif void paint_pathCacheRoundedRect(QPainter &p) { @@ -312,7 +315,7 @@ struct { { "QStaticTextWithBackendOptimizations", &paint_QStaticText_optimizations }, { "CachedText", &paint_QPixmapCachedText }, { "RoundedRect", &paint_RoundedRect }, - { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, + // { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, { "PathCacheRoundedRect", &paint_pathCacheRoundedRect }, { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, diff --git a/tests/benchmarks/qml/pointers/pointers.pro b/tests/benchmarks/qml/pointers/pointers.pro index 1db474428d..ccf85d659a 100644 --- a/tests/benchmarks/qml/pointers/pointers.pro +++ b/tests/benchmarks/qml/pointers/pointers.pro @@ -1,5 +1,5 @@ CONFIG += testcase -QT += qml testlib +QT += core-private qml-private testlib TEMPLATE = app TARGET = tst_pointers macx:CONFIG -= app_bundle diff --git a/tests/benchmarks/qml/pointers/tst_pointers.cpp b/tests/benchmarks/qml/pointers/tst_pointers.cpp index 65dda28fe7..0c25030c7f 100644 --- a/tests/benchmarks/qml/pointers/tst_pointers.cpp +++ b/tests/benchmarks/qml/pointers/tst_pointers.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <qtest.h> -#include "private/qqmlguard_p.h" +#include <QtQml/private/qqmlguard_p.h> #include <QWeakPointer> class tst_pointers : public QObject diff --git a/tests/benchmarks/qml/qquickwindow/qquickwindow.pro b/tests/benchmarks/qml/qquickwindow/qquickwindow.pro index 76aecf9d13..0676405e23 100644 --- a/tests/benchmarks/qml/qquickwindow/qquickwindow.pro +++ b/tests/benchmarks/qml/qquickwindow/qquickwindow.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib +QT += core-private gui-private qml-private quick-private opengl-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
\ No newline at end of file diff --git a/tests/benchmarks/qml/qquickwindow/tst_qquickwindow.cpp b/tests/benchmarks/qml/qquickwindow/tst_qquickwindow.cpp index 01ddd70838..20e5fb6c64 100644 --- a/tests/benchmarks/qml/qquickwindow/tst_qquickwindow.cpp +++ b/tests/benchmarks/qml/qquickwindow/tst_qquickwindow.cpp @@ -63,9 +63,9 @@ tst_qquickwindow::tst_qquickwindow() { window = new QQuickWindow; window->resize(250, 250); - window->setPos(100, 100); + window->setPosition(100, 100); for ( int i=0; i<8000; i++ ) { - QQuickRectangle *r =new QQuickRectangle(window->rootItem()); + QQuickRectangle *r =new QQuickRectangle(window->contentItem()); for ( int j=0; j<10; ++j ) { new QQuickRectangle(r); } diff --git a/tests/benchmarks/qml/script/script.pro b/tests/benchmarks/qml/script/script.pro index 7beb3f81c1..51a02e796d 100644 --- a/tests/benchmarks/qml/script/script.pro +++ b/tests/benchmarks/qml/script/script.pro @@ -6,7 +6,7 @@ CONFIG += release SOURCES += tst_script.cpp -QT += core-private gui-private v8-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/qml/typeimports/tst_typeimports.cpp b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp index c24e344a6b..5871565ace 100644 --- a/tests/benchmarks/qml/typeimports/tst_typeimports.cpp +++ b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp @@ -67,7 +67,7 @@ public: TestType1(QObject *parent = 0) : QObject(parent) {} QQmlListProperty<QObject> resources() { - return QQmlListProperty<QObject>(this, 0, resources_append); + return QQmlListProperty<QObject>(this, 0, resources_append, 0, 0, 0); } static void resources_append(QQmlListProperty<QObject> *p, QObject *o) { diff --git a/tests/benchmarks/script/qjsvalue/qjsvalue.pro b/tests/benchmarks/script/qjsvalue/qjsvalue.pro index 7aa864c12f..b0134b085a 100644 --- a/tests/benchmarks/script/qjsvalue/qjsvalue.pro +++ b/tests/benchmarks/script/qjsvalue/qjsvalue.pro @@ -7,5 +7,5 @@ CONFIG += release SOURCES += tst_qjsvalue.cpp -QT += core-private v8-private qml-private testlib +QT += core-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/manual/v4/TestExpectations b/tests/manual/v4/TestExpectations new file mode 100644 index 0000000000..8af484277f --- /dev/null +++ b/tests/manual/v4/TestExpectations @@ -0,0 +1,15 @@ +# wrong tests +# uses octal number +15.2.3.6-2-17-1 failing + + +10.4.3-1-104 failing +10.4.3-1-106 failing +11.2.3-3_3 failing +S11.8.6_A5_T2 failing +S13_A15_T4 failing +S13.2.3_A1 failing +S15.4.4.3_A1_T1 failing +S15.4.4.3_A3_T1 failing +S15.5.4.11_A5_T1 failing +S15.2.4.4_A14 failing diff --git a/tests/manual/v4/accessors.js b/tests/manual/v4/accessors.js new file mode 100644 index 0000000000..3874e4d329 --- /dev/null +++ b/tests/manual/v4/accessors.js @@ -0,0 +1,8 @@ +"use strict"; +var foo = { y: 1 } +foo.__defineSetter__("x", function(x) { this.y = x;} ) +foo.__defineGetter__("x", function() { return this.y;} ) +print(foo.y); +foo.x = "ok"; +print(foo.x); +print(foo.y); diff --git a/tests/manual/v4/array.1.js b/tests/manual/v4/array.1.js new file mode 100644 index 0000000000..015941c2dc --- /dev/null +++ b/tests/manual/v4/array.1.js @@ -0,0 +1,32 @@ + +var d1 = new Date() +a = [] + +for (var i = 0; i < 10000; i = i + 1) + a[i] = i + +for (var i = 0; i < 10000; i = i + 1) + if (a[i] != i) + print("KO", i) + +print("done in", new Date - d1) + +var s = "some cool stuff" +for (var i = 0; i < 15; i = i + 1) { + print(s[i]) +} + +var xx = [1,2] +xx[0] = 1 +print(xx.length) +print(xx) + +print("yy", xx.concat(xx)) +var pp = [1,2,3,4] +var aa = pp.concat([5,6,7]); +print(aa[0], aa[1], aa[2], aa[3], aa[4], aa[5], aa.length) +print(Array.prototype.concat("hello", true, 123, null, "world")) +aa.pop() +print(aa) +aa.pop() +print(aa) diff --git a/tests/manual/v4/auto/auto.pro b/tests/manual/v4/auto/auto.pro new file mode 100644 index 0000000000..3b189275b9 --- /dev/null +++ b/tests/manual/v4/auto/auto.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS=\ + executableallocator + diff --git a/tests/manual/v4/auto/executableallocator/executableallocator.pro b/tests/manual/v4/auto/executableallocator/executableallocator.pro new file mode 100644 index 0000000000..196398020d --- /dev/null +++ b/tests/manual/v4/auto/executableallocator/executableallocator.pro @@ -0,0 +1,4 @@ +TEMPLATE = app +TARGET = tst_executableallocator +SOURCES = tst_executableallocator.cpp +QT = core v4-private testlib diff --git a/tests/manual/v4/auto/executableallocator/tst_executableallocator.cpp b/tests/manual/v4/auto/executableallocator/tst_executableallocator.cpp new file mode 100644 index 0000000000..e7a604ddef --- /dev/null +++ b/tests/manual/v4/auto/executableallocator/tst_executableallocator.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest> +#include <QtCore> +#include <stdlib.h> +#include <assert.h> + +#include <private/qv4executableallocator.h> + +using namespace QQmlJS::VM; + +class tst_ExecutableAllocator : public QObject +{ + Q_OBJECT +private slots: + void singleAlloc(); + void mergeNext(); + void mergePrev(); + void multipleChunks(); +}; + +void tst_ExecutableAllocator::singleAlloc() +{ + ExecutableAllocator allocator; + ExecutableAllocator::Allocation *p = allocator.allocate(256); + QCOMPARE(allocator.freeAllocationCount(), 1); + QCOMPARE(allocator.chunkCount(), 1); + allocator.free(p); + QCOMPARE(allocator.freeAllocationCount(), 0); + QCOMPARE(allocator.chunkCount(), 0); +} + +void tst_ExecutableAllocator::mergeNext() +{ + ExecutableAllocator allocator; + + ExecutableAllocator::Allocation *first = allocator.allocate(10); + QCOMPARE(allocator.freeAllocationCount(), 1); + QCOMPARE(allocator.chunkCount(), 1); + + ExecutableAllocator::Allocation *second = allocator.allocate(10); + QCOMPARE(allocator.freeAllocationCount(), 1); + QCOMPARE(allocator.chunkCount(), 1); + + allocator.free(second); + QCOMPARE(allocator.freeAllocationCount(), 1); + QCOMPARE(allocator.chunkCount(), 1); + + allocator.free(first); + QCOMPARE(allocator.freeAllocationCount(), 0); + QCOMPARE(allocator.chunkCount(), 0); +} + +void tst_ExecutableAllocator::mergePrev() +{ + ExecutableAllocator allocator; + + ExecutableAllocator::Allocation *first = allocator.allocate(10); + QCOMPARE(allocator.freeAllocationCount(), 1); + + ExecutableAllocator::Allocation *second = allocator.allocate(10); + QCOMPARE(allocator.freeAllocationCount(), 1); + + ExecutableAllocator::Allocation *third = allocator.allocate(10); + QCOMPARE(allocator.freeAllocationCount(), 1); + + allocator.free(first); + QCOMPARE(allocator.freeAllocationCount(), 2); + + allocator.free(second); + QCOMPARE(allocator.freeAllocationCount(), 2); + + allocator.free(third); + QCOMPARE(allocator.freeAllocationCount(), 0); +} + +void tst_ExecutableAllocator::multipleChunks() +{ + ExecutableAllocator allocator; + + ExecutableAllocator::Allocation *first = allocator.allocate(10); + QCOMPARE(allocator.chunkCount(), 1); + + ExecutableAllocator::Allocation *second = allocator.allocate(8 * 1024 * 1024); + QCOMPARE(allocator.chunkCount(), 2); + + ExecutableAllocator::Allocation *third = allocator.allocate(1024); + QCOMPARE(allocator.chunkCount(), 2); + + allocator.free(first); + allocator.free(second); + allocator.free(third); + QCOMPARE(allocator.chunkCount(), 0); + QCOMPARE(allocator.freeAllocationCount(), 0); +} + +QTEST_MAIN(tst_ExecutableAllocator) +#include "tst_executableallocator.moc" diff --git a/tests/manual/v4/crypto.js b/tests/manual/v4/crypto.js new file mode 100644 index 0000000000..cd48bdb019 --- /dev/null +++ b/tests/manual/v4/crypto.js @@ -0,0 +1,1712 @@ +/* + * Copyright (c) 2003-2005 Tom Wu + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF + * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * In addition, the following condition applies: + * + * All redistributions must retain an intact copy of this copyright notice + * and disclaimer. + */ + + +// The code has been adapted for use as a benchmark by Google. +//var Crypto = new BenchmarkSuite('Crypto', 266181, [ +// new Benchmark("Encrypt", encrypt), +// new Benchmark("Decrypt", decrypt) +//]); + + +// Basic JavaScript BN library - subset useful for RSA encryption. + +// Bits per digit +var dbits; +var BI_DB; +var BI_DM; +var BI_DV; + +var BI_FP; +var BI_FV; +var BI_F1; +var BI_F2; + +// JavaScript engine analysis +var canary = 0xdeadbeefcafe; +var j_lm = ((canary&0xffffff)==0xefcafe); + +function parseInt(n,b) { + if (b == 16) return Number("0x" + String(n)) + return Number(n) +} + +// (public) Constructor +function BigInteger(a,b,c) { + this.array = new Array(); + if(a != null) + if("number" == typeof a) this.fromNumber(a,b,c); + else if(b == null && "string" != typeof a) this.fromString(a,256); + else this.fromString(a,b); +} + +// return new, unset BigInteger +function nbi() { return new BigInteger(null); } + +// am: Compute w_j += (x*this_i), propagate carries, +// c is initial carry, returns final carry. +// c < 3*dvalue, x < 2*dvalue, this_i < dvalue +// We need to select the fastest one that works in this environment. + +// am1: use a single mult and divide to get the high bits, +// max digit bits should be 26 because +// max internal value = 2*dvalue^2-2*dvalue (< 2^53) +function am1(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + while(--n >= 0) { + var v = x*this_array[i++]+w_array[j]+c; + c = Math.floor(v/0x4000000); + w_array[j++] = v&0x3ffffff; + } + return c; +} + +// am2 avoids a big mult-and-extract completely. +// Max digit bits should be <= 30 because we do bitwise ops +// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) +function am2(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + var xl = x&0x7fff, xh = x>>15; + while(--n >= 0) { + var l = this_array[i]&0x7fff; + var h = this_array[i++]>>15; + var m = xh*l+h*xl; + l = xl*l+((m&0x7fff)<<15)+w_array[j]+(c&0x3fffffff); + c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); + w_array[j++] = l&0x3fffffff; + } + return c; +} + +// Alternately, set max digit bits to 28 since some +// browsers slow down when dealing with 32-bit numbers. +function am3(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + + var xl = x&0x3fff, xh = x>>14; + while(--n >= 0) { + var l = this_array[i]&0x3fff; + var h = this_array[i++]>>14; + var m = xh*l+h*xl; + l = xl*l+((m&0x3fff)<<14)+w_array[j]+c; + c = (l>>28)+(m>>14)+xh*h; + w_array[j++] = l&0xfffffff; + } + return c; +} + +// This is tailored to VMs with 2-bit tagging. It makes sure +// that all the computations stay within the 29 bits available. +function am4(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + + var xl = x&0x1fff, xh = x>>13; + while(--n >= 0) { + var l = this_array[i]&0x1fff; + var h = this_array[i++]>>13; + var m = xh*l+h*xl; + l = xl*l+((m&0x1fff)<<13)+w_array[j]+c; + c = (l>>26)+(m>>13)+xh*h; + w_array[j++] = l&0x3ffffff; + } + return c; +} + +// am3/28 is best for SM, Rhino, but am4/26 is best for v8. +// Kestrel (Opera 9.5) gets its best result with am4/26. +// IE7 does 9% better with am3/28 than with am4/26. +// Firefox (SM) gets 10% faster with am3/28 than with am4/26. + +setupEngine = function(fn, bits) { + BigInteger.prototype.am = fn; + dbits = bits; + + BI_DB = dbits; + BI_DM = ((1<<dbits)-1); + BI_DV = (1<<dbits); + + BI_FP = 52; + BI_FV = Math.pow(2,BI_FP); + BI_F1 = BI_FP-dbits; + BI_F2 = 2*dbits-BI_FP; +} + + +// Digit conversions +var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"; +var BI_RC = new Array(); +var rr,vv; +rr = "0".charCodeAt(0); +for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv; +rr = "a".charCodeAt(0); +for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; +rr = "A".charCodeAt(0); +for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; + +function int2char(n) { return BI_RM.charAt(n); } +function intAt(s,i) { + var c = BI_RC[s.charCodeAt(i)]; + return (c==null)?-1:c; +} + +// (protected) copy this to r +function bnpCopyTo(r) { + var this_array = this.array; + var r_array = r.array; + + for(var i = this.t-1; i >= 0; --i) r_array[i] = this_array[i]; + r.t = this.t; + r.s = this.s; +} + +// (protected) set from integer value x, -DV <= x < DV +function bnpFromInt(x) { + var this_array = this.array; + this.t = 1; + this.s = (x<0)?-1:0; + if(x > 0) this_array[0] = x; + else if(x < -1) this_array[0] = x+DV; + else this.t = 0; +} + +// return bigint initialized to value +function nbv(i) { var r = nbi(); r.fromInt(i); return r; } + +// (protected) set from string and radix +function bnpFromString(s,b) { + var this_array = this.array; + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 256) k = 8; // byte array + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else { this.fromRadix(s,b); return; } + this.t = 0; + this.s = 0; + var i = s.length, mi = false, sh = 0; + while(--i >= 0) { + var x = (k==8)?s[i]&0xff:intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-") mi = true; + continue; + } + mi = false; + if(sh == 0) + this_array[this.t++] = x; + else if(sh+k > BI_DB) { + this_array[this.t-1] |= (x&((1<<(BI_DB-sh))-1))<<sh; + this_array[this.t++] = (x>>(BI_DB-sh)); + } + else + this_array[this.t-1] |= x<<sh; + sh += k; + if(sh >= BI_DB) sh -= BI_DB; + } + if(k == 8 && (s[0]&0x80) != 0) { + this.s = -1; + if(sh > 0) this_array[this.t-1] |= ((1<<(BI_DB-sh))-1)<<sh; + } + this.clamp(); + if(mi) BigInteger.ZERO.subTo(this,this); +} + +// (protected) clamp off excess high words +function bnpClamp() { + var this_array = this.array; + var c = this.s&BI_DM; + while(this.t > 0 && this_array[this.t-1] == c) --this.t; +} + +// (public) return string representation in given radix +function bnToString(b) { + var this_array = this.array; + if(this.s < 0) return "-"+this.negate().toString(b); + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else return this.toRadix(b); + var km = (1<<k)-1, d, m = false, r = "", i = this.t; + var p = BI_DB-(i*BI_DB)%k; + if(i-- > 0) { + if(p < BI_DB && (d = this_array[i]>>p) > 0) { m = true; r = int2char(d); } + while(i >= 0) { + if(p < k) { + d = (this_array[i]&((1<<p)-1))<<(k-p); + d |= this_array[--i]>>(p+=BI_DB-k); + } + else { + d = (this_array[i]>>(p-=k))&km; + if(p <= 0) { p += BI_DB; --i; } + } + if(d > 0) m = true; + if(m) r += int2char(d); + } + } + return m?r:"0"; +} + +// (public) -this +function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } + +// (public) |this| +function bnAbs() { return (this.s<0)?this.negate():this; } + +// (public) return + if this > a, - if this < a, 0 if equal +function bnCompareTo(a) { + var this_array = this.array; + var a_array = a.array; + + var r = this.s-a.s; + if(r != 0) return r; + var i = this.t; + r = i-a.t; + if(r != 0) return r; + while(--i >= 0) if((r=this_array[i]-a_array[i]) != 0) return r; + return 0; +} + +// returns bit length of the integer x +function nbits(x) { + var r = 1, t; + if((t=x>>>16) != 0) { x = t; r += 16; } + if((t=x>>8) != 0) { x = t; r += 8; } + if((t=x>>4) != 0) { x = t; r += 4; } + if((t=x>>2) != 0) { x = t; r += 2; } + if((t=x>>1) != 0) { x = t; r += 1; } + return r; +} + +// (public) return the number of bits in "this" +function bnBitLength() { + var this_array = this.array; + if(this.t <= 0) return 0; + return BI_DB*(this.t-1)+nbits(this_array[this.t-1]^(this.s&BI_DM)); +} + +// (protected) r = this << n*DB +function bnpDLShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + var i; + for(i = this.t-1; i >= 0; --i) r_array[i+n] = this_array[i]; + for(i = n-1; i >= 0; --i) r_array[i] = 0; + r.t = this.t+n; + r.s = this.s; +} + +// (protected) r = this >> n*DB +function bnpDRShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + for(var i = n; i < this.t; ++i) r_array[i-n] = this_array[i]; + r.t = Math.max(this.t-n,0); + r.s = this.s; +} + +// (protected) r = this << n +function bnpLShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + var bs = n%BI_DB; + var cbs = BI_DB-bs; + var bm = (1<<cbs)-1; + var ds = Math.floor(n/BI_DB), c = (this.s<<bs)&BI_DM, i; + for(i = this.t-1; i >= 0; --i) { + r_array[i+ds+1] = (this_array[i]>>cbs)|c; + c = (this_array[i]&bm)<<bs; + } + for(i = ds-1; i >= 0; --i) r_array[i] = 0; + r_array[ds] = c; + r.t = this.t+ds+1; + r.s = this.s; + r.clamp(); +} + +// (protected) r = this >> n +function bnpRShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + r.s = this.s; + var ds = Math.floor(n/BI_DB); + if(ds >= this.t) { r.t = 0; return; } + var bs = n%BI_DB; + var cbs = BI_DB-bs; + var bm = (1<<bs)-1; + r_array[0] = this_array[ds]>>bs; + for(var i = ds+1; i < this.t; ++i) { + r_array[i-ds-1] |= (this_array[i]&bm)<<cbs; + r_array[i-ds] = this_array[i]>>bs; + } + if(bs > 0) r_array[this.t-ds-1] |= (this.s&bm)<<cbs; + r.t = this.t-ds; + r.clamp(); +} + +// (protected) r = this - a +function bnpSubTo(a,r) { + var this_array = this.array; + var r_array = r.array; + var a_array = a.array; + var i = 0, c = 0, m = Math.min(a.t,this.t); + while(i < m) { + c += this_array[i]-a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + if(a.t < this.t) { + c -= a.s; + while(i < this.t) { + c += this_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c -= a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c -= a.s; + } + r.s = (c<0)?-1:0; + if(c < -1) r_array[i++] = BI_DV+c; + else if(c > 0) r_array[i++] = c; + r.t = i; + r.clamp(); +} + +// (protected) r = this * a, r != this,a (HAC 14.12) +// "this" should be the larger one if appropriate. +function bnpMultiplyTo(a,r) { + var this_array = this.array; + var r_array = r.array; + var x = this.abs(), y = a.abs(); + var y_array = y.array; + + var i = x.t; + r.t = i+y.t; + while(--i >= 0) r_array[i] = 0; + for(i = 0; i < y.t; ++i) r_array[i+x.t] = x.am(0,y_array[i],r,i,0,x.t); + r.s = 0; + r.clamp(); + if(this.s != a.s) BigInteger.ZERO.subTo(r,r); +} + +// (protected) r = this^2, r != this (HAC 14.16) +function bnpSquareTo(r) { + var x = this.abs(); + var x_array = x.array; + var r_array = r.array; + + var i = r.t = 2*x.t; + while(--i >= 0) r_array[i] = 0; + for(i = 0; i < x.t-1; ++i) { + var c = x.am(i,x_array[i],r,2*i,0,1); + if((r_array[i+x.t]+=x.am(i+1,2*x_array[i],r,2*i+1,c,x.t-i-1)) >= BI_DV) { + r_array[i+x.t] -= BI_DV; + r_array[i+x.t+1] = 1; + } + } + if(r.t > 0) r_array[r.t-1] += x.am(i,x_array[i],r,2*i,0,1); + r.s = 0; + r.clamp(); +} + +// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) +// r != q, this != m. q or r may be null. +function bnpDivRemTo(m,q,r) { + var pm = m.abs(); + if(pm.t <= 0) return; + var pt = this.abs(); + if(pt.t < pm.t) { + if(q != null) q.fromInt(0); + if(r != null) this.copyTo(r); + return; + } + if(r == null) r = nbi(); + var y = nbi(), ts = this.s, ms = m.s; + var pm_array = pm.array; + var nsh = BI_DB-nbits(pm_array[pm.t-1]); // normalize modulus + if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } + else { pm.copyTo(y); pt.copyTo(r); } + var ys = y.t; + + var y_array = y.array; + var y0 = y_array[ys-1]; + if(y0 == 0) return; + var yt = y0*(1<<BI_F1)+((ys>1)?y_array[ys-2]>>BI_F2:0); + var d1 = BI_FV/yt, d2 = (1<<BI_F1)/yt, e = 1<<BI_F2; + var i = r.t, j = i-ys, t = (q==null)?nbi():q; + y.dlShiftTo(j,t); + + var r_array = r.array; + if(r.compareTo(t) >= 0) { + r_array[r.t++] = 1; + r.subTo(t,r); + } + BigInteger.ONE.dlShiftTo(ys,t); + t.subTo(y,y); // "negative" y so we can replace sub with am later + while(y.t < ys) y_array[y.t++] = 0; + while(--j >= 0) { + // Estimate quotient digit + var qd = (r_array[--i]==y0)?BI_DM:Math.floor(r_array[i]*d1+(r_array[i-1]+e)*d2); + if((r_array[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out + y.dlShiftTo(j,t); + r.subTo(t,r); + while(r_array[i] < --qd) r.subTo(t,r); + } + } + if(q != null) { + r.drShiftTo(ys,q); + if(ts != ms) BigInteger.ZERO.subTo(q,q); + } + r.t = ys; + r.clamp(); + if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder + if(ts < 0) BigInteger.ZERO.subTo(r,r); +} + +// (public) this mod a +function bnMod(a) { + var r = nbi(); + this.abs().divRemTo(a,null,r); + if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); + return r; +} + +// Modular reduction using "classic" algorithm +function Classic(m) { this.m = m; } +function cConvert(x) { + if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); + else return x; +} +function cRevert(x) { return x; } +function cReduce(x) { x.divRemTo(this.m,null,x); } +function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } +function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +Classic.prototype.convert = cConvert; +Classic.prototype.revert = cRevert; +Classic.prototype.reduce = cReduce; +Classic.prototype.mulTo = cMulTo; +Classic.prototype.sqrTo = cSqrTo; + +// (protected) return "-1/this % 2^DB"; useful for Mont. reduction +// justification: +// xy == 1 (mod m) +// xy = 1+km +// xy(2-xy) = (1+km)(1-km) +// x[y(2-xy)] = 1-k^2m^2 +// x[y(2-xy)] == 1 (mod m^2) +// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 +// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. +// JS multiply "overflows" differently from C/C++, so care is needed here. +function bnpInvDigit() { + var this_array = this.array; + if(this.t < 1) return 0; + var x = this_array[0]; + if((x&1) == 0) return 0; + var y = x&3; // y == 1/x mod 2^2 + y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 + y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 + y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y*(2-x*y%BI_DV))%BI_DV; // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return (y>0)?BI_DV-y:-y; +} + +// Montgomery reduction +function Montgomery(m) { + this.m = m; + this.mp = m.invDigit(); + this.mpl = this.mp&0x7fff; + this.mph = this.mp>>15; + this.um = (1<<(BI_DB-15))-1; + this.mt2 = 2*m.t; +} + +// xR mod m +function montConvert(x) { + var r = nbi(); + x.abs().dlShiftTo(this.m.t,r); + r.divRemTo(this.m,null,r); + if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); + return r; +} + +// x/R mod m +function montRevert(x) { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; +} + +// x = x/R mod m (HAC 14.32) +function montReduce(x) { + var x_array = x.array; + while(x.t <= this.mt2) // pad x so am has enough room later + x_array[x.t++] = 0; + for(var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x_array[i]&0x7fff; + var u0 = (j*this.mpl+(((j*this.mph+(x_array[i]>>15)*this.mpl)&this.um)<<15))&BI_DM; + // use am to combine the multiply-shift-add into one call + j = i+this.m.t; + x_array[j] += this.m.am(0,u0,x,i,0,this.m.t); + // propagate carry + while(x_array[j] >= BI_DV) { x_array[j] -= BI_DV; x_array[++j]++; } + } + x.clamp(); + x.drShiftTo(this.m.t,x); + if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); +} + +// r = "x^2/R mod m"; x != r +function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +// r = "xy/R mod m"; x,y != r +function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + +Montgomery.prototype.convert = montConvert; +Montgomery.prototype.revert = montRevert; +Montgomery.prototype.reduce = montReduce; +Montgomery.prototype.mulTo = montMulTo; +Montgomery.prototype.sqrTo = montSqrTo; + +// (protected) true iff this is even +function bnpIsEven() { + var this_array = this.array; + return ((this.t>0)?(this_array[0]&1):this.s) == 0; +} + +// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) +function bnpExp(e,z) { + if(e > 0xffffffff || e < 1) return BigInteger.ONE; + var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; + g.copyTo(r); + while(--i >= 0) { + z.sqrTo(r,r2); + if((e&(1<<i)) > 0) z.mulTo(r2,g,r); + else { var t = r; r = r2; r2 = t; } + } + return z.revert(r); +} + +// (public) this^e % m, 0 <= e < 2^32 +function bnModPowInt(e,m) { + var z; + if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); + return this.exp(e,z); +} + +// protected +BigInteger.prototype.copyTo = bnpCopyTo; +BigInteger.prototype.fromInt = bnpFromInt; +BigInteger.prototype.fromString = bnpFromString; +BigInteger.prototype.clamp = bnpClamp; +BigInteger.prototype.dlShiftTo = bnpDLShiftTo; +BigInteger.prototype.drShiftTo = bnpDRShiftTo; +BigInteger.prototype.lShiftTo = bnpLShiftTo; +BigInteger.prototype.rShiftTo = bnpRShiftTo; +BigInteger.prototype.subTo = bnpSubTo; +BigInteger.prototype.multiplyTo = bnpMultiplyTo; +BigInteger.prototype.squareTo = bnpSquareTo; +BigInteger.prototype.divRemTo = bnpDivRemTo; +BigInteger.prototype.invDigit = bnpInvDigit; +BigInteger.prototype.isEven = bnpIsEven; +BigInteger.prototype.exp = bnpExp; + +// public +BigInteger.prototype.toString = bnToString; +BigInteger.prototype.negate = bnNegate; +BigInteger.prototype.abs = bnAbs; +BigInteger.prototype.compareTo = bnCompareTo; +BigInteger.prototype.bitLength = bnBitLength; +BigInteger.prototype.mod = bnMod; +BigInteger.prototype.modPowInt = bnModPowInt; + +// "constants" +BigInteger.ZERO = nbv(0); +BigInteger.ONE = nbv(1); +// Copyright (c) 2005 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. + +// Extended JavaScript BN functions, required for RSA private ops. + +// (public) +function bnClone() { var r = nbi(); this.copyTo(r); return r; } + +// (public) return value as integer +function bnIntValue() { + var this_array = this.array; + if(this.s < 0) { + if(this.t == 1) return this_array[0]-BI_DV; + else if(this.t == 0) return -1; + } + else if(this.t == 1) return this_array[0]; + else if(this.t == 0) return 0; + // assumes 16 < DB < 32 + return ((this_array[1]&((1<<(32-BI_DB))-1))<<BI_DB)|this_array[0]; +} + +// (public) return value as byte +function bnByteValue() { + var this_array = this.array; + return (this.t==0)?this.s:(this_array[0]<<24)>>24; +} + +// (public) return value as short (assumes DB>=16) +function bnShortValue() { + var this_array = this.array; + return (this.t==0)?this.s:(this_array[0]<<16)>>16; +} + +// (protected) return x s.t. r^x < DV +function bnpChunkSize(r) { return Math.floor(Math.LN2*BI_DB/Math.log(r)); } + +// (public) 0 if this == 0, 1 if this > 0 +function bnSigNum() { + var this_array = this.array; + if(this.s < 0) return -1; + else if(this.t <= 0 || (this.t == 1 && this_array[0] <= 0)) return 0; + else return 1; +} + +// (protected) convert to radix string +function bnpToRadix(b) { + if(b == null) b = 10; + if(this.signum() == 0 || b < 2 || b > 36) return "0"; + var cs = this.chunkSize(b); + var a = Math.pow(b,cs); + var d = nbv(a), y = nbi(), z = nbi(), r = ""; + this.divRemTo(d,y,z); + while(y.signum() > 0) { + r = (a+z.intValue()).toString(b).substr(1) + r; + y.divRemTo(d,y,z); + } + return z.intValue().toString(b) + r; +} + +// (protected) convert from radix string +function bnpFromRadix(s,b) { + this.fromInt(0); + if(b == null) b = 10; + var cs = this.chunkSize(b); + var d = Math.pow(b,cs), mi = false, j = 0, w = 0; + for(var i = 0; i < s.length; ++i) { + var x = intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-" && this.signum() == 0) mi = true; + continue; + } + w = b*w+x; + if(++j >= cs) { + this.dMultiply(d); + this.dAddOffset(w,0); + j = 0; + w = 0; + } + } + if(j > 0) { + this.dMultiply(Math.pow(b,j)); + this.dAddOffset(w,0); + } + if(mi) BigInteger.ZERO.subTo(this,this); +} + +// (protected) alternate constructor +function bnpFromNumber(a,b,c) { + if("number" == typeof b) { + // new BigInteger(int,int,RNG) + if(a < 2) this.fromInt(1); + else { + this.fromNumber(a,c); + if(!this.testBit(a-1)) // force MSB set + this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this); + if(this.isEven()) this.dAddOffset(1,0); // force odd + while(!this.isProbablePrime(b)) { + this.dAddOffset(2,0); + if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this); + } + } + } + else { + // new BigInteger(int,RNG) + var x = new Array(), t = a&7; + x.length = (a>>3)+1; + b.nextBytes(x); + if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0; + this.fromString(x,256); + } +} + +// (public) convert to bigendian byte array +function bnToByteArray() { + var this_array = this.array; + var i = this.t, r = new Array(); + r[0] = this.s; + var p = BI_DB-(i*BI_DB)%8, d, k = 0; + if(i-- > 0) { + if(p < BI_DB && (d = this_array[i]>>p) != (this.s&BI_DM)>>p) + r[k++] = d|(this.s<<(BI_DB-p)); + while(i >= 0) { + if(p < 8) { + d = (this_array[i]&((1<<p)-1))<<(8-p); + d |= this_array[--i]>>(p+=BI_DB-8); + } + else { + d = (this_array[i]>>(p-=8))&0xff; + if(p <= 0) { p += BI_DB; --i; } + } + if((d&0x80) != 0) d |= -256; + if(k == 0 && (this.s&0x80) != (d&0x80)) ++k; + if(k > 0 || d != this.s) r[k++] = d; + } + } + return r; +} + +function bnEquals(a) { return(this.compareTo(a)==0); } +function bnMin(a) { return(this.compareTo(a)<0)?this:a; } +function bnMax(a) { return(this.compareTo(a)>0)?this:a; } + +// (protected) r = this op a (bitwise) +function bnpBitwiseTo(a,op,r) { + var this_array = this.array; + var a_array = a.array; + var r_array = r.array; + var i, f, m = Math.min(a.t,this.t); + for(i = 0; i < m; ++i) r_array[i] = op(this_array[i],a_array[i]); + if(a.t < this.t) { + f = a.s&BI_DM; + for(i = m; i < this.t; ++i) r_array[i] = op(this_array[i],f); + r.t = this.t; + } + else { + f = this.s&BI_DM; + for(i = m; i < a.t; ++i) r_array[i] = op(f,a_array[i]); + r.t = a.t; + } + r.s = op(this.s,a.s); + r.clamp(); +} + +// (public) this & a +function op_and(x,y) { return x&y; } +function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; } + +// (public) this | a +function op_or(x,y) { return x|y; } +function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; } + +// (public) this ^ a +function op_xor(x,y) { return x^y; } +function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; } + +// (public) this & ~a +function op_andnot(x,y) { return x&~y; } +function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; } + +// (public) ~this +function bnNot() { + var this_array = this.array; + var r = nbi(); + var r_array = r.array; + + for(var i = 0; i < this.t; ++i) r_array[i] = BI_DM&~this_array[i]; + r.t = this.t; + r.s = ~this.s; + return r; +} + +// (public) this << n +function bnShiftLeft(n) { + var r = nbi(); + if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r); + return r; +} + +// (public) this >> n +function bnShiftRight(n) { + var r = nbi(); + if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r); + return r; +} + +// return index of lowest 1-bit in x, x < 2^31 +function lbit(x) { + if(x == 0) return -1; + var r = 0; + if((x&0xffff) == 0) { x >>= 16; r += 16; } + if((x&0xff) == 0) { x >>= 8; r += 8; } + if((x&0xf) == 0) { x >>= 4; r += 4; } + if((x&3) == 0) { x >>= 2; r += 2; } + if((x&1) == 0) ++r; + return r; +} + +// (public) returns index of lowest 1-bit (or -1 if none) +function bnGetLowestSetBit() { + var this_array = this.array; + for(var i = 0; i < this.t; ++i) + if(this_array[i] != 0) return i*BI_DB+lbit(this_array[i]); + if(this.s < 0) return this.t*BI_DB; + return -1; +} + +// return number of 1 bits in x +function cbit(x) { + var r = 0; + while(x != 0) { x &= x-1; ++r; } + return r; +} + +// (public) return number of set bits +function bnBitCount() { + var r = 0, x = this.s&BI_DM; + for(var i = 0; i < this.t; ++i) r += cbit(this_array[i]^x); + return r; +} + +// (public) true iff nth bit is set +function bnTestBit(n) { + var this_array = this.array; + var j = Math.floor(n/BI_DB); + if(j >= this.t) return(this.s!=0); + return((this_array[j]&(1<<(n%BI_DB)))!=0); +} + +// (protected) this op (1<<n) +function bnpChangeBit(n,op) { + var r = BigInteger.ONE.shiftLeft(n); + this.bitwiseTo(r,op,r); + return r; +} + +// (public) this | (1<<n) +function bnSetBit(n) { return this.changeBit(n,op_or); } + +// (public) this & ~(1<<n) +function bnClearBit(n) { return this.changeBit(n,op_andnot); } + +// (public) this ^ (1<<n) +function bnFlipBit(n) { return this.changeBit(n,op_xor); } + +// (protected) r = this + a +function bnpAddTo(a,r) { + var this_array = this.array; + var a_array = a.array; + var r_array = r.array; + var i = 0, c = 0, m = Math.min(a.t,this.t); + while(i < m) { + c += this_array[i]+a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + if(a.t < this.t) { + c += a.s; + while(i < this.t) { + c += this_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c += a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += a.s; + } + r.s = (c<0)?-1:0; + if(c > 0) r_array[i++] = c; + else if(c < -1) r_array[i++] = BI_DV+c; + r.t = i; + r.clamp(); +} + +// (public) this + a +function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; } + +// (public) this - a +function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; } + +// (public) this * a +function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; } + +// (public) this / a +function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; } + +// (public) this % a +function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; } + +// (public) [this/a,this%a] +function bnDivideAndRemainder(a) { + var q = nbi(), r = nbi(); + this.divRemTo(a,q,r); + return new Array(q,r); +} + +// (protected) this *= n, this >= 0, 1 < n < DV +function bnpDMultiply(n) { + var this_array = this.array; + this_array[this.t] = this.am(0,n-1,this,0,0,this.t); + ++this.t; + this.clamp(); +} + +// (protected) this += n << w words, this >= 0 +function bnpDAddOffset(n,w) { + var this_array = this.array; + while(this.t <= w) this_array[this.t++] = 0; + this_array[w] += n; + while(this_array[w] >= BI_DV) { + this_array[w] -= BI_DV; + if(++w >= this.t) this_array[this.t++] = 0; + ++this_array[w]; + } +} + +// A "null" reducer +function NullExp() {} +function nNop(x) { return x; } +function nMulTo(x,y,r) { x.multiplyTo(y,r); } +function nSqrTo(x,r) { x.squareTo(r); } + +NullExp.prototype.convert = nNop; +NullExp.prototype.revert = nNop; +NullExp.prototype.mulTo = nMulTo; +NullExp.prototype.sqrTo = nSqrTo; + +// (public) this^e +function bnPow(e) { return this.exp(e,new NullExp()); } + +// (protected) r = lower n words of "this * a", a.t <= n +// "this" should be the larger one if appropriate. +function bnpMultiplyLowerTo(a,n,r) { + var r_array = r.array; + var a_array = a.array; + var i = Math.min(this.t+a.t,n); + r.s = 0; // assumes a,this >= 0 + r.t = i; + while(i > 0) r_array[--i] = 0; + var j; + for(j = r.t-this.t; i < j; ++i) r_array[i+this.t] = this.am(0,a_array[i],r,i,0,this.t); + for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a_array[i],r,i,0,n-i); + r.clamp(); +} + +// (protected) r = "this * a" without lower n words, n > 0 +// "this" should be the larger one if appropriate. +function bnpMultiplyUpperTo(a,n,r) { + var r_array = r.array; + var a_array = a.array; + --n; + var i = r.t = this.t+a.t-n; + r.s = 0; // assumes a,this >= 0 + while(--i >= 0) r_array[i] = 0; + for(i = Math.max(n-this.t,0); i < a.t; ++i) + r_array[this.t+i-n] = this.am(n-i,a_array[i],r,0,0,this.t+i-n); + r.clamp(); + r.drShiftTo(1,r); +} + +// Barrett modular reduction +function Barrett(m) { + // setup Barrett + this.r2 = nbi(); + this.q3 = nbi(); + BigInteger.ONE.dlShiftTo(2*m.t,this.r2); + this.mu = this.r2.divide(m); + this.m = m; +} + +function barrettConvert(x) { + if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m); + else if(x.compareTo(this.m) < 0) return x; + else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } +} + +function barrettRevert(x) { return x; } + +// x = x mod m (HAC 14.42) +function barrettReduce(x) { + x.drShiftTo(this.m.t-1,this.r2); + if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); } + this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3); + this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2); + while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1); + x.subTo(this.r2,x); + while(x.compareTo(this.m) >= 0) x.subTo(this.m,x); +} + +// r = x^2 mod m; x != r +function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +// r = x*y mod m; x,y != r +function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + +Barrett.prototype.convert = barrettConvert; +Barrett.prototype.revert = barrettRevert; +Barrett.prototype.reduce = barrettReduce; +Barrett.prototype.mulTo = barrettMulTo; +Barrett.prototype.sqrTo = barrettSqrTo; + +// (public) this^e % m (HAC 14.85) +function bnModPow(e,m) { + var e_array = e.array; + var i = e.bitLength(), k, r = nbv(1), z; + if(i <= 0) return r; + else if(i < 18) k = 1; + else if(i < 48) k = 3; + else if(i < 144) k = 4; + else if(i < 768) k = 5; + else k = 6; + if(i < 8) + z = new Classic(m); + else if(m.isEven()) + z = new Barrett(m); + else + z = new Montgomery(m); + + // precomputation + var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1; + g[1] = z.convert(this); + if(k > 1) { + var g2 = nbi(); + z.sqrTo(g[1],g2); + while(n <= km) { + g[n] = nbi(); + z.mulTo(g2,g[n-2],g[n]); + n += 2; + } + } + + var j = e.t-1, w, is1 = true, r2 = nbi(), t; + i = nbits(e_array[j])-1; + while(j >= 0) { + if(i >= k1) w = (e_array[j]>>(i-k1))&km; + else { + w = (e_array[j]&((1<<(i+1))-1))<<(k1-i); + if(j > 0) w |= e_array[j-1]>>(BI_DB+i-k1); + } + + n = k; + while((w&1) == 0) { w >>= 1; --n; } + if((i -= n) < 0) { i += BI_DB; --j; } + if(is1) { // ret == 1, don't bother squaring or multiplying it + g[w].copyTo(r); + is1 = false; + } + else { + while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; } + if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; } + z.mulTo(r2,g[w],r); + } + + while(j >= 0 && (e_array[j]&(1<<i)) == 0) { + z.sqrTo(r,r2); t = r; r = r2; r2 = t; + if(--i < 0) { i = BI_DB-1; --j; } + } + } + return z.revert(r); +} + +// (public) gcd(this,a) (HAC 14.54) +function bnGCD(a) { + var x = (this.s<0)?this.negate():this.clone(); + var y = (a.s<0)?a.negate():a.clone(); + if(x.compareTo(y) < 0) { var t = x; x = y; y = t; } + var i = x.getLowestSetBit(), g = y.getLowestSetBit(); + if(g < 0) return x; + if(i < g) g = i; + if(g > 0) { + x.rShiftTo(g,x); + y.rShiftTo(g,y); + } + while(x.signum() > 0) { + if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x); + if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y); + if(x.compareTo(y) >= 0) { + x.subTo(y,x); + x.rShiftTo(1,x); + } + else { + y.subTo(x,y); + y.rShiftTo(1,y); + } + } + if(g > 0) y.lShiftTo(g,y); + return y; +} + +// (protected) this % n, n < 2^26 +function bnpModInt(n) { + var this_array = this.array; + if(n <= 0) return 0; + var d = BI_DV%n, r = (this.s<0)?n-1:0; + if(this.t > 0) + if(d == 0) r = this_array[0]%n; + else for(var i = this.t-1; i >= 0; --i) r = (d*r+this_array[i])%n; + return r; +} + +// (public) 1/this % m (HAC 14.61) +function bnModInverse(m) { + var ac = m.isEven(); + if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; + var u = m.clone(), v = this.clone(); + var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); + while(u.signum() != 0) { + while(u.isEven()) { + u.rShiftTo(1,u); + if(ac) { + if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } + a.rShiftTo(1,a); + } + else if(!b.isEven()) b.subTo(m,b); + b.rShiftTo(1,b); + } + while(v.isEven()) { + v.rShiftTo(1,v); + if(ac) { + if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } + c.rShiftTo(1,c); + } + else if(!d.isEven()) d.subTo(m,d); + d.rShiftTo(1,d); + } + if(u.compareTo(v) >= 0) { + u.subTo(v,u); + if(ac) a.subTo(c,a); + b.subTo(d,b); + } + else { + v.subTo(u,v); + if(ac) c.subTo(a,c); + d.subTo(b,d); + } + } + if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; + if(d.compareTo(m) >= 0) return d.subtract(m); + if(d.signum() < 0) d.addTo(m,d); else return d; + if(d.signum() < 0) return d.add(m); else return d; +} + +var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509]; +var lplim = (1<<26)/lowprimes[lowprimes.length-1]; + +// (public) test primality with certainty >= 1-.5^t +function bnIsProbablePrime(t) { + var i, x = this.abs(); + var x_array = x.array; + if(x.t == 1 && x_array[0] <= lowprimes[lowprimes.length-1]) { + for(i = 0; i < lowprimes.length; ++i) + if(x_array[0] == lowprimes[i]) return true; + return false; + } + if(x.isEven()) return false; + i = 1; + while(i < lowprimes.length) { + var m = lowprimes[i], j = i+1; + while(j < lowprimes.length && m < lplim) m *= lowprimes[j++]; + m = x.modInt(m); + while(i < j) if(m%lowprimes[i++] == 0) return false; + } + return x.millerRabin(t); +} + +// (protected) true if probably prime (HAC 4.24, Miller-Rabin) +function bnpMillerRabin(t) { + var n1 = this.subtract(BigInteger.ONE); + var k = n1.getLowestSetBit(); + if(k <= 0) return false; + var r = n1.shiftRight(k); + t = (t+1)>>1; + if(t > lowprimes.length) t = lowprimes.length; + var a = nbi(); + for(var i = 0; i < t; ++i) { + a.fromInt(lowprimes[i]); + var y = a.modPow(r,this); + if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { + var j = 1; + while(j++ < k && y.compareTo(n1) != 0) { + y = y.modPowInt(2,this); + if(y.compareTo(BigInteger.ONE) == 0) return false; + } + if(y.compareTo(n1) != 0) return false; + } + } + return true; +} + +// protected +BigInteger.prototype.chunkSize = bnpChunkSize; +BigInteger.prototype.toRadix = bnpToRadix; +BigInteger.prototype.fromRadix = bnpFromRadix; +BigInteger.prototype.fromNumber = bnpFromNumber; +BigInteger.prototype.bitwiseTo = bnpBitwiseTo; +BigInteger.prototype.changeBit = bnpChangeBit; +BigInteger.prototype.addTo = bnpAddTo; +BigInteger.prototype.dMultiply = bnpDMultiply; +BigInteger.prototype.dAddOffset = bnpDAddOffset; +BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; +BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; +BigInteger.prototype.modInt = bnpModInt; +BigInteger.prototype.millerRabin = bnpMillerRabin; + +// public +BigInteger.prototype.clone = bnClone; +BigInteger.prototype.intValue = bnIntValue; +BigInteger.prototype.byteValue = bnByteValue; +BigInteger.prototype.shortValue = bnShortValue; +BigInteger.prototype.signum = bnSigNum; +BigInteger.prototype.toByteArray = bnToByteArray; +BigInteger.prototype.equals = bnEquals; +BigInteger.prototype.min = bnMin; +BigInteger.prototype.max = bnMax; +BigInteger.prototype.and = bnAnd; +BigInteger.prototype.or = bnOr; +BigInteger.prototype.xor = bnXor; +BigInteger.prototype.andNot = bnAndNot; +BigInteger.prototype.not = bnNot; +BigInteger.prototype.shiftLeft = bnShiftLeft; +BigInteger.prototype.shiftRight = bnShiftRight; +BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; +BigInteger.prototype.bitCount = bnBitCount; +BigInteger.prototype.testBit = bnTestBit; +BigInteger.prototype.setBit = bnSetBit; +BigInteger.prototype.clearBit = bnClearBit; +BigInteger.prototype.flipBit = bnFlipBit; +BigInteger.prototype.add = bnAdd; +BigInteger.prototype.subtract = bnSubtract; +BigInteger.prototype.multiply = bnMultiply; +BigInteger.prototype.divide = bnDivide; +BigInteger.prototype.remainder = bnRemainder; +BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; +BigInteger.prototype.modPow = bnModPow; +BigInteger.prototype.modInverse = bnModInverse; +BigInteger.prototype.pow = bnPow; +BigInteger.prototype.gcd = bnGCD; +BigInteger.prototype.isProbablePrime = bnIsProbablePrime; + +// BigInteger interfaces not implemented in jsbn: + +// BigInteger(int signum, byte[] magnitude) +// double doubleValue() +// float floatValue() +// int hashCode() +// long longValue() +// static BigInteger valueOf(long val) +// prng4.js - uses Arcfour as a PRNG + +function Arcfour() { + this.i = 0; + this.j = 0; + this.S = new Array(); +} + +// Initialize arcfour context from key, an array of ints, each from [0..255] +function ARC4init(key) { + var i, j, t; + for(i = 0; i < 256; ++i) + this.S[i] = i; + j = 0; + for(i = 0; i < 256; ++i) { + j = (j + this.S[i] + key[i % key.length]) & 255; + t = this.S[i]; + this.S[i] = this.S[j]; + this.S[j] = t; + } + this.i = 0; + this.j = 0; +} + +function ARC4next() { + var t; + this.i = (this.i + 1) & 255; + this.j = (this.j + this.S[this.i]) & 255; + t = this.S[this.i]; + this.S[this.i] = this.S[this.j]; + this.S[this.j] = t; + return this.S[(t + this.S[this.i]) & 255]; +} + +Arcfour.prototype.init = ARC4init; +Arcfour.prototype.next = ARC4next; + +// Plug in your RNG constructor here +function prng_newstate() { + return new Arcfour(); +} + +// Pool size must be a multiple of 4 and greater than 32. +// An array of bytes the size of the pool will be passed to init() +var rng_psize = 256; +// Random number generator - requires a PRNG backend, e.g. prng4.js + +// For best results, put code like +// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'> +// in your main HTML document. + +var rng_state; +var rng_pool; +var rng_pptr; + +// Mix in a 32-bit integer into the pool +function rng_seed_int(x) { + rng_pool[rng_pptr++] ^= x & 255; + rng_pool[rng_pptr++] ^= (x >> 8) & 255; + rng_pool[rng_pptr++] ^= (x >> 16) & 255; + rng_pool[rng_pptr++] ^= (x >> 24) & 255; + if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; +} + +// Mix in the current time (w/milliseconds) into the pool +function rng_seed_time() { + // Use pre-computed date to avoid making the benchmark + // results dependent on the current date. + rng_seed_int(1122926989487); +} + +// Initialize the pool with junk if needed. +if(rng_pool == null) { + rng_pool = new Array(); + rng_pptr = 0; + var t; + while(rng_pptr < rng_psize) { // extract some randomness from Math.random() + t = Math.floor(65536 * Math.random()); + rng_pool[rng_pptr++] = t >>> 8; + rng_pool[rng_pptr++] = t & 255; + } + rng_pptr = 0; + rng_seed_time(); + //rng_seed_int(window.screenX); + //rng_seed_int(window.screenY); +} + +function rng_get_byte() { + if(rng_state == null) { + rng_seed_time(); + rng_state = prng_newstate(); + rng_state.init(rng_pool); + for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) + rng_pool[rng_pptr] = 0; + rng_pptr = 0; + //rng_pool = null; + } + // TODO: allow reseeding after first request + return rng_state.next(); +} + +function rng_get_bytes(ba) { + var i; + for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte(); +} + +function SecureRandom() {} + +SecureRandom.prototype.nextBytes = rng_get_bytes; +// Depends on jsbn.js and rng.js + +// convert a (hex) string to a bignum object +function parseBigInt(str,r) { + return new BigInteger(str,r); +} + +function linebrk(s,n) { + var ret = ""; + var i = 0; + while(i + n < s.length) { + ret += s.substring(i,i+n) + "\n"; + i += n; + } + return ret + s.substring(i,s.length); +} + +function byte2Hex(b) { + if(b < 0x10) + return "0" + b.toString(16); + else + return b.toString(16); +} + +// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint +function pkcs1pad2(s,n) { + if(n < s.length + 11) { + print("Message too long for RSA"); + return null; + } + var ba = new Array(); + var i = s.length - 1; + while(i >= 0 && n > 0) ba[--n] = s.charCodeAt(i--); + ba[--n] = 0; + var rng = new SecureRandom(); + var x = new Array(); + while(n > 2) { // random non-zero pad + x[0] = 0; + while(x[0] == 0) rng.nextBytes(x); + ba[--n] = x[0]; + } + ba[--n] = 2; + ba[--n] = 0; + return new BigInteger(ba); +} + +// "empty" RSA key constructor +function RSAKey() { + this.n = null; + this.e = 0; + this.d = null; + this.p = null; + this.q = null; + this.dmp1 = null; + this.dmq1 = null; + this.coeff = null; +} + +// Set the public key fields N and e from hex strings +function RSASetPublic(N,E) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + } + else + print("Invalid RSA public key"); +} + +// Perform raw public operation on "x": return x^e (mod n) +function RSADoPublic(x) { + return x.modPowInt(this.e, this.n); +} + +// Return the PKCS#1 RSA encryption of "text" as an even-length hex string +function RSAEncrypt(text) { + var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3); + if(m == null) return null; + var c = this.doPublic(m); + if(c == null) return null; + var h = c.toString(16); + if((h.length & 1) == 0) return h; else return "0" + h; +} + +// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string +//function RSAEncryptB64(text) { +// var h = this.encrypt(text); +// if(h) return hex2b64(h); else return null; +//} + +// protected +RSAKey.prototype.doPublic = RSADoPublic; + +// public +RSAKey.prototype.setPublic = RSASetPublic; +RSAKey.prototype.encrypt = RSAEncrypt; +//RSAKey.prototype.encrypt_b64 = RSAEncryptB64; +// Depends on rsa.js and jsbn2.js + +// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext +function pkcs1unpad2(d,n) { + var b = d.toByteArray(); + var i = 0; + while(i < b.length && b[i] == 0) ++i; + if(b.length-i != n-1 || b[i] != 2) + return null; + ++i; + while(b[i] != 0) + if(++i >= b.length) return null; + var ret = ""; + while(++i < b.length) + ret += String.fromCharCode(b[i]); + return ret; +} + +// Set the private key fields N, e, and d from hex strings +function RSASetPrivate(N,E,D) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + this.d = parseBigInt(D,16); + } + else + print("Invalid RSA private key"); +} + +// Set the private key fields N, e, d and CRT params from hex strings +function RSASetPrivateEx(N,E,D,P,Q,DP,DQ,C) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + this.d = parseBigInt(D,16); + this.p = parseBigInt(P,16); + this.q = parseBigInt(Q,16); + this.dmp1 = parseBigInt(DP,16); + this.dmq1 = parseBigInt(DQ,16); + this.coeff = parseBigInt(C,16); + } + else + print("Invalid RSA private key"); +} + +// Generate a new random private key B bits long, using public expt E +function RSAGenerate(B,E) { + var rng = new SecureRandom(); + var qs = B>>1; + this.e = parseInt(E,16); + var ee = new BigInteger(E,16); + for(;;) { + for(;;) { + this.p = new BigInteger(B-qs,1,rng); + if(this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) break; + } + for(;;) { + this.q = new BigInteger(qs,1,rng); + if(this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) break; + } + if(this.p.compareTo(this.q) <= 0) { + var t = this.p; + this.p = this.q; + this.q = t; + } + var p1 = this.p.subtract(BigInteger.ONE); + var q1 = this.q.subtract(BigInteger.ONE); + var phi = p1.multiply(q1); + if(phi.gcd(ee).compareTo(BigInteger.ONE) == 0) { + this.n = this.p.multiply(this.q); + this.d = ee.modInverse(phi); + this.dmp1 = this.d.mod(p1); + this.dmq1 = this.d.mod(q1); + this.coeff = this.q.modInverse(this.p); + break; + } + } +} + +// Perform raw private operation on "x": return x^d (mod n) +function RSADoPrivate(x) { + if(this.p == null || this.q == null) + return x.modPow(this.d, this.n); + + // TODO: re-calculate any missing CRT params + var xp = x.mod(this.p).modPow(this.dmp1, this.p); + var xq = x.mod(this.q).modPow(this.dmq1, this.q); + + while(xp.compareTo(xq) < 0) + xp = xp.add(this.p); + return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq); +} + +// Return the PKCS#1 RSA decryption of "ctext". +// "ctext" is an even-length hex string and the output is a plain string. +function RSADecrypt(ctext) { + var c = parseBigInt(ctext, 16); + var m = this.doPrivate(c); + if(m == null) return null; + return pkcs1unpad2(m, (this.n.bitLength()+7)>>3); +} + +// Return the PKCS#1 RSA decryption of "ctext". +// "ctext" is a Base64-encoded string and the output is a plain string. +//function RSAB64Decrypt(ctext) { +// var h = b64tohex(ctext); +// if(h) return this.decrypt(h); else return null; +//} + +// protected +RSAKey.prototype.doPrivate = RSADoPrivate; + +// public +RSAKey.prototype.setPrivate = RSASetPrivate; +RSAKey.prototype.setPrivateEx = RSASetPrivateEx; +RSAKey.prototype.generate = RSAGenerate; +RSAKey.prototype.decrypt = RSADecrypt; +//RSAKey.prototype.b64_decrypt = RSAB64Decrypt; + + +nValue="a5261939975948bb7a58dffe5ff54e65f0498f9175f5a09288810b8975871e99af3b5dd94057b0fc07535f5f97444504fa35169d461d0d30cf0192e307727c065168c788771c561a9400fb49175e9e6aa4e23fe11af69e9412dd23b0cb6684c4c2429bce139e848ab26d0829073351f4acd36074eafd036a5eb83359d2a698d3"; +eValue="10001"; +dValue="8e9912f6d3645894e8d38cb58c0db81ff516cf4c7e5a14c7f1eddb1459d2cded4d8d293fc97aee6aefb861859c8b6a3d1dfe710463e1f9ddc72048c09751971c4a580aa51eb523357a3cc48d31cfad1d4a165066ed92d4748fb6571211da5cb14bc11b6e2df7c1a559e6d5ac1cd5c94703a22891464fba23d0d965086277a161"; +pValue="d090ce58a92c75233a6486cb0a9209bf3583b64f540c76f5294bb97d285eed33aec220bde14b2417951178ac152ceab6da7090905b478195498b352048f15e7d"; +qValue="cab575dc652bb66df15a0359609d51d1db184750c00c6698b90ef3465c99655103edbf0d54c56aec0ce3c4d22592338092a126a0cc49f65a4a30d222b411e58f"; +dmp1Value="1a24bca8e273df2f0e47c199bbf678604e7df7215480c77c8db39f49b000ce2cf7500038acfff5433b7d582a01f1826e6f4d42e1c57f5e1fef7b12aabc59fd25"; +dmq1Value="3d06982efbbe47339e1f6d36b1216b8a741d410b0c662f54f7118b27b9a4ec9d914337eb39841d8666f3034408cf94f5b62f11c402fc994fe15a05493150d9fd"; +coeffValue="3a3e731acd8960b7ff9eb81a7ff93bd1cfa74cbd56987db58b4594fb09c09084db1734c8143f98b602b981aaa9243ca28deb69b5b280ee8dcee0fd2625e53250"; + +setupEngine(am3, 28); + +var TEXT = "The quick brown fox jumped over the extremely lazy frog! " + + "Now is the time for all good men to come to the party."; +var encrypted; + +function encrypt() { + var RSA = new RSAKey(); + RSA.setPublic(nValue, eValue); + RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value, coeffValue); + encrypted = RSA.encrypt(TEXT); +} + +function decrypt() { + var RSA = new RSAKey(); + RSA.setPublic(nValue, eValue); + RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value, coeffValue); + var decrypted = RSA.decrypt(encrypted); + if (decrypted != TEXT) { + throw new Error("Crypto operation failed"); + } +} + +var d1 = +new Date +encrypt() +decrypt() + +if (typeof(print) === "undefined") + print = console.log; + +print("done in", new Date - d1) diff --git a/tests/manual/v4/exceptions.1.js b/tests/manual/v4/exceptions.1.js new file mode 100644 index 0000000000..5e4e152c19 --- /dev/null +++ b/tests/manual/v4/exceptions.1.js @@ -0,0 +1,16 @@ + +function foo(a) { + x = 1 + if (a) + throw 100; + print("unreachable.1") +} + +function bar(a) { + print("reachable"); + foo(a) + print("unreachable.2") +} + +bar(1) +print("unreachable.3") diff --git a/tests/manual/v4/exceptions.2.js b/tests/manual/v4/exceptions.2.js new file mode 100644 index 0000000000..16b93b8940 --- /dev/null +++ b/tests/manual/v4/exceptions.2.js @@ -0,0 +1,2 @@ + +print(foo) diff --git a/tests/manual/v4/fact.2.js b/tests/manual/v4/fact.2.js new file mode 100644 index 0000000000..d8f750b5a1 --- /dev/null +++ b/tests/manual/v4/fact.2.js @@ -0,0 +1,8 @@ + +function fact(n) { + return n > 1 ? n * fact(n - 1) : 1 +} + +for (var i = 0; i < 1000000; i = i + 1) + fact(12) + diff --git a/tests/manual/v4/fact.3.js b/tests/manual/v4/fact.3.js new file mode 100644 index 0000000000..8a42df080f --- /dev/null +++ b/tests/manual/v4/fact.3.js @@ -0,0 +1,20 @@ +function fact(n) { + var res = 1; + for (var i = 2; i <= n; i=i+1) { + res = res * i; + } + return res; +} + +function go() { + var d1 = +new Date + for (var i = 0; i < 1000000; i = i + 1) { + if (fact(12) != 479001600) + print(i); + } + var d2 = +new Date + print("done in", d2 - d1) +} + +//print(fact(12)); +go(); diff --git a/tests/manual/v4/fact.js b/tests/manual/v4/fact.js new file mode 100644 index 0000000000..95692381fb --- /dev/null +++ b/tests/manual/v4/fact.js @@ -0,0 +1,22 @@ +function fact1(n) { + if (n > 0) + return n * fact1(n - 1); + else + return 1 +} + +function fact2(n) { + return n > 0 ? n * fact2(n - 1) : 1 +} + +function fact3(n) { + var res = 1; + for (var i = 2; i <= n; i=i+1) + res = res * i; + return res; +} + +print("fact1(12) =", fact1(12)) +print("fact2(12) =", fact2(12)) +print("fact3(12) =", fact3(12)) + diff --git a/tests/manual/v4/for/for.1.js b/tests/manual/v4/for/for.1.js new file mode 100644 index 0000000000..9c1454dd31 --- /dev/null +++ b/tests/manual/v4/for/for.1.js @@ -0,0 +1,6 @@ + +var x = 0 +for (var i = 0; i < 20; i = i + 1) { + x = x + i + print((i + ") x = " + x)) +} diff --git a/tests/manual/v4/for/for.2.js b/tests/manual/v4/for/for.2.js new file mode 100644 index 0000000000..f403160dc8 --- /dev/null +++ b/tests/manual/v4/for/for.2.js @@ -0,0 +1,7 @@ +var x = 0 +for (var i = 0; i < 20; i = i + 1) { + if (i % 2) + continue + x = x + i + print((i + ") x = " + x)) +} diff --git a/tests/manual/v4/for/for.3.js b/tests/manual/v4/for/for.3.js new file mode 100644 index 0000000000..f745366d41 --- /dev/null +++ b/tests/manual/v4/for/for.3.js @@ -0,0 +1,7 @@ +var x = 0 +for (var i = 0; i < 20; i = i + 1) { + if (i == 10) + break + x = x + i + print((i + ") x = " + x)) +} diff --git a/tests/manual/v4/for/for.4.js b/tests/manual/v4/for/for.4.js new file mode 100644 index 0000000000..6e282181f4 --- /dev/null +++ b/tests/manual/v4/for/for.4.js @@ -0,0 +1,7 @@ +var x = 0 +for (var i = 0; i < 20; i = i + 1) { + if (! (i % 2)) + continue + x = x + i + print((i + ") x = " + x)) +} diff --git a/tests/manual/v4/fun.1.js b/tests/manual/v4/fun.1.js new file mode 100644 index 0000000000..9d73cade94 --- /dev/null +++ b/tests/manual/v4/fun.1.js @@ -0,0 +1,7 @@ + +function foo(a,b) { print(a, b) } +var foo2 = foo +var foo3 = function(a,b) { print(a, b); } +foo(1,2) +foo2(1,2) +foo3(1, 2) diff --git a/tests/manual/v4/fun.2.js b/tests/manual/v4/fun.2.js new file mode 100644 index 0000000000..c3fb613ac6 --- /dev/null +++ b/tests/manual/v4/fun.2.js @@ -0,0 +1,14 @@ + +function Point(x,y) { + this.x = 10 + this.y = 20 +} + +Point.prototype = { + print: function() { print(this.x, this.y) } +} + +var pt = new Point(10, 20) +print(pt.x, pt.y) +pt.print() + diff --git a/tests/manual/v4/fun.3.js b/tests/manual/v4/fun.3.js new file mode 100644 index 0000000000..5add270f35 --- /dev/null +++ b/tests/manual/v4/fun.3.js @@ -0,0 +1,17 @@ + +function fix(f) { + var k = function (x) { + return f(function (z) { return x(x)(z) }) + } + return k(k) +} + +var F = function (f) { + return function (n) { + return n == 0 ? 1 : n * f(n - 1) + } +} + +var fact = fix(F) + +print("the factorial of 12 is", fact(12)) diff --git a/tests/manual/v4/fun.4.js b/tests/manual/v4/fun.4.js new file mode 100644 index 0000000000..b130acccd3 --- /dev/null +++ b/tests/manual/v4/fun.4.js @@ -0,0 +1,18 @@ + +function foo(a,b,c) { + print("hello",a,b,c) +} + +foo.call(null, 1,2,3); + +[10,20,30].forEach(function (v,k,o) { print(v,k,o); }); + +print([10, 20, 30].every(function (v,k,o) { return v > 9 })); +print([10, 20, 30].some(function (v,k,o) { return v == 20 })); +print([10, 20, 30].map(function (v,k,o) { return v * v })); +print([10, 20, 30].filter(function (v,k,o) { return v >= 20 })); + +print([10,20,30].reduce(function(a,v,k,o) { return a + v })); +print([10,20,30].reduceRight(function(a,v,k,o) { return a + v })); + + diff --git a/tests/manual/v4/instanceof.1.js b/tests/manual/v4/instanceof.1.js new file mode 100644 index 0000000000..d991574e66 --- /dev/null +++ b/tests/manual/v4/instanceof.1.js @@ -0,0 +1,9 @@ + +function foo() {} +foo.prototype = {} + +var f = new foo() +print(foo.prototype) +print(f.__proto__) +print(foo.prototype == f.__proto__) +print(f instanceof foo) diff --git a/tests/manual/v4/label.1.js b/tests/manual/v4/label.1.js new file mode 100644 index 0000000000..79921cb5aa --- /dev/null +++ b/tests/manual/v4/label.1.js @@ -0,0 +1,8 @@ + +L: { + var x = 1 + print(x) + break L + x = 2 + print(x) +} diff --git a/tests/manual/v4/label.2.js b/tests/manual/v4/label.2.js new file mode 100644 index 0000000000..fcb3d3e0e9 --- /dev/null +++ b/tests/manual/v4/label.2.js @@ -0,0 +1,2 @@ + +L: break L diff --git a/tests/manual/v4/label.3.js b/tests/manual/v4/label.3.js new file mode 100644 index 0000000000..9940a33aff --- /dev/null +++ b/tests/manual/v4/label.3.js @@ -0,0 +1,6 @@ + +L: for (var i = 0; i < 10; ++i) { + print(i) + if (i == 5) + continue L +} diff --git a/tests/manual/v4/obj.1.js b/tests/manual/v4/obj.1.js new file mode 100644 index 0000000000..de2bd6318e --- /dev/null +++ b/tests/manual/v4/obj.1.js @@ -0,0 +1,8 @@ + +var point = { x: 123, y: 321 } +print(point, point.x, point.y) + +var obj = {} +obj.x = 123 +obj.str = "ciao" +print(obj, obj.str, obj.x) diff --git a/tests/manual/v4/obj.2.js b/tests/manual/v4/obj.2.js new file mode 100644 index 0000000000..e9b1be5be0 --- /dev/null +++ b/tests/manual/v4/obj.2.js @@ -0,0 +1,10 @@ + + +var obj = { + x: 10, + y: 20, + dump: function() { print("hello", this.x, this.y) } +} + +print(obj.x, obj.y, obj.dump) +obj.dump() diff --git a/tests/manual/v4/property_lookup.js b/tests/manual/v4/property_lookup.js new file mode 100644 index 0000000000..ee45b65710 --- /dev/null +++ b/tests/manual/v4/property_lookup.js @@ -0,0 +1,9 @@ +function foo() { + var obj = { x: 10 } + + for (var i = 0; i < 1000000; ++i) { + var y = obj.x; + obj.x = y; + } +} +foo(); diff --git a/tests/manual/v4/prototype.1.js b/tests/manual/v4/prototype.1.js new file mode 100644 index 0000000000..40db84a0a9 --- /dev/null +++ b/tests/manual/v4/prototype.1.js @@ -0,0 +1,14 @@ + +function foo() { +} + +print(foo.toString()) +print(foo.__proto__) +print(foo.prototype) + +//foo.prototype.xx = function() { +// print("got xx") +//} + +//f = new foo +//f.xx() diff --git a/tests/manual/v4/prototype.2.js b/tests/manual/v4/prototype.2.js new file mode 100644 index 0000000000..860385d977 --- /dev/null +++ b/tests/manual/v4/prototype.2.js @@ -0,0 +1,13 @@ + +var oo = {} +function mk() { + function zoo() { + } + zoo.prototype = oo + return new zoo() +} + +var a = mk() +var b = mk() +print(a.__proto__ == b.__proto__) + diff --git a/tests/manual/v4/prototype.3.js b/tests/manual/v4/prototype.3.js new file mode 100644 index 0000000000..b76f544ee3 --- /dev/null +++ b/tests/manual/v4/prototype.3.js @@ -0,0 +1,10 @@ + +function foo() { + this.stuff() +} + +foo.prototype.stuff = function() { + print("this is cool stuff") +} + +f = new foo() diff --git a/tests/manual/v4/prototype.4.js b/tests/manual/v4/prototype.4.js new file mode 100644 index 0000000000..9e4facb540 --- /dev/null +++ b/tests/manual/v4/prototype.4.js @@ -0,0 +1,9 @@ + +function Point(x, y) { + this.x = x + this.y = y +} + +var pt = new Point(10, 20) +print(Point.prototype.isPrototypeOf(pt)) + diff --git a/tests/manual/v4/regexp.1.js b/tests/manual/v4/regexp.1.js new file mode 100644 index 0000000000..c508bd53bb --- /dev/null +++ b/tests/manual/v4/regexp.1.js @@ -0,0 +1,4 @@ +var re = new RegExp("abc") +print(re) +var match = re.exec("xxxabc") +print(match.length, match.index, match[0]) diff --git a/tests/manual/v4/simple.2.js b/tests/manual/v4/simple.2.js new file mode 100644 index 0000000000..4a9f966da1 --- /dev/null +++ b/tests/manual/v4/simple.2.js @@ -0,0 +1,19 @@ + +function main() +{ + var a = 1 + var b = 2 + var c = 10 + var d = 100 + + for (var i = 0; i < 1000000; i = i + 1) { + if (a == 1) + d = d + a + b * c + else + d = 321 + } + + print("the result is", d) +} + +main() diff --git a/tests/manual/v4/simple.js b/tests/manual/v4/simple.js new file mode 100644 index 0000000000..8a80bcb4d0 --- /dev/null +++ b/tests/manual/v4/simple.js @@ -0,0 +1,15 @@ + +var a = 1 +var b = 2 +var c = 10 +var d = 100 + +var d1 = new Date +for (var i = 0; i < 1000000; i = i + 1) { + if (a == 1) + d = d + a + b * c + else + d = 321 +} + +print("the result is", d, "done in", new Date - d1) diff --git a/tests/manual/v4/string.1.js b/tests/manual/v4/string.1.js new file mode 100644 index 0000000000..8cc76bb82d --- /dev/null +++ b/tests/manual/v4/string.1.js @@ -0,0 +1,20 @@ + +var s = String(123) + 1 +print(s) + +var s2 = new String(123) +print(s2, s2.toString, s2.toString()) + +var s3 = String.prototype.constructor(321) +print(s3) + +var s4 = new String.prototype.constructor(321) +print(s4) + +print(s4.charAt(0), s4.charAt(1), s4.charCodeAt(0)) + +print(s4.concat("ciao", "cool")) +print(s4.indexOf('1')) +print(s4.lastIndexOf('1', 1)) + +print("ss", s4.slice(0, 2)) diff --git a/tests/manual/v4/switch.1.js b/tests/manual/v4/switch.1.js new file mode 100644 index 0000000000..ca29b5f5de --- /dev/null +++ b/tests/manual/v4/switch.1.js @@ -0,0 +1,16 @@ + +function test(a) { + switch (a) { + default: return "cool" + case "xxx": print("got zero"); break; + case "ciao": case "ciao2": return 123 + case "hello": return 321 + } + return 444 +} + +print(test("xxx")) +print(test("hello")) +print(test("ciao")) +print(test("ciao2")) +print(test(9)) diff --git a/tests/manual/v4/switch.2.js b/tests/manual/v4/switch.2.js new file mode 100644 index 0000000000..60d59c161b --- /dev/null +++ b/tests/manual/v4/switch.2.js @@ -0,0 +1,11 @@ +var i; +for (i = 0; i < 2; ++i) { + switch ("a") { + case "a": + continue; + default: + break; + } +} +if (i != 2) + print("loop did not run often enough"); diff --git a/tests/manual/v4/test262 b/tests/manual/v4/test262 new file mode 160000 +Subproject 0b5af3dcec772bb06b4d685a20b2859cda59d18 diff --git a/tests/manual/v4/test262.py b/tests/manual/v4/test262.py new file mode 100755 index 0000000000..9f2ba80996 --- /dev/null +++ b/tests/manual/v4/test262.py @@ -0,0 +1,595 @@ +#!/usr/bin/env python +############################################################################# +## +## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +## Contact: http://www.qt-project.org/legal +## +## This file is part of the test suite module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +## of its contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +# Copyright 2009 the Sputnik authors. All rights reserved. +# This code is governed by the BSD license found in the LICENSE file. + +# This is derived from sputnik.py, the Sputnik console test runner, +# with elements from packager.py, which is separately +# copyrighted. TODO: Refactor so there is less duplication between +# test262.py and packager.py. + +import sys +from os import path +rootDir = path.dirname(path.realpath(__file__)) +sys.path.insert(0, path.abspath(rootDir + "/test262/tools/packaging")) + +import logging +import optparse +import os +import platform +import re +import subprocess +import tempfile +import time +import xml.dom.minidom +import datetime +import shutil +import json +import stat +import multiprocessing +import signal + + +from parseTestRecord import parseTestRecord, stripHeader + +from packagerConfig import * + +# ############# Helpers needed for parallel multi-process test execution ############ + +def runTest(case, args): + return case.Run(args) + +def runTestVarArgs(args): + return runTest(*args) + +def initWorkerProcess(): + signal.signal(signal.SIGINT, signal.SIG_IGN) + +# ############# + +class Test262Error(Exception): + def __init__(self, message): + self.message = message + +def ReportError(s): + raise Test262Error(s) + + +class TestExpectations: + def __init__(self, enabled): + self.testsToSkip = [] + self.failingTests = [] + f = open(rootDir + "/TestExpectations") + if not enabled: + return + for line in f.read().splitlines(): + line = line.strip() + if len(line) == 0 or line[0] == "#": + continue + record = line.split() + if len(record) == 1: + self.testsToSkip.append(record[0]) + else: + test = record[0] + expectation = record[1] + if expectation == "failing": + self.failingTests.append(test) + f.close() + + def update(self, progress): + unexpectedPasses = [c.case.name[-1] for c in progress.failed_tests if c.case.IsNegative()] + + # If a test fails that we expected to fail, then it actually passed unexpectedly. + failures = [c.case.name[-1] for c in progress.failed_tests if not c.case.IsNegative()] + for failure in failures: + if failure in self.failingTests: + unexpectedPasses.append(failure) + + f = open(rootDir + "/TestExpectations") + lines = f.read().splitlines() + oldLen = len(lines) + for result in unexpectedPasses: + expectationLine = result + " failing" + try: + lines.remove(expectationLine) + except ValueError: + pass + + f.close() + if len(lines) != oldLen: + f = open(rootDir + "/TestExpectations", "w") + f.write("\n".join(lines)) + f.close() + print "Changes to TestExpectations written!" + + +if not os.path.exists(EXCLUDED_FILENAME): + print "Cannot generate (JSON) test262 tests without a file," + \ + " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME + sys.exit(1) +EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME) +EXCLUDE_LIST = EXCLUDE_LIST.getElementsByTagName("test") +EXCLUDE_LIST = [x.getAttribute("id") for x in EXCLUDE_LIST] + + +def BuildOptions(): + result = optparse.OptionParser() + result.add_option("--command", default="v4", help="The command-line to run") + result.add_option("--tests", default=path.abspath(rootDir + '/test262'), + help="Path to the tests") + result.add_option("--cat", default=False, action="store_true", + help="Print packaged test code that would be run") + result.add_option("--summary", default=True, action="store_true", + help="Print summary after running tests") + result.add_option("--full-summary", default=False, action="store_true", + help="Print summary and test output after running tests") + result.add_option("--strict_only", default=False, action="store_true", + help="Test only strict mode") + result.add_option("--non_strict_only", default=False, action="store_true", + help="Test only non-strict mode") + result.add_option("--parallel", default=False, action="store_true", + help="Run tests in parallel") + result.add_option("--with-test-expectations", default=False, action="store_true", + help="Parse TestExpectations to deal with tests known to fail") + result.add_option("--update-expectations", default=False, action="store_true", + help="Update test expectations fail when a test passes that was expected to fail") + # TODO: Once enough tests are made strict compat, change the default + # to "both" + result.add_option("--unmarked_default", default="non_strict", + help="default mode for tests of unspecified strictness") + return result + + +def ValidateOptions(options): + if not options.command: + ReportError("A --command must be specified.") + if not path.exists(options.tests): + ReportError("Couldn't find test path '%s'" % options.tests) + + +placeHolderPattern = re.compile(r"\{\{(\w+)\}\}") + + +def IsWindows(): + p = platform.system() + return (p == 'Windows') or (p == 'Microsoft') + + +class TempFile(object): + + def __init__(self, suffix="", prefix="tmp", text=False): + self.suffix = suffix + self.prefix = prefix + self.text = text + self.fd = None + self.name = None + self.is_closed = False + self.Open() + + def Open(self): + (self.fd, self.name) = tempfile.mkstemp( + suffix = self.suffix, + prefix = self.prefix, + text = self.text) + + def Write(self, str): + os.write(self.fd, str) + + def Read(self): + f = file(self.name) + result = f.read() + f.close() + return result + + def Close(self): + if not self.is_closed: + self.is_closed = True + os.close(self.fd) + + def Dispose(self): + try: + self.Close() + os.unlink(self.name) + except OSError, e: + logging.error("Error disposing temp file: %s", str(e)) + + +class TestResult(object): + + def __init__(self, exit_code, stdout, stderr, case): + self.exit_code = exit_code + self.stdout = stdout + self.stderr = stderr + self.case = case + + def ReportOutcome(self, long_format): + name = self.case.GetName() + mode = self.case.GetMode() + if self.HasUnexpectedOutcome(): + if self.case.IsNegative(): + print "=== %s was expected to fail in %s, but didn't ===" % (name, mode) + else: + if long_format: + print "=== %s failed in %s ===" % (name, mode) + else: + print "%s in %s: " % (name, mode) + out = self.stdout.strip() + if len(out) > 0: + print "--- output ---" + print out + err = self.stderr.strip() + if len(err) > 0: + print "--- errors ---" + print err + if long_format: + print "===" + elif self.case.IsNegative(): + print "%s failed in %s as expected" % (name, mode) + else: + print "%s passed in %s" % (name, mode) + + def HasFailed(self): + return self.exit_code != 0 + + def HasUnexpectedOutcome(self): + if self.case.IsNegative(): + return not self.HasFailed() + else: + return self.HasFailed() + + +class TestCase(object): + + def __init__(self, suite, name, full_path, strict_mode): + self.suite = suite + self.name = name + self.full_path = full_path + self.strict_mode = strict_mode + f = open(self.full_path) + self.contents = f.read() + f.close() + testRecord = parseTestRecord(self.contents, name) + self.test = testRecord["test"] + del testRecord["test"] + del testRecord["header"] + del testRecord["commentary"] + self.testRecord = testRecord; + + + def GetName(self): + return path.join(*self.name) + + def GetMode(self): + if self.strict_mode: + return "strict mode" + else: + return "non-strict mode" + + def GetPath(self): + return self.name + + def NegateResult(self): + if self.IsNegative(): + del self.testRecord['negative'] + else: + self.testRecord['negative'] = "Some failure"; + + def IsNegative(self): + return 'negative' in self.testRecord + + def IsOnlyStrict(self): + return 'onlyStrict' in self.testRecord + + def IsNoStrict(self): + return 'noStrict' in self.testRecord + + def GetSource(self): + # "var testDescrip = " + str(self.testRecord) + ';\n\n' + \ + source = self.suite.GetInclude("cth.js") + \ + self.suite.GetInclude("sta.js") + \ + self.suite.GetInclude("ed.js") + \ + self.suite.GetInclude("testBuiltInObject.js") + \ + self.suite.GetInclude("testIntl.js") + \ + self.test + '\n' + + if self.strict_mode: + source = '"use strict";\nvar strict_mode = true;\n' + source + else: + source = "var strict_mode = false; \n" + source + return source + + def InstantiateTemplate(self, template, params): + def GetParameter(match): + key = match.group(1) + return params.get(key, match.group(0)) + return placeHolderPattern.sub(GetParameter, template) + + def Execute(self, command): + if IsWindows(): + args = '%s' % command + else: + args = command.split(" ") + stdout = TempFile(prefix="test262-out-") + stderr = TempFile(prefix="test262-err-") + try: + logging.info("exec: %s", str(args)) + process = subprocess.Popen( + args, + shell = IsWindows(), + stdout = stdout.fd, + stderr = stderr.fd + ) + code = process.wait() + out = stdout.Read() + err = stderr.Read() + finally: + stdout.Dispose() + stderr.Dispose() + return (code, out, err) + + def RunTestIn(self, command_template, tmp): + tmp.Write(self.GetSource()) + tmp.Close() + command = self.InstantiateTemplate(command_template, { + 'path': tmp.name + }) + (code, out, err) = self.Execute(command) + return TestResult(code, out, err, self) + + def Run(self, command_template): + tmp = TempFile(suffix=".js", prefix="test262-", text=True) + try: + result = self.RunTestIn(command_template, tmp) + finally: + tmp.Dispose() + return result + + def Print(self): + print self.GetSource() + + +class ProgressIndicator(object): + + def __init__(self, count): + self.count = count + self.succeeded = 0 + self.failed = 0 + self.failed_tests = [] + + def HasRun(self, result): + result.ReportOutcome(True) + if result.HasUnexpectedOutcome(): + self.failed += 1 + self.failed_tests.append(result) + else: + self.succeeded += 1 + + +def MakePlural(n): + if (n == 1): + return (n, "") + else: + return (n, "s") + + +class TestSuite(object): + + def __init__(self, root, strict_only, non_strict_only, unmarked_default, load_expectations): + # TODO: derive from packagerConfig.py + self.test_root = path.join(root, 'test', 'suite') + self.lib_root = path.join(root, 'test', 'harness') + self.strict_only = strict_only + self.non_strict_only = non_strict_only + self.unmarked_default = unmarked_default + self.include_cache = { } + self.expectations = TestExpectations(load_expectations) + + def Validate(self): + if not path.exists(self.test_root): + ReportError("No test repository found") + if not path.exists(self.lib_root): + ReportError("No test library found") + + def IsHidden(self, path): + return path.startswith('.') or path == 'CVS' + + def IsTestCase(self, path): + return path.endswith('.js') + + def ShouldRun(self, rel_path, tests): + if len(tests) == 0: + return True + for test in tests: + if test in rel_path: + return True + return False + + def GetInclude(self, name): + if not name in self.include_cache: + static = path.join(self.lib_root, name) + if path.exists(static): + f = open(static) + contents = stripHeader(f.read()) + contents = re.sub(r'\r\n', '\n', contents) + self.include_cache[name] = contents + "\n" + f.close() + else: + ReportError("Can't find: " + static) + return self.include_cache[name] + + def EnumerateTests(self, tests): + logging.info("Listing tests in %s", self.test_root) + cases = [] + for root, dirs, files in os.walk(self.test_root): + for f in [x for x in dirs if self.IsHidden(x)]: + dirs.remove(f) + dirs.sort() + for f in sorted(files): + if self.IsTestCase(f): + full_path = path.join(root, f) + if full_path.startswith(self.test_root): + rel_path = full_path[len(self.test_root)+1:] + else: + logging.warning("Unexpected path %s", full_path) + rel_path = full_path + if self.ShouldRun(rel_path, tests) and not rel_path.startswith("intl402" + os.sep): + basename = path.basename(full_path)[:-3] + name = rel_path.split(path.sep)[:-1] + [basename] + if EXCLUDE_LIST.count(basename) >= 1 or self.expectations.testsToSkip.count(basename) >= 1: + print 'Excluded: ' + basename + else: + if not self.non_strict_only: + strict_case = TestCase(self, name, full_path, True) + if self.expectations.failingTests.count(basename) >= 1: + strict_case.NegateResult() + if not strict_case.IsNoStrict(): + if strict_case.IsOnlyStrict() or \ + self.unmarked_default in ['both', 'strict']: + cases.append(strict_case) + if not self.strict_only: + non_strict_case = TestCase(self, name, full_path, False) + if self.expectations.failingTests.count(basename) >= 1: + non_strict_case.NegateResult() + if not non_strict_case.IsOnlyStrict(): + if non_strict_case.IsNoStrict() or \ + self.unmarked_default in ['both', 'non_strict']: + cases.append(non_strict_case) + logging.info("Done listing tests") + return cases + + def PrintSummary(self, progress): + print + print "=== Summary ===" + count = progress.count + succeeded = progress.succeeded + failed = progress.failed + print " - Ran %i test%s" % MakePlural(count) + if progress.failed == 0: + print " - All tests succeeded" + else: + percent = ((100.0 * succeeded) / count,) + print " - Passed %i test%s (%.1f%%)" % (MakePlural(succeeded) + percent) + percent = ((100.0 * failed) / count,) + print " - Failed %i test%s (%.1f%%)" % (MakePlural(failed) + percent) + positive = [c for c in progress.failed_tests if not c.case.IsNegative()] + negative = [c for c in progress.failed_tests if c.case.IsNegative()] + if len(positive) > 0: + print + print "Failed tests" + for result in positive: + print " %s in %s" % (result.case.GetName(), result.case.GetMode()) + if len(negative) > 0: + print + print "Expected to fail but passed ---" + for result in negative: + print " %s in %s" % (result.case.GetName(), result.case.GetMode()) + + def PrintFailureOutput(self, progress): + for result in progress.failed_tests: + print + result.ReportOutcome(False) + + def Run(self, command_template, tests, print_summary, full_summary, parallel, update_expectations): + if not "{{path}}" in command_template: + command_template += " {{path}}" + cases = self.EnumerateTests(tests) + if len(cases) == 0: + ReportError("No tests to run") + progress = ProgressIndicator(len(cases)) + + if parallel: + pool = multiprocessing.Pool(processes=multiprocessing.cpu_count(), initializer=initWorkerProcess) + results = pool.imap_unordered(func=runTestVarArgs, iterable=[(case, command_template) for case in cases], chunksize=multiprocessing.cpu_count() * 8) + for result in results: + progress.HasRun(result) + else: + for case in cases: + result = case.Run(command_template) + progress.HasRun(result) + if print_summary: + self.PrintSummary(progress) + if full_summary: + self.PrintFailureOutput(progress) + else: + print + print "Use --full-summary to see output from failed tests" + print + if update_expectations: + self.expectations.update(progress) + + def Print(self, tests): + cases = self.EnumerateTests(tests) + if len(cases) > 0: + cases[0].Print() + + +def Main(): + # Some date tests rely on being run in pacific time. + # Uncomment the next line for more logging info. + #logging.basicConfig(level=logging.DEBUG) + os.environ["TZ"] = "PST8PDT" + parser = BuildOptions() + (options, args) = parser.parse_args() + ValidateOptions(options) + test_suite = TestSuite(options.tests, + options.strict_only, + options.non_strict_only, + options.unmarked_default, + options.with_test_expectations) + test_suite.Validate() + if options.cat: + test_suite.Print(args) + else: + test_suite.Run(options.command, args, + options.summary or options.full_summary, + options.full_summary, + options.parallel, + options.update_expectations) + + +if __name__ == '__main__': + try: + Main() + sys.exit(0) + except Test262Error, e: + print "Error: %s" % e.message + sys.exit(1) diff --git a/tests/manual/v4/tests.pro b/tests/manual/v4/tests.pro new file mode 100644 index 0000000000..5a0a97dcd3 --- /dev/null +++ b/tests/manual/v4/tests.pro @@ -0,0 +1,15 @@ +TEMPLATE = aux + +TESTSCRIPT=$$PWD/test262.py +V4CMD = v4 + +checktarget.target = check +checktarget.commands = python $$TESTSCRIPT --command=$$V4CMD --parallel --with-test-expectations --update-expectations +checktarget.depends = all +QMAKE_EXTRA_TARGETS += checktarget + +checkmothtarget.target = check-interpreter +checkmothtarget.commands = python $$TESTSCRIPT --command=\"$$V4CMD --interpret\" --parallel --with-test-expectations +checkmothtarget.depends = all +QMAKE_EXTRA_TARGETS += checkmothtarget + diff --git a/tests/manual/v4/typeof.1.js b/tests/manual/v4/typeof.1.js new file mode 100644 index 0000000000..a24cfc6169 --- /dev/null +++ b/tests/manual/v4/typeof.1.js @@ -0,0 +1,12 @@ + +var o = { + number: 123, + fun: function() {}, + string: "ciao", + array: [], +} + +print(typeof o) +print(typeof o.number) +print(typeof o.fun) +print(typeof o.array) diff --git a/tests/manual/v4/v8-bench.js b/tests/manual/v4/v8-bench.js new file mode 100644 index 0000000000..baa6274136 --- /dev/null +++ b/tests/manual/v4/v8-bench.js @@ -0,0 +1,11591 @@ +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// Simple framework for running the benchmark suites and +// computing a score based on the timing measurements. + +if (typeof print == "undefined") + + print = console.log; + +// A benchmark has a name (string) and a function that will be run to +// do the performance measurement. The optional setup and tearDown +// arguments are functions that will be invoked before and after +// running the benchmark, but the running time of these functions will +// not be accounted for in the benchmark score. +function Benchmark(name, run, setup, tearDown) { + this.name = name; + this.run = run; + this.Setup = setup ? setup : function() { }; + this.TearDown = tearDown ? tearDown : function() { }; +} + + +// Benchmark results hold the benchmark and the measured time used to +// run the benchmark. The benchmark score is computed later once a +// full benchmark suite has run to completion. +function BenchmarkResult(benchmark, time) { + this.benchmark = benchmark; + this.time = time; +} + + +// Automatically convert results to numbers. Used by the geometric +// mean computation. +BenchmarkResult.prototype.valueOf = function() { + return this.time; +} + + +// Suites of benchmarks consist of a name and the set of benchmarks in +// addition to the reference timing that the final score will be based +// on. This way, all scores are relative to a reference run and higher +// scores implies better performance. +function BenchmarkSuite(name, reference, benchmarks) { + this.name = name; + this.reference = reference; + this.benchmarks = benchmarks; + BenchmarkSuite.suites.push(this); +} + + +// Keep track of all declared benchmark suites. +BenchmarkSuite.suites = []; + + +// Scores are not comparable across versions. Bump the version if +// you're making changes that will affect that scores, e.g. if you add +// a new benchmark or change an existing one. +BenchmarkSuite.version = '7'; + + +// To make the benchmark results predictable, we replace Math.random +// with a 100% deterministic alternative. +Math.random = (function() { + var seed = 49734321; + return function() { + // Robert Jenkins' 32 bit integer hash function. + seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; + seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; + seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; + seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; + seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff; + seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff; + return (seed & 0xfffffff) / 0x10000000; + }; +})(); + + +// Runs all registered benchmark suites and optionally yields between +// each individual benchmark to avoid running for too long in the +// context of browsers. Once done, the final score is reported to the +// runner. +BenchmarkSuite.RunSuites = function(runner) { + var continuation = null; + var suites = BenchmarkSuite.suites; + var length = suites.length; + BenchmarkSuite.scores = []; + var index = 0; + function RunStep() { + while (continuation || index < length) { + if (continuation) { + continuation = continuation(); + } else { + var suite = suites[index++]; + if (runner.NotifyStart) runner.NotifyStart(suite.name); + continuation = suite.RunStep(runner); + } + if (continuation && typeof window != 'undefined' && window.setTimeout) { + window.setTimeout(RunStep, 25); + return; + } + } + if (runner.NotifyScore) { + var score = BenchmarkSuite.GeometricMean(BenchmarkSuite.scores); + var formatted = BenchmarkSuite.FormatScore(100 * score); + runner.NotifyScore(formatted); + } + } + RunStep(); +} + + +// Counts the total number of registered benchmarks. Useful for +// showing progress as a percentage. +BenchmarkSuite.CountBenchmarks = function() { + var result = 0; + var suites = BenchmarkSuite.suites; + for (var i = 0; i < suites.length; i++) { + result += suites[i].benchmarks.length; + } + return result; +} + + +// Computes the geometric mean of a set of numbers. +BenchmarkSuite.GeometricMean = function(numbers) { + var log = 0; + for (var i = 0; i < numbers.length; i++) { + log += Math.log(numbers[i]); + } + return Math.pow(Math.E, log / numbers.length); +} + + +// Converts a score value to a string with at least three significant +// digits. +BenchmarkSuite.FormatScore = function(value) { + if (value > 100) { + return value.toFixed(0); + } else { + return value.toPrecision(3); + } +} + +// Notifies the runner that we're done running a single benchmark in +// the benchmark suite. This can be useful to report progress. +BenchmarkSuite.prototype.NotifyStep = function(result) { + this.results.push(result); + if (this.runner.NotifyStep) this.runner.NotifyStep(result.benchmark.name); +} + + +// Notifies the runner that we're done with running a suite and that +// we have a result which can be reported to the user if needed. +BenchmarkSuite.prototype.NotifyResult = function() { + var mean = BenchmarkSuite.GeometricMean(this.results); + var score = this.reference / mean; + BenchmarkSuite.scores.push(score); + if (this.runner.NotifyResult) { + var formatted = BenchmarkSuite.FormatScore(100 * score); + this.runner.NotifyResult(this.name, formatted); + } +} + + +// Notifies the runner that running a benchmark resulted in an error. +BenchmarkSuite.prototype.NotifyError = function(error) { + if (this.runner.NotifyError) { + this.runner.NotifyError(this.name, error); + } + if (this.runner.NotifyStep) { + this.runner.NotifyStep(this.name); + } +} + + +// Runs a single benchmark for at least a second and computes the +// average time it takes to run a single iteration. +BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark, data) { + function Measure(data) { + var elapsed = 0; + var start = new Date(); + for (var n = 0; elapsed < 1000; n++) { + benchmark.run(); + elapsed = new Date() - start; + } + if (data != null) { + data.runs += n; + data.elapsed += elapsed; + } + } + + if (data == null) { + // Measure the benchmark once for warm up and throw the result + // away. Return a fresh data object. + Measure(null); + return { runs: 0, elapsed: 0 }; + } else { + Measure(data); + // If we've run too few iterations, we continue for another second. + if (data.runs < 32) return data; + var usec = (data.elapsed * 1000) / data.runs; + this.NotifyStep(new BenchmarkResult(benchmark, usec)); + return null; + } +} + + +// This function starts running a suite, but stops between each +// individual benchmark in the suite and returns a continuation +// function which can be invoked to run the next benchmark. Once the +// last benchmark has been executed, null is returned. +BenchmarkSuite.prototype.RunStep = function(runner) { + this.results = []; + this.runner = runner; + var length = this.benchmarks.length; + var index = 0; + var suite = this; + var data; + + // Run the setup, the actual benchmark, and the tear down in three + // separate steps to allow the framework to yield between any of the + // steps. + + function RunNextSetup() { + if (index < length) { + try { + suite.benchmarks[index].Setup(); + } catch (e) { + suite.NotifyError(e); + return null; + } + return RunNextBenchmark; + } + suite.NotifyResult(); + return null; + } + + function RunNextBenchmark() { + try { + data = suite.RunSingleBenchmark(suite.benchmarks[index], data); + } catch (e) { + suite.NotifyError(e); + return null; + } + // If data is null, we're done with this benchmark. + return (data == null) ? RunNextTearDown : RunNextBenchmark(); + } + + function RunNextTearDown() { + try { + suite.benchmarks[index++].TearDown(); + } catch (e) { + suite.NotifyError(e); + return null; + } + return RunNextSetup; + } + + // Start out running the setup. + return RunNextSetup(); +} +// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +// This is a JavaScript implementation of the Richards +// benchmark from: +// +// http://www.cl.cam.ac.uk/~mr10/Bench.html +// +// The benchmark was originally implemented in BCPL by +// Martin Richards. + + +var Richards = new BenchmarkSuite('Richards', 35302, [ + new Benchmark("Richards", runRichards) +]); + + +/** + * The Richards benchmark simulates the task dispatcher of an + * operating system. + **/ +function runRichards() { + var scheduler = new Scheduler(); + scheduler.addIdleTask(ID_IDLE, 0, null, COUNT); + + var queue = new Packet(null, ID_WORKER, KIND_WORK); + queue = new Packet(queue, ID_WORKER, KIND_WORK); + scheduler.addWorkerTask(ID_WORKER, 1000, queue); + + queue = new Packet(null, ID_DEVICE_A, KIND_DEVICE); + queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE); + queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE); + scheduler.addHandlerTask(ID_HANDLER_A, 2000, queue); + + queue = new Packet(null, ID_DEVICE_B, KIND_DEVICE); + queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE); + queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE); + scheduler.addHandlerTask(ID_HANDLER_B, 3000, queue); + + scheduler.addDeviceTask(ID_DEVICE_A, 4000, null); + + scheduler.addDeviceTask(ID_DEVICE_B, 5000, null); + + scheduler.schedule(); + + if (scheduler.queueCount != EXPECTED_QUEUE_COUNT || + scheduler.holdCount != EXPECTED_HOLD_COUNT) { + var msg = + "Error during execution: queueCount = " + scheduler.queueCount + + ", holdCount = " + scheduler.holdCount + "."; + throw new Error(msg); + } +} + +var COUNT = 1000; + +/** + * These two constants specify how many times a packet is queued and + * how many times a task is put on hold in a correct run of richards. + * They don't have any meaning a such but are characteristic of a + * correct run so if the actual queue or hold count is different from + * the expected there must be a bug in the implementation. + **/ +var EXPECTED_QUEUE_COUNT = 2322; +var EXPECTED_HOLD_COUNT = 928; + + +/** + * A scheduler can be used to schedule a set of tasks based on their relative + * priorities. Scheduling is done by maintaining a list of task control blocks + * which holds tasks and the data queue they are processing. + * @constructor + */ +function Scheduler() { + this.queueCount = 0; + this.holdCount = 0; + this.blocks = new Array(NUMBER_OF_IDS); + this.list = null; + this.currentTcb = null; + this.currentId = null; +} + +var ID_IDLE = 0; +var ID_WORKER = 1; +var ID_HANDLER_A = 2; +var ID_HANDLER_B = 3; +var ID_DEVICE_A = 4; +var ID_DEVICE_B = 5; +var NUMBER_OF_IDS = 6; + +var KIND_DEVICE = 0; +var KIND_WORK = 1; + +/** + * Add an idle task to this scheduler. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + * @param {int} count the number of times to schedule the task + */ +Scheduler.prototype.addIdleTask = function (id, priority, queue, count) { + this.addRunningTask(id, priority, queue, new IdleTask(this, 1, count)); +}; + +/** + * Add a work task to this scheduler. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + */ +Scheduler.prototype.addWorkerTask = function (id, priority, queue) { + this.addTask(id, priority, queue, new WorkerTask(this, ID_HANDLER_A, 0)); +}; + +/** + * Add a handler task to this scheduler. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + */ +Scheduler.prototype.addHandlerTask = function (id, priority, queue) { + this.addTask(id, priority, queue, new HandlerTask(this)); +}; + +/** + * Add a handler task to this scheduler. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + */ +Scheduler.prototype.addDeviceTask = function (id, priority, queue) { + this.addTask(id, priority, queue, new DeviceTask(this)) +}; + +/** + * Add the specified task and mark it as running. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + * @param {Task} task the task to add + */ +Scheduler.prototype.addRunningTask = function (id, priority, queue, task) { + this.addTask(id, priority, queue, task); + this.currentTcb.setRunning(); +}; + +/** + * Add the specified task to this scheduler. + * @param {int} id the identity of the task + * @param {int} priority the task's priority + * @param {Packet} queue the queue of work to be processed by the task + * @param {Task} task the task to add + */ +Scheduler.prototype.addTask = function (id, priority, queue, task) { + this.currentTcb = new TaskControlBlock(this.list, id, priority, queue, task); + this.list = this.currentTcb; + this.blocks[id] = this.currentTcb; +}; + +/** + * Execute the tasks managed by this scheduler. + */ +Scheduler.prototype.schedule = function () { + this.currentTcb = this.list; + while (this.currentTcb != null) { + if (this.currentTcb.isHeldOrSuspended()) { + this.currentTcb = this.currentTcb.link; + } else { + this.currentId = this.currentTcb.id; + this.currentTcb = this.currentTcb.run(); + } + } +}; + +/** + * Release a task that is currently blocked and return the next block to run. + * @param {int} id the id of the task to suspend + */ +Scheduler.prototype.release = function (id) { + var tcb = this.blocks[id]; + if (tcb == null) return tcb; + tcb.markAsNotHeld(); + if (tcb.priority > this.currentTcb.priority) { + return tcb; + } else { + return this.currentTcb; + } +}; + +/** + * Block the currently executing task and return the next task control block + * to run. The blocked task will not be made runnable until it is explicitly + * released, even if new work is added to it. + */ +Scheduler.prototype.holdCurrent = function () { + this.holdCount++; + this.currentTcb.markAsHeld(); + return this.currentTcb.link; +}; + +/** + * Suspend the currently executing task and return the next task control block + * to run. If new work is added to the suspended task it will be made runnable. + */ +Scheduler.prototype.suspendCurrent = function () { + this.currentTcb.markAsSuspended(); + return this.currentTcb; +}; + +/** + * Add the specified packet to the end of the worklist used by the task + * associated with the packet and make the task runnable if it is currently + * suspended. + * @param {Packet} packet the packet to add + */ +Scheduler.prototype.queue = function (packet) { + var t = this.blocks[packet.id]; + if (t == null) return t; + this.queueCount++; + packet.link = null; + packet.id = this.currentId; + return t.checkPriorityAdd(this.currentTcb, packet); +}; + +/** + * A task control block manages a task and the queue of work packages associated + * with it. + * @param {TaskControlBlock} link the preceding block in the linked block list + * @param {int} id the id of this block + * @param {int} priority the priority of this block + * @param {Packet} queue the queue of packages to be processed by the task + * @param {Task} task the task + * @constructor + */ +function TaskControlBlock(link, id, priority, queue, task) { + this.link = link; + this.id = id; + this.priority = priority; + this.queue = queue; + this.task = task; + if (queue == null) { + this.state = STATE_SUSPENDED; + } else { + this.state = STATE_SUSPENDED_RUNNABLE; + } +} + +/** + * The task is running and is currently scheduled. + */ +var STATE_RUNNING = 0; + +/** + * The task has packets left to process. + */ +var STATE_RUNNABLE = 1; + +/** + * The task is not currently running. The task is not blocked as such and may +* be started by the scheduler. + */ +var STATE_SUSPENDED = 2; + +/** + * The task is blocked and cannot be run until it is explicitly released. + */ +var STATE_HELD = 4; + +var STATE_SUSPENDED_RUNNABLE = STATE_SUSPENDED | STATE_RUNNABLE; +var STATE_NOT_HELD = ~STATE_HELD; + +TaskControlBlock.prototype.setRunning = function () { + this.state = STATE_RUNNING; +}; + +TaskControlBlock.prototype.markAsNotHeld = function () { + this.state = this.state & STATE_NOT_HELD; +}; + +TaskControlBlock.prototype.markAsHeld = function () { + this.state = this.state | STATE_HELD; +}; + +TaskControlBlock.prototype.isHeldOrSuspended = function () { + return (this.state & STATE_HELD) != 0 || (this.state == STATE_SUSPENDED); +}; + +TaskControlBlock.prototype.markAsSuspended = function () { + this.state = this.state | STATE_SUSPENDED; +}; + +TaskControlBlock.prototype.markAsRunnable = function () { + this.state = this.state | STATE_RUNNABLE; +}; + +/** + * Runs this task, if it is ready to be run, and returns the next task to run. + */ +TaskControlBlock.prototype.run = function () { + var packet; + if (this.state == STATE_SUSPENDED_RUNNABLE) { + packet = this.queue; + this.queue = packet.link; + if (this.queue == null) { + this.state = STATE_RUNNING; + } else { + this.state = STATE_RUNNABLE; + } + } else { + packet = null; + } + return this.task.run(packet); +}; + +/** + * Adds a packet to the worklist of this block's task, marks this as runnable if + * necessary, and returns the next runnable object to run (the one + * with the highest priority). + */ +TaskControlBlock.prototype.checkPriorityAdd = function (task, packet) { + if (this.queue == null) { + this.queue = packet; + this.markAsRunnable(); + if (this.priority > task.priority) return this; + } else { + this.queue = packet.addTo(this.queue); + } + return task; +}; + +TaskControlBlock.prototype.toString = function () { + return "tcb { " + this.task + "@" + this.state + " }"; +}; + +/** + * An idle task doesn't do any work itself but cycles control between the two + * device tasks. + * @param {Scheduler} scheduler the scheduler that manages this task + * @param {int} v1 a seed value that controls how the device tasks are scheduled + * @param {int} count the number of times this task should be scheduled + * @constructor + */ +function IdleTask(scheduler, v1, count) { + this.scheduler = scheduler; + this.v1 = v1; + this.count = count; +} + +IdleTask.prototype.run = function (packet) { + this.count--; + if (this.count == 0) return this.scheduler.holdCurrent(); + if ((this.v1 & 1) == 0) { + this.v1 = this.v1 >> 1; + return this.scheduler.release(ID_DEVICE_A); + } else { + this.v1 = (this.v1 >> 1) ^ 0xD008; + return this.scheduler.release(ID_DEVICE_B); + } +}; + +IdleTask.prototype.toString = function () { + return "IdleTask" +}; + +/** + * A task that suspends itself after each time it has been run to simulate + * waiting for data from an external device. + * @param {Scheduler} scheduler the scheduler that manages this task + * @constructor + */ +function DeviceTask(scheduler) { + this.scheduler = scheduler; + this.v1 = null; +} + +DeviceTask.prototype.run = function (packet) { + if (packet == null) { + if (this.v1 == null) return this.scheduler.suspendCurrent(); + var v = this.v1; + this.v1 = null; + return this.scheduler.queue(v); + } else { + this.v1 = packet; + return this.scheduler.holdCurrent(); + } +}; + +DeviceTask.prototype.toString = function () { + return "DeviceTask"; +}; + +/** + * A task that manipulates work packets. + * @param {Scheduler} scheduler the scheduler that manages this task + * @param {int} v1 a seed used to specify how work packets are manipulated + * @param {int} v2 another seed used to specify how work packets are manipulated + * @constructor + */ +function WorkerTask(scheduler, v1, v2) { + this.scheduler = scheduler; + this.v1 = v1; + this.v2 = v2; +} + +WorkerTask.prototype.run = function (packet) { + if (packet == null) { + return this.scheduler.suspendCurrent(); + } else { + if (this.v1 == ID_HANDLER_A) { + this.v1 = ID_HANDLER_B; + } else { + this.v1 = ID_HANDLER_A; + } + packet.id = this.v1; + packet.a1 = 0; + for (var i = 0; i < DATA_SIZE; i++) { + this.v2++; + if (this.v2 > 26) this.v2 = 1; + packet.a2[i] = this.v2; + } + return this.scheduler.queue(packet); + } +}; + +WorkerTask.prototype.toString = function () { + return "WorkerTask"; +}; + +/** + * A task that manipulates work packets and then suspends itself. + * @param {Scheduler} scheduler the scheduler that manages this task + * @constructor + */ +function HandlerTask(scheduler) { + this.scheduler = scheduler; + this.v1 = null; + this.v2 = null; +} + +HandlerTask.prototype.run = function (packet) { + if (packet != null) { + if (packet.kind == KIND_WORK) { + this.v1 = packet.addTo(this.v1); + } else { + this.v2 = packet.addTo(this.v2); + } + } + if (this.v1 != null) { + var count = this.v1.a1; + var v; + if (count < DATA_SIZE) { + if (this.v2 != null) { + v = this.v2; + this.v2 = this.v2.link; + v.a1 = this.v1.a2[count]; + this.v1.a1 = count + 1; + return this.scheduler.queue(v); + } + } else { + v = this.v1; + this.v1 = this.v1.link; + return this.scheduler.queue(v); + } + } + return this.scheduler.suspendCurrent(); +}; + +HandlerTask.prototype.toString = function () { + return "HandlerTask"; +}; + +/* --- * + * P a c k e t + * --- */ + +var DATA_SIZE = 4; + +/** + * A simple package of data that is manipulated by the tasks. The exact layout + * of the payload data carried by a packet is not importaint, and neither is the + * nature of the work performed on packets by the tasks. + * + * Besides carrying data, packets form linked lists and are hence used both as + * data and worklists. + * @param {Packet} link the tail of the linked list of packets + * @param {int} id an ID for this packet + * @param {int} kind the type of this packet + * @constructor + */ +function Packet(link, id, kind) { + this.link = link; + this.id = id; + this.kind = kind; + this.a1 = 0; + this.a2 = new Array(DATA_SIZE); +} + +/** + * Add this packet to the end of a worklist, and return the worklist. + * @param {Packet} queue the worklist to add this packet to + */ +Packet.prototype.addTo = function (queue) { + this.link = null; + if (queue == null) return this; + var peek, next = queue; + while ((peek = next.link) != null) + next = peek; + next.link = this; + return queue; +}; + +Packet.prototype.toString = function () { + return "Packet"; +}; +// Copyright 2008 the V8 project authors. All rights reserved. +// Copyright 1996 John Maloney and Mario Wolczko. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +// This implementation of the DeltaBlue benchmark is derived +// from the Smalltalk implementation by John Maloney and Mario +// Wolczko. Some parts have been translated directly, whereas +// others have been modified more aggresively to make it feel +// more like a JavaScript program. + + +var DeltaBlue = new BenchmarkSuite('DeltaBlue', 66118, [ + new Benchmark('DeltaBlue', deltaBlue) +]); + + +/** + * A JavaScript implementation of the DeltaBlue constraint-solving + * algorithm, as described in: + * + * "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver" + * Bjorn N. Freeman-Benson and John Maloney + * January 1990 Communications of the ACM, + * also available as University of Washington TR 89-08-06. + * + * Beware: this benchmark is written in a grotesque style where + * the constraint model is built by side-effects from constructors. + * I've kept it this way to avoid deviating too much from the original + * implementation. + */ + + +/* --- O b j e c t M o d e l --- */ + +Object.prototype.inheritsFrom = function (shuper) { + function Inheriter() { } + Inheriter.prototype = shuper.prototype; + this.prototype = new Inheriter(); + this.superConstructor = shuper; +} + +function OrderedCollection() { + this.elms = new Array(); +} + +OrderedCollection.prototype.add = function (elm) { + this.elms.push(elm); +} + +OrderedCollection.prototype.at = function (index) { + return this.elms[index]; +} + +OrderedCollection.prototype.size = function () { + return this.elms.length; +} + +OrderedCollection.prototype.removeFirst = function () { + return this.elms.pop(); +} + +OrderedCollection.prototype.remove = function (elm) { + var index = 0, skipped = 0; + for (var i = 0; i < this.elms.length; i++) { + var value = this.elms[i]; + if (value != elm) { + this.elms[index] = value; + index++; + } else { + skipped++; + } + } + for (var i = 0; i < skipped; i++) + this.elms.pop(); +} + +/* --- * + * S t r e n g t h + * --- */ + +/** + * Strengths are used to measure the relative importance of constraints. + * New strengths may be inserted in the strength hierarchy without + * disrupting current constraints. Strengths cannot be created outside + * this class, so pointer comparison can be used for value comparison. + */ +function Strength(strengthValue, name) { + this.strengthValue = strengthValue; + this.name = name; +} + +Strength.stronger = function (s1, s2) { + return s1.strengthValue < s2.strengthValue; +} + +Strength.weaker = function (s1, s2) { + return s1.strengthValue > s2.strengthValue; +} + +Strength.weakestOf = function (s1, s2) { + return this.weaker(s1, s2) ? s1 : s2; +} + +Strength.strongest = function (s1, s2) { + return this.stronger(s1, s2) ? s1 : s2; +} + +Strength.prototype.nextWeaker = function () { + switch (this.strengthValue) { + case 0: return Strength.WEAKEST; + case 1: return Strength.WEAK_DEFAULT; + case 2: return Strength.NORMAL; + case 3: return Strength.STRONG_DEFAULT; + case 4: return Strength.PREFERRED; + case 5: return Strength.REQUIRED; + } +} + +// Strength constants. +Strength.REQUIRED = new Strength(0, "required"); +Strength.STONG_PREFERRED = new Strength(1, "strongPreferred"); +Strength.PREFERRED = new Strength(2, "preferred"); +Strength.STRONG_DEFAULT = new Strength(3, "strongDefault"); +Strength.NORMAL = new Strength(4, "normal"); +Strength.WEAK_DEFAULT = new Strength(5, "weakDefault"); +Strength.WEAKEST = new Strength(6, "weakest"); + +/* --- * + * C o n s t r a i n t + * --- */ + +/** + * An abstract class representing a system-maintainable relationship + * (or "constraint") between a set of variables. A constraint supplies + * a strength instance variable; concrete subclasses provide a means + * of storing the constrained variables and other information required + * to represent a constraint. + */ +function Constraint(strength) { + this.strength = strength; +} + +/** + * Activate this constraint and attempt to satisfy it. + */ +Constraint.prototype.addConstraint = function () { + this.addToGraph(); + planner.incrementalAdd(this); +} + +/** + * Attempt to find a way to enforce this constraint. If successful, + * record the solution, perhaps modifying the current dataflow + * graph. Answer the constraint that this constraint overrides, if + * there is one, or nil, if there isn't. + * Assume: I am not already satisfied. + */ +Constraint.prototype.satisfy = function (mark) { + this.chooseMethod(mark); + if (!this.isSatisfied()) { + if (this.strength == Strength.REQUIRED) + alert("Could not satisfy a required constraint!"); + return null; + } + this.markInputs(mark); + var out = this.output(); + var overridden = out.determinedBy; + if (overridden != null) overridden.markUnsatisfied(); + out.determinedBy = this; + if (!planner.addPropagate(this, mark)) + alert("Cycle encountered"); + out.mark = mark; + return overridden; +} + +Constraint.prototype.destroyConstraint = function () { + if (this.isSatisfied()) planner.incrementalRemove(this); + else this.removeFromGraph(); +} + +/** + * Normal constraints are not input constraints. An input constraint + * is one that depends on external state, such as the mouse, the + * keybord, a clock, or some arbitraty piece of imperative code. + */ +Constraint.prototype.isInput = function () { + return false; +} + +/* --- * + * U n a r y C o n s t r a i n t + * --- */ + +/** + * Abstract superclass for constraints having a single possible output + * variable. + */ +function UnaryConstraint(v, strength) { + UnaryConstraint.superConstructor.call(this, strength); + this.myOutput = v; + this.satisfied = false; + this.addConstraint(); +} + +UnaryConstraint.inheritsFrom(Constraint); + +/** + * Adds this constraint to the constraint graph + */ +UnaryConstraint.prototype.addToGraph = function () { + this.myOutput.addConstraint(this); + this.satisfied = false; +} + +/** + * Decides if this constraint can be satisfied and records that + * decision. + */ +UnaryConstraint.prototype.chooseMethod = function (mark) { + this.satisfied = (this.myOutput.mark != mark) + && Strength.stronger(this.strength, this.myOutput.walkStrength); +} + +/** + * Returns true if this constraint is satisfied in the current solution. + */ +UnaryConstraint.prototype.isSatisfied = function () { + return this.satisfied; +} + +UnaryConstraint.prototype.markInputs = function (mark) { + // has no inputs +} + +/** + * Returns the current output variable. + */ +UnaryConstraint.prototype.output = function () { + return this.myOutput; +} + +/** + * Calculate the walkabout strength, the stay flag, and, if it is + * 'stay', the value for the current output of this constraint. Assume + * this constraint is satisfied. + */ +UnaryConstraint.prototype.recalculate = function () { + this.myOutput.walkStrength = this.strength; + this.myOutput.stay = !this.isInput(); + if (this.myOutput.stay) this.execute(); // Stay optimization +} + +/** + * Records that this constraint is unsatisfied + */ +UnaryConstraint.prototype.markUnsatisfied = function () { + this.satisfied = false; +} + +UnaryConstraint.prototype.inputsKnown = function () { + return true; +} + +UnaryConstraint.prototype.removeFromGraph = function () { + if (this.myOutput != null) this.myOutput.removeConstraint(this); + this.satisfied = false; +} + +/* --- * + * S t a y C o n s t r a i n t + * --- */ + +/** + * Variables that should, with some level of preference, stay the same. + * Planners may exploit the fact that instances, if satisfied, will not + * change their output during plan execution. This is called "stay + * optimization". + */ +function StayConstraint(v, str) { + StayConstraint.superConstructor.call(this, v, str); +} + +StayConstraint.inheritsFrom(UnaryConstraint); + +StayConstraint.prototype.execute = function () { + // Stay constraints do nothing +} + +/* --- * + * E d i t C o n s t r a i n t + * --- */ + +/** + * A unary input constraint used to mark a variable that the client + * wishes to change. + */ +function EditConstraint(v, str) { + EditConstraint.superConstructor.call(this, v, str); +} + +EditConstraint.inheritsFrom(UnaryConstraint); + +/** + * Edits indicate that a variable is to be changed by imperative code. + */ +EditConstraint.prototype.isInput = function () { + return true; +} + +EditConstraint.prototype.execute = function () { + // Edit constraints do nothing +} + +/* --- * + * B i n a r y C o n s t r a i n t + * --- */ + +var Direction = new Object(); +Direction.NONE = 0; +Direction.FORWARD = 1; +Direction.BACKWARD = -1; + +/** + * Abstract superclass for constraints having two possible output + * variables. + */ +function BinaryConstraint(var1, var2, strength) { + BinaryConstraint.superConstructor.call(this, strength); + this.v1 = var1; + this.v2 = var2; + this.direction = Direction.NONE; + this.addConstraint(); +} + +BinaryConstraint.inheritsFrom(Constraint); + +/** + * Decides if this constraint can be satisfied and which way it + * should flow based on the relative strength of the variables related, + * and record that decision. + */ +BinaryConstraint.prototype.chooseMethod = function (mark) { + if (this.v1.mark == mark) { + this.direction = (this.v2.mark != mark && Strength.stronger(this.strength, this.v2.walkStrength)) + ? Direction.FORWARD + : Direction.NONE; + } + if (this.v2.mark == mark) { + this.direction = (this.v1.mark != mark && Strength.stronger(this.strength, this.v1.walkStrength)) + ? Direction.BACKWARD + : Direction.NONE; + } + if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) { + this.direction = Strength.stronger(this.strength, this.v1.walkStrength) + ? Direction.BACKWARD + : Direction.NONE; + } else { + this.direction = Strength.stronger(this.strength, this.v2.walkStrength) + ? Direction.FORWARD + : Direction.BACKWARD + } +} + +/** + * Add this constraint to the constraint graph + */ +BinaryConstraint.prototype.addToGraph = function () { + this.v1.addConstraint(this); + this.v2.addConstraint(this); + this.direction = Direction.NONE; +} + +/** + * Answer true if this constraint is satisfied in the current solution. + */ +BinaryConstraint.prototype.isSatisfied = function () { + return this.direction != Direction.NONE; +} + +/** + * Mark the input variable with the given mark. + */ +BinaryConstraint.prototype.markInputs = function (mark) { + this.input().mark = mark; +} + +/** + * Returns the current input variable + */ +BinaryConstraint.prototype.input = function () { + return (this.direction == Direction.FORWARD) ? this.v1 : this.v2; +} + +/** + * Returns the current output variable + */ +BinaryConstraint.prototype.output = function () { + return (this.direction == Direction.FORWARD) ? this.v2 : this.v1; +} + +/** + * Calculate the walkabout strength, the stay flag, and, if it is + * 'stay', the value for the current output of this + * constraint. Assume this constraint is satisfied. + */ +BinaryConstraint.prototype.recalculate = function () { + var ihn = this.input(), out = this.output(); + out.walkStrength = Strength.weakestOf(this.strength, ihn.walkStrength); + out.stay = ihn.stay; + if (out.stay) this.execute(); +} + +/** + * Record the fact that this constraint is unsatisfied. + */ +BinaryConstraint.prototype.markUnsatisfied = function () { + this.direction = Direction.NONE; +} + +BinaryConstraint.prototype.inputsKnown = function (mark) { + var i = this.input(); + return i.mark == mark || i.stay || i.determinedBy == null; +} + +BinaryConstraint.prototype.removeFromGraph = function () { + if (this.v1 != null) this.v1.removeConstraint(this); + if (this.v2 != null) this.v2.removeConstraint(this); + this.direction = Direction.NONE; +} + +/* --- * + * S c a l e C o n s t r a i n t + * --- */ + +/** + * Relates two variables by the linear scaling relationship: "v2 = + * (v1 * scale) + offset". Either v1 or v2 may be changed to maintain + * this relationship but the scale factor and offset are considered + * read-only. + */ +function ScaleConstraint(src, scale, offset, dest, strength) { + this.direction = Direction.NONE; + this.scale = scale; + this.offset = offset; + ScaleConstraint.superConstructor.call(this, src, dest, strength); +} + +ScaleConstraint.inheritsFrom(BinaryConstraint); + +/** + * Adds this constraint to the constraint graph. + */ +ScaleConstraint.prototype.addToGraph = function () { + ScaleConstraint.superConstructor.prototype.addToGraph.call(this); + this.scale.addConstraint(this); + this.offset.addConstraint(this); +} + +ScaleConstraint.prototype.removeFromGraph = function () { + ScaleConstraint.superConstructor.prototype.removeFromGraph.call(this); + if (this.scale != null) this.scale.removeConstraint(this); + if (this.offset != null) this.offset.removeConstraint(this); +} + +ScaleConstraint.prototype.markInputs = function (mark) { + ScaleConstraint.superConstructor.prototype.markInputs.call(this, mark); + this.scale.mark = this.offset.mark = mark; +} + +/** + * Enforce this constraint. Assume that it is satisfied. + */ +ScaleConstraint.prototype.execute = function () { + if (this.direction == Direction.FORWARD) { + this.v2.value = this.v1.value * this.scale.value + this.offset.value; + } else { + this.v1.value = (this.v2.value - this.offset.value) / this.scale.value; + } +} + +/** + * Calculate the walkabout strength, the stay flag, and, if it is + * 'stay', the value for the current output of this constraint. Assume + * this constraint is satisfied. + */ +ScaleConstraint.prototype.recalculate = function () { + var ihn = this.input(), out = this.output(); + out.walkStrength = Strength.weakestOf(this.strength, ihn.walkStrength); + out.stay = ihn.stay && this.scale.stay && this.offset.stay; + if (out.stay) this.execute(); +} + +/* --- * + * E q u a l i t y C o n s t r a i n t + * --- */ + +/** + * Constrains two variables to have the same value. + */ +function EqualityConstraint(var1, var2, strength) { + EqualityConstraint.superConstructor.call(this, var1, var2, strength); +} + +EqualityConstraint.inheritsFrom(BinaryConstraint); + +/** + * Enforce this constraint. Assume that it is satisfied. + */ +EqualityConstraint.prototype.execute = function () { + this.output().value = this.input().value; +} + +/* --- * + * V a r i a b l e + * --- */ + +/** + * A constrained variable. In addition to its value, it maintain the + * structure of the constraint graph, the current dataflow graph, and + * various parameters of interest to the DeltaBlue incremental + * constraint solver. + **/ +function Variable(name, initialValue) { + this.value = initialValue || 0; + this.constraints = new OrderedCollection(); + this.determinedBy = null; + this.mark = 0; + this.walkStrength = Strength.WEAKEST; + this.stay = true; + this.name = name; +} + +/** + * Add the given constraint to the set of all constraints that refer + * this variable. + */ +Variable.prototype.addConstraint = function (c) { + this.constraints.add(c); +} + +/** + * Removes all traces of c from this variable. + */ +Variable.prototype.removeConstraint = function (c) { + this.constraints.remove(c); + if (this.determinedBy == c) this.determinedBy = null; +} + +/* --- * + * P l a n n e r + * --- */ + +/** + * The DeltaBlue planner + */ +function Planner() { + this.currentMark = 0; +} + +/** + * Attempt to satisfy the given constraint and, if successful, + * incrementally update the dataflow graph. Details: If satifying + * the constraint is successful, it may override a weaker constraint + * on its output. The algorithm attempts to resatisfy that + * constraint using some other method. This process is repeated + * until either a) it reaches a variable that was not previously + * determined by any constraint or b) it reaches a constraint that + * is too weak to be satisfied using any of its methods. The + * variables of constraints that have been processed are marked with + * a unique mark value so that we know where we've been. This allows + * the algorithm to avoid getting into an infinite loop even if the + * constraint graph has an inadvertent cycle. + */ +Planner.prototype.incrementalAdd = function (c) { + var mark = this.newMark(); + var overridden = c.satisfy(mark); + while (overridden != null) + overridden = overridden.satisfy(mark); +} + +/** + * Entry point for retracting a constraint. Remove the given + * constraint and incrementally update the dataflow graph. + * Details: Retracting the given constraint may allow some currently + * unsatisfiable downstream constraint to be satisfied. We therefore collect + * a list of unsatisfied downstream constraints and attempt to + * satisfy each one in turn. This list is traversed by constraint + * strength, strongest first, as a heuristic for avoiding + * unnecessarily adding and then overriding weak constraints. + * Assume: c is satisfied. + */ +Planner.prototype.incrementalRemove = function (c) { + var out = c.output(); + c.markUnsatisfied(); + c.removeFromGraph(); + var unsatisfied = this.removePropagateFrom(out); + var strength = Strength.REQUIRED; + do { + for (var i = 0; i < unsatisfied.size(); i++) { + var u = unsatisfied.at(i); + if (u.strength == strength) + this.incrementalAdd(u); + } + strength = strength.nextWeaker(); + } while (strength != Strength.WEAKEST); +} + +/** + * Select a previously unused mark value. + */ +Planner.prototype.newMark = function () { + return ++this.currentMark; +} + +/** + * Extract a plan for resatisfaction starting from the given source + * constraints, usually a set of input constraints. This method + * assumes that stay optimization is desired; the plan will contain + * only constraints whose output variables are not stay. Constraints + * that do no computation, such as stay and edit constraints, are + * not included in the plan. + * Details: The outputs of a constraint are marked when it is added + * to the plan under construction. A constraint may be appended to + * the plan when all its input variables are known. A variable is + * known if either a) the variable is marked (indicating that has + * been computed by a constraint appearing earlier in the plan), b) + * the variable is 'stay' (i.e. it is a constant at plan execution + * time), or c) the variable is not determined by any + * constraint. The last provision is for past states of history + * variables, which are not stay but which are also not computed by + * any constraint. + * Assume: sources are all satisfied. + */ +Planner.prototype.makePlan = function (sources) { + var mark = this.newMark(); + var plan = new Plan(); + var todo = sources; + while (todo.size() > 0) { + var c = todo.removeFirst(); + if (c.output().mark != mark && c.inputsKnown(mark)) { + plan.addConstraint(c); + c.output().mark = mark; + this.addConstraintsConsumingTo(c.output(), todo); + } + } + return plan; +} + +/** + * Extract a plan for resatisfying starting from the output of the + * given constraints, usually a set of input constraints. + */ +Planner.prototype.extractPlanFromConstraints = function (constraints) { + var sources = new OrderedCollection(); + for (var i = 0; i < constraints.size(); i++) { + var c = constraints.at(i); + if (c.isInput() && c.isSatisfied()) + // not in plan already and eligible for inclusion + sources.add(c); + } + return this.makePlan(sources); +} + +/** + * Recompute the walkabout strengths and stay flags of all variables + * downstream of the given constraint and recompute the actual + * values of all variables whose stay flag is true. If a cycle is + * detected, remove the given constraint and answer + * false. Otherwise, answer true. + * Details: Cycles are detected when a marked variable is + * encountered downstream of the given constraint. The sender is + * assumed to have marked the inputs of the given constraint with + * the given mark. Thus, encountering a marked node downstream of + * the output constraint means that there is a path from the + * constraint's output to one of its inputs. + */ +Planner.prototype.addPropagate = function (c, mark) { + var todo = new OrderedCollection(); + todo.add(c); + while (todo.size() > 0) { + var d = todo.removeFirst(); + if (d.output().mark == mark) { + this.incrementalRemove(c); + return false; + } + d.recalculate(); + this.addConstraintsConsumingTo(d.output(), todo); + } + return true; +} + + +/** + * Update the walkabout strengths and stay flags of all variables + * downstream of the given constraint. Answer a collection of + * unsatisfied constraints sorted in order of decreasing strength. + */ +Planner.prototype.removePropagateFrom = function (out) { + out.determinedBy = null; + out.walkStrength = Strength.WEAKEST; + out.stay = true; + var unsatisfied = new OrderedCollection(); + var todo = new OrderedCollection(); + todo.add(out); + while (todo.size() > 0) { + var v = todo.removeFirst(); + for (var i = 0; i < v.constraints.size(); i++) { + var c = v.constraints.at(i); + if (!c.isSatisfied()) + unsatisfied.add(c); + } + var determining = v.determinedBy; + for (var i = 0; i < v.constraints.size(); i++) { + var next = v.constraints.at(i); + if (next != determining && next.isSatisfied()) { + next.recalculate(); + todo.add(next.output()); + } + } + } + return unsatisfied; +} + +Planner.prototype.addConstraintsConsumingTo = function (v, coll) { + var determining = v.determinedBy; + var cc = v.constraints; + for (var i = 0; i < cc.size(); i++) { + var c = cc.at(i); + if (c != determining && c.isSatisfied()) + coll.add(c); + } +} + +/* --- * + * P l a n + * --- */ + +/** + * A Plan is an ordered list of constraints to be executed in sequence + * to resatisfy all currently satisfiable constraints in the face of + * one or more changing inputs. + */ +function Plan() { + this.v = new OrderedCollection(); +} + +Plan.prototype.addConstraint = function (c) { + this.v.add(c); +} + +Plan.prototype.size = function () { + return this.v.size(); +} + +Plan.prototype.constraintAt = function (index) { + return this.v.at(index); +} + +Plan.prototype.execute = function () { + for (var i = 0; i < this.size(); i++) { + var c = this.constraintAt(i); + c.execute(); + } +} + +/* --- * + * M a i n + * --- */ + +/** + * This is the standard DeltaBlue benchmark. A long chain of equality + * constraints is constructed with a stay constraint on one end. An + * edit constraint is then added to the opposite end and the time is + * measured for adding and removing this constraint, and extracting + * and executing a constraint satisfaction plan. There are two cases. + * In case 1, the added constraint is stronger than the stay + * constraint and values must propagate down the entire length of the + * chain. In case 2, the added constraint is weaker than the stay + * constraint so it cannot be accomodated. The cost in this case is, + * of course, very low. Typical situations lie somewhere between these + * two extremes. + */ +function chainTest(n) { + planner = new Planner(); + var prev = null, first = null, last = null; + + // Build chain of n equality constraints + for (var i = 0; i <= n; i++) { + var name = "v" + i; + var v = new Variable(name); + if (prev != null) + new EqualityConstraint(prev, v, Strength.REQUIRED); + if (i == 0) first = v; + if (i == n) last = v; + prev = v; + } + + new StayConstraint(last, Strength.STRONG_DEFAULT); + var edit = new EditConstraint(first, Strength.PREFERRED); + var edits = new OrderedCollection(); + edits.add(edit); + var plan = planner.extractPlanFromConstraints(edits); + for (var i = 0; i < 100; i++) { + first.value = i; + plan.execute(); + if (last.value != i) + alert("Chain test failed."); + } +} + +/** + * This test constructs a two sets of variables related to each + * other by a simple linear transformation (scale and offset). The + * time is measured to change a variable on either side of the + * mapping and to change the scale and offset factors. + */ +function projectionTest(n) { + planner = new Planner(); + var scale = new Variable("scale", 10); + var offset = new Variable("offset", 1000); + var src = null, dst = null; + + var dests = new OrderedCollection(); + for (var i = 0; i < n; i++) { + src = new Variable("src" + i, i); + dst = new Variable("dst" + i, i); + dests.add(dst); + new StayConstraint(src, Strength.NORMAL); + new ScaleConstraint(src, scale, offset, dst, Strength.REQUIRED); + } + + change(src, 17); + if (dst.value != 1170) alert("Projection 1 failed"); + change(dst, 1050); + if (src.value != 5) alert("Projection 2 failed"); + change(scale, 5); + for (var i = 0; i < n - 1; i++) { + if (dests.at(i).value != i * 5 + 1000) + alert("Projection 3 failed"); + } + change(offset, 2000); + for (var i = 0; i < n - 1; i++) { + if (dests.at(i).value != i * 5 + 2000) + alert("Projection 4 failed"); + } +} + +function change(v, newValue) { + var edit = new EditConstraint(v, Strength.PREFERRED); + var edits = new OrderedCollection(); + edits.add(edit); + var plan = planner.extractPlanFromConstraints(edits); + for (var i = 0; i < 10; i++) { + v.value = newValue; + plan.execute(); + } + edit.destroyConstraint(); +} + +// Global variable holding the current planner. +var planner = null; + +function deltaBlue() { + chainTest(100); + projectionTest(100); +} +/* + * Copyright (c) 2003-2005 Tom Wu + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF + * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * In addition, the following condition applies: + * + * All redistributions must retain an intact copy of this copyright notice + * and disclaimer. + */ + + +// The code has been adapted for use as a benchmark by Google. +var Crypto = new BenchmarkSuite('Crypto', 266181, [ + new Benchmark("Encrypt", encrypt), + new Benchmark("Decrypt", decrypt) +]); + + +// Basic JavaScript BN library - subset useful for RSA encryption. + +// Bits per digit +var dbits; +var BI_DB; +var BI_DM; +var BI_DV; + +var BI_FP; +var BI_FV; +var BI_F1; +var BI_F2; + +// JavaScript engine analysis +var canary = 0xdeadbeefcafe; +var j_lm = ((canary&0xffffff)==0xefcafe); + +// (public) Constructor +function BigInteger(a,b,c) { + this.array = new Array(); + if(a != null) + if("number" == typeof a) this.fromNumber(a,b,c); + else if(b == null && "string" != typeof a) this.fromString(a,256); + else this.fromString(a,b); +} + +// return new, unset BigInteger +function nbi() { return new BigInteger(null); } + +// am: Compute w_j += (x*this_i), propagate carries, +// c is initial carry, returns final carry. +// c < 3*dvalue, x < 2*dvalue, this_i < dvalue +// We need to select the fastest one that works in this environment. + +// am1: use a single mult and divide to get the high bits, +// max digit bits should be 26 because +// max internal value = 2*dvalue^2-2*dvalue (< 2^53) +function am1(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + while(--n >= 0) { + var v = x*this_array[i++]+w_array[j]+c; + c = Math.floor(v/0x4000000); + w_array[j++] = v&0x3ffffff; + } + return c; +} + +// am2 avoids a big mult-and-extract completely. +// Max digit bits should be <= 30 because we do bitwise ops +// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) +function am2(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + var xl = x&0x7fff, xh = x>>15; + while(--n >= 0) { + var l = this_array[i]&0x7fff; + var h = this_array[i++]>>15; + var m = xh*l+h*xl; + l = xl*l+((m&0x7fff)<<15)+w_array[j]+(c&0x3fffffff); + c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); + w_array[j++] = l&0x3fffffff; + } + return c; +} + +// Alternately, set max digit bits to 28 since some +// browsers slow down when dealing with 32-bit numbers. +function am3(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + + var xl = x&0x3fff, xh = x>>14; + while(--n >= 0) { + var l = this_array[i]&0x3fff; + var h = this_array[i++]>>14; + var m = xh*l+h*xl; + l = xl*l+((m&0x3fff)<<14)+w_array[j]+c; + c = (l>>28)+(m>>14)+xh*h; + w_array[j++] = l&0xfffffff; + } + return c; +} + +// This is tailored to VMs with 2-bit tagging. It makes sure +// that all the computations stay within the 29 bits available. +function am4(i,x,w,j,c,n) { + var this_array = this.array; + var w_array = w.array; + + var xl = x&0x1fff, xh = x>>13; + while(--n >= 0) { + var l = this_array[i]&0x1fff; + var h = this_array[i++]>>13; + var m = xh*l+h*xl; + l = xl*l+((m&0x1fff)<<13)+w_array[j]+c; + c = (l>>26)+(m>>13)+xh*h; + w_array[j++] = l&0x3ffffff; + } + return c; +} + +// am3/28 is best for SM, Rhino, but am4/26 is best for v8. +// Kestrel (Opera 9.5) gets its best result with am4/26. +// IE7 does 9% better with am3/28 than with am4/26. +// Firefox (SM) gets 10% faster with am3/28 than with am4/26. + +setupEngine = function(fn, bits) { + BigInteger.prototype.am = fn; + dbits = bits; + + BI_DB = dbits; + BI_DM = ((1<<dbits)-1); + BI_DV = (1<<dbits); + + BI_FP = 52; + BI_FV = Math.pow(2,BI_FP); + BI_F1 = BI_FP-dbits; + BI_F2 = 2*dbits-BI_FP; +} + + +// Digit conversions +var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz"; +var BI_RC = new Array(); +var rr,vv; +rr = "0".charCodeAt(0); +for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv; +rr = "a".charCodeAt(0); +for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; +rr = "A".charCodeAt(0); +for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv; + +function int2char(n) { return BI_RM.charAt(n); } +function intAt(s,i) { + var c = BI_RC[s.charCodeAt(i)]; + return (c==null)?-1:c; +} + +// (protected) copy this to r +function bnpCopyTo(r) { + var this_array = this.array; + var r_array = r.array; + + for(var i = this.t-1; i >= 0; --i) r_array[i] = this_array[i]; + r.t = this.t; + r.s = this.s; +} + +// (protected) set from integer value x, -DV <= x < DV +function bnpFromInt(x) { + var this_array = this.array; + this.t = 1; + this.s = (x<0)?-1:0; + if(x > 0) this_array[0] = x; + else if(x < -1) this_array[0] = x+DV; + else this.t = 0; +} + +// return bigint initialized to value +function nbv(i) { var r = nbi(); r.fromInt(i); return r; } + +// (protected) set from string and radix +function bnpFromString(s,b) { + var this_array = this.array; + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 256) k = 8; // byte array + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else { this.fromRadix(s,b); return; } + this.t = 0; + this.s = 0; + var i = s.length, mi = false, sh = 0; + while(--i >= 0) { + var x = (k==8)?s[i]&0xff:intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-") mi = true; + continue; + } + mi = false; + if(sh == 0) + this_array[this.t++] = x; + else if(sh+k > BI_DB) { + this_array[this.t-1] |= (x&((1<<(BI_DB-sh))-1))<<sh; + this_array[this.t++] = (x>>(BI_DB-sh)); + } + else + this_array[this.t-1] |= x<<sh; + sh += k; + if(sh >= BI_DB) sh -= BI_DB; + } + if(k == 8 && (s[0]&0x80) != 0) { + this.s = -1; + if(sh > 0) this_array[this.t-1] |= ((1<<(BI_DB-sh))-1)<<sh; + } + this.clamp(); + if(mi) BigInteger.ZERO.subTo(this,this); +} + +// (protected) clamp off excess high words +function bnpClamp() { + var this_array = this.array; + var c = this.s&BI_DM; + while(this.t > 0 && this_array[this.t-1] == c) --this.t; +} + +// (public) return string representation in given radix +function bnToString(b) { + var this_array = this.array; + if(this.s < 0) return "-"+this.negate().toString(b); + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else return this.toRadix(b); + var km = (1<<k)-1, d, m = false, r = "", i = this.t; + var p = BI_DB-(i*BI_DB)%k; + if(i-- > 0) { + if(p < BI_DB && (d = this_array[i]>>p) > 0) { m = true; r = int2char(d); } + while(i >= 0) { + if(p < k) { + d = (this_array[i]&((1<<p)-1))<<(k-p); + d |= this_array[--i]>>(p+=BI_DB-k); + } + else { + d = (this_array[i]>>(p-=k))&km; + if(p <= 0) { p += BI_DB; --i; } + } + if(d > 0) m = true; + if(m) r += int2char(d); + } + } + return m?r:"0"; +} + +// (public) -this +function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } + +// (public) |this| +function bnAbs() { return (this.s<0)?this.negate():this; } + +// (public) return + if this > a, - if this < a, 0 if equal +function bnCompareTo(a) { + var this_array = this.array; + var a_array = a.array; + + var r = this.s-a.s; + if(r != 0) return r; + var i = this.t; + r = i-a.t; + if(r != 0) return r; + while(--i >= 0) if((r=this_array[i]-a_array[i]) != 0) return r; + return 0; +} + +// returns bit length of the integer x +function nbits(x) { + var r = 1, t; + if((t=x>>>16) != 0) { x = t; r += 16; } + if((t=x>>8) != 0) { x = t; r += 8; } + if((t=x>>4) != 0) { x = t; r += 4; } + if((t=x>>2) != 0) { x = t; r += 2; } + if((t=x>>1) != 0) { x = t; r += 1; } + return r; +} + +// (public) return the number of bits in "this" +function bnBitLength() { + var this_array = this.array; + if(this.t <= 0) return 0; + return BI_DB*(this.t-1)+nbits(this_array[this.t-1]^(this.s&BI_DM)); +} + +// (protected) r = this << n*DB +function bnpDLShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + var i; + for(i = this.t-1; i >= 0; --i) r_array[i+n] = this_array[i]; + for(i = n-1; i >= 0; --i) r_array[i] = 0; + r.t = this.t+n; + r.s = this.s; +} + +// (protected) r = this >> n*DB +function bnpDRShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + for(var i = n; i < this.t; ++i) r_array[i-n] = this_array[i]; + r.t = Math.max(this.t-n,0); + r.s = this.s; +} + +// (protected) r = this << n +function bnpLShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + var bs = n%BI_DB; + var cbs = BI_DB-bs; + var bm = (1<<cbs)-1; + var ds = Math.floor(n/BI_DB), c = (this.s<<bs)&BI_DM, i; + for(i = this.t-1; i >= 0; --i) { + r_array[i+ds+1] = (this_array[i]>>cbs)|c; + c = (this_array[i]&bm)<<bs; + } + for(i = ds-1; i >= 0; --i) r_array[i] = 0; + r_array[ds] = c; + r.t = this.t+ds+1; + r.s = this.s; + r.clamp(); +} + +// (protected) r = this >> n +function bnpRShiftTo(n,r) { + var this_array = this.array; + var r_array = r.array; + r.s = this.s; + var ds = Math.floor(n/BI_DB); + if(ds >= this.t) { r.t = 0; return; } + var bs = n%BI_DB; + var cbs = BI_DB-bs; + var bm = (1<<bs)-1; + r_array[0] = this_array[ds]>>bs; + for(var i = ds+1; i < this.t; ++i) { + r_array[i-ds-1] |= (this_array[i]&bm)<<cbs; + r_array[i-ds] = this_array[i]>>bs; + } + if(bs > 0) r_array[this.t-ds-1] |= (this.s&bm)<<cbs; + r.t = this.t-ds; + r.clamp(); +} + +// (protected) r = this - a +function bnpSubTo(a,r) { + var this_array = this.array; + var r_array = r.array; + var a_array = a.array; + var i = 0, c = 0, m = Math.min(a.t,this.t); + while(i < m) { + c += this_array[i]-a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + if(a.t < this.t) { + c -= a.s; + while(i < this.t) { + c += this_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c -= a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c -= a.s; + } + r.s = (c<0)?-1:0; + if(c < -1) r_array[i++] = BI_DV+c; + else if(c > 0) r_array[i++] = c; + r.t = i; + r.clamp(); +} + +// (protected) r = this * a, r != this,a (HAC 14.12) +// "this" should be the larger one if appropriate. +function bnpMultiplyTo(a,r) { + var this_array = this.array; + var r_array = r.array; + var x = this.abs(), y = a.abs(); + var y_array = y.array; + + var i = x.t; + r.t = i+y.t; + while(--i >= 0) r_array[i] = 0; + for(i = 0; i < y.t; ++i) r_array[i+x.t] = x.am(0,y_array[i],r,i,0,x.t); + r.s = 0; + r.clamp(); + if(this.s != a.s) BigInteger.ZERO.subTo(r,r); +} + +// (protected) r = this^2, r != this (HAC 14.16) +function bnpSquareTo(r) { + var x = this.abs(); + var x_array = x.array; + var r_array = r.array; + + var i = r.t = 2*x.t; + while(--i >= 0) r_array[i] = 0; + for(i = 0; i < x.t-1; ++i) { + var c = x.am(i,x_array[i],r,2*i,0,1); + if((r_array[i+x.t]+=x.am(i+1,2*x_array[i],r,2*i+1,c,x.t-i-1)) >= BI_DV) { + r_array[i+x.t] -= BI_DV; + r_array[i+x.t+1] = 1; + } + } + if(r.t > 0) r_array[r.t-1] += x.am(i,x_array[i],r,2*i,0,1); + r.s = 0; + r.clamp(); +} + +// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) +// r != q, this != m. q or r may be null. +function bnpDivRemTo(m,q,r) { + var pm = m.abs(); + if(pm.t <= 0) return; + var pt = this.abs(); + if(pt.t < pm.t) { + if(q != null) q.fromInt(0); + if(r != null) this.copyTo(r); + return; + } + if(r == null) r = nbi(); + var y = nbi(), ts = this.s, ms = m.s; + var pm_array = pm.array; + var nsh = BI_DB-nbits(pm_array[pm.t-1]); // normalize modulus + if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } + else { pm.copyTo(y); pt.copyTo(r); } + var ys = y.t; + + var y_array = y.array; + var y0 = y_array[ys-1]; + if(y0 == 0) return; + var yt = y0*(1<<BI_F1)+((ys>1)?y_array[ys-2]>>BI_F2:0); + var d1 = BI_FV/yt, d2 = (1<<BI_F1)/yt, e = 1<<BI_F2; + var i = r.t, j = i-ys, t = (q==null)?nbi():q; + y.dlShiftTo(j,t); + + var r_array = r.array; + if(r.compareTo(t) >= 0) { + r_array[r.t++] = 1; + r.subTo(t,r); + } + BigInteger.ONE.dlShiftTo(ys,t); + t.subTo(y,y); // "negative" y so we can replace sub with am later + while(y.t < ys) y_array[y.t++] = 0; + while(--j >= 0) { + // Estimate quotient digit + var qd = (r_array[--i]==y0)?BI_DM:Math.floor(r_array[i]*d1+(r_array[i-1]+e)*d2); + if((r_array[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out + y.dlShiftTo(j,t); + r.subTo(t,r); + while(r_array[i] < --qd) r.subTo(t,r); + } + } + if(q != null) { + r.drShiftTo(ys,q); + if(ts != ms) BigInteger.ZERO.subTo(q,q); + } + r.t = ys; + r.clamp(); + if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder + if(ts < 0) BigInteger.ZERO.subTo(r,r); +} + +// (public) this mod a +function bnMod(a) { + var r = nbi(); + this.abs().divRemTo(a,null,r); + if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); + return r; +} + +// Modular reduction using "classic" algorithm +function Classic(m) { this.m = m; } +function cConvert(x) { + if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); + else return x; +} +function cRevert(x) { return x; } +function cReduce(x) { x.divRemTo(this.m,null,x); } +function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } +function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +Classic.prototype.convert = cConvert; +Classic.prototype.revert = cRevert; +Classic.prototype.reduce = cReduce; +Classic.prototype.mulTo = cMulTo; +Classic.prototype.sqrTo = cSqrTo; + +// (protected) return "-1/this % 2^DB"; useful for Mont. reduction +// justification: +// xy == 1 (mod m) +// xy = 1+km +// xy(2-xy) = (1+km)(1-km) +// x[y(2-xy)] = 1-k^2m^2 +// x[y(2-xy)] == 1 (mod m^2) +// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 +// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. +// JS multiply "overflows" differently from C/C++, so care is needed here. +function bnpInvDigit() { + var this_array = this.array; + if(this.t < 1) return 0; + var x = this_array[0]; + if((x&1) == 0) return 0; + var y = x&3; // y == 1/x mod 2^2 + y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 + y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 + y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y*(2-x*y%BI_DV))%BI_DV; // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return (y>0)?BI_DV-y:-y; +} + +// Montgomery reduction +function Montgomery(m) { + this.m = m; + this.mp = m.invDigit(); + this.mpl = this.mp&0x7fff; + this.mph = this.mp>>15; + this.um = (1<<(BI_DB-15))-1; + this.mt2 = 2*m.t; +} + +// xR mod m +function montConvert(x) { + var r = nbi(); + x.abs().dlShiftTo(this.m.t,r); + r.divRemTo(this.m,null,r); + if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); + return r; +} + +// x/R mod m +function montRevert(x) { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; +} + +// x = x/R mod m (HAC 14.32) +function montReduce(x) { + var x_array = x.array; + while(x.t <= this.mt2) // pad x so am has enough room later + x_array[x.t++] = 0; + for(var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x_array[i]&0x7fff; + var u0 = (j*this.mpl+(((j*this.mph+(x_array[i]>>15)*this.mpl)&this.um)<<15))&BI_DM; + // use am to combine the multiply-shift-add into one call + j = i+this.m.t; + x_array[j] += this.m.am(0,u0,x,i,0,this.m.t); + // propagate carry + while(x_array[j] >= BI_DV) { x_array[j] -= BI_DV; x_array[++j]++; } + } + x.clamp(); + x.drShiftTo(this.m.t,x); + if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); +} + +// r = "x^2/R mod m"; x != r +function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +// r = "xy/R mod m"; x,y != r +function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + +Montgomery.prototype.convert = montConvert; +Montgomery.prototype.revert = montRevert; +Montgomery.prototype.reduce = montReduce; +Montgomery.prototype.mulTo = montMulTo; +Montgomery.prototype.sqrTo = montSqrTo; + +// (protected) true iff this is even +function bnpIsEven() { + var this_array = this.array; + return ((this.t>0)?(this_array[0]&1):this.s) == 0; +} + +// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) +function bnpExp(e,z) { + if(e > 0xffffffff || e < 1) return BigInteger.ONE; + var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; + g.copyTo(r); + while(--i >= 0) { + z.sqrTo(r,r2); + if((e&(1<<i)) > 0) z.mulTo(r2,g,r); + else { var t = r; r = r2; r2 = t; } + } + return z.revert(r); +} + +// (public) this^e % m, 0 <= e < 2^32 +function bnModPowInt(e,m) { + var z; + if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); + return this.exp(e,z); +} + +// protected +BigInteger.prototype.copyTo = bnpCopyTo; +BigInteger.prototype.fromInt = bnpFromInt; +BigInteger.prototype.fromString = bnpFromString; +BigInteger.prototype.clamp = bnpClamp; +BigInteger.prototype.dlShiftTo = bnpDLShiftTo; +BigInteger.prototype.drShiftTo = bnpDRShiftTo; +BigInteger.prototype.lShiftTo = bnpLShiftTo; +BigInteger.prototype.rShiftTo = bnpRShiftTo; +BigInteger.prototype.subTo = bnpSubTo; +BigInteger.prototype.multiplyTo = bnpMultiplyTo; +BigInteger.prototype.squareTo = bnpSquareTo; +BigInteger.prototype.divRemTo = bnpDivRemTo; +BigInteger.prototype.invDigit = bnpInvDigit; +BigInteger.prototype.isEven = bnpIsEven; +BigInteger.prototype.exp = bnpExp; + +// public +BigInteger.prototype.toString = bnToString; +BigInteger.prototype.negate = bnNegate; +BigInteger.prototype.abs = bnAbs; +BigInteger.prototype.compareTo = bnCompareTo; +BigInteger.prototype.bitLength = bnBitLength; +BigInteger.prototype.mod = bnMod; +BigInteger.prototype.modPowInt = bnModPowInt; + +// "constants" +BigInteger.ZERO = nbv(0); +BigInteger.ONE = nbv(1); +// Copyright (c) 2005 Tom Wu +// All Rights Reserved. +// See "LICENSE" for details. + +// Extended JavaScript BN functions, required for RSA private ops. + +// (public) +function bnClone() { var r = nbi(); this.copyTo(r); return r; } + +// (public) return value as integer +function bnIntValue() { + var this_array = this.array; + if(this.s < 0) { + if(this.t == 1) return this_array[0]-BI_DV; + else if(this.t == 0) return -1; + } + else if(this.t == 1) return this_array[0]; + else if(this.t == 0) return 0; + // assumes 16 < DB < 32 + return ((this_array[1]&((1<<(32-BI_DB))-1))<<BI_DB)|this_array[0]; +} + +// (public) return value as byte +function bnByteValue() { + var this_array = this.array; + return (this.t==0)?this.s:(this_array[0]<<24)>>24; +} + +// (public) return value as short (assumes DB>=16) +function bnShortValue() { + var this_array = this.array; + return (this.t==0)?this.s:(this_array[0]<<16)>>16; +} + +// (protected) return x s.t. r^x < DV +function bnpChunkSize(r) { return Math.floor(Math.LN2*BI_DB/Math.log(r)); } + +// (public) 0 if this == 0, 1 if this > 0 +function bnSigNum() { + var this_array = this.array; + if(this.s < 0) return -1; + else if(this.t <= 0 || (this.t == 1 && this_array[0] <= 0)) return 0; + else return 1; +} + +// (protected) convert to radix string +function bnpToRadix(b) { + if(b == null) b = 10; + if(this.signum() == 0 || b < 2 || b > 36) return "0"; + var cs = this.chunkSize(b); + var a = Math.pow(b,cs); + var d = nbv(a), y = nbi(), z = nbi(), r = ""; + this.divRemTo(d,y,z); + while(y.signum() > 0) { + r = (a+z.intValue()).toString(b).substr(1) + r; + y.divRemTo(d,y,z); + } + return z.intValue().toString(b) + r; +} + +// (protected) convert from radix string +function bnpFromRadix(s,b) { + this.fromInt(0); + if(b == null) b = 10; + var cs = this.chunkSize(b); + var d = Math.pow(b,cs), mi = false, j = 0, w = 0; + for(var i = 0; i < s.length; ++i) { + var x = intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-" && this.signum() == 0) mi = true; + continue; + } + w = b*w+x; + if(++j >= cs) { + this.dMultiply(d); + this.dAddOffset(w,0); + j = 0; + w = 0; + } + } + if(j > 0) { + this.dMultiply(Math.pow(b,j)); + this.dAddOffset(w,0); + } + if(mi) BigInteger.ZERO.subTo(this,this); +} + +// (protected) alternate constructor +function bnpFromNumber(a,b,c) { + if("number" == typeof b) { + // new BigInteger(int,int,RNG) + if(a < 2) this.fromInt(1); + else { + this.fromNumber(a,c); + if(!this.testBit(a-1)) // force MSB set + this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this); + if(this.isEven()) this.dAddOffset(1,0); // force odd + while(!this.isProbablePrime(b)) { + this.dAddOffset(2,0); + if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this); + } + } + } + else { + // new BigInteger(int,RNG) + var x = new Array(), t = a&7; + x.length = (a>>3)+1; + b.nextBytes(x); + if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0; + this.fromString(x,256); + } +} + +// (public) convert to bigendian byte array +function bnToByteArray() { + var this_array = this.array; + var i = this.t, r = new Array(); + r[0] = this.s; + var p = BI_DB-(i*BI_DB)%8, d, k = 0; + if(i-- > 0) { + if(p < BI_DB && (d = this_array[i]>>p) != (this.s&BI_DM)>>p) + r[k++] = d|(this.s<<(BI_DB-p)); + while(i >= 0) { + if(p < 8) { + d = (this_array[i]&((1<<p)-1))<<(8-p); + d |= this_array[--i]>>(p+=BI_DB-8); + } + else { + d = (this_array[i]>>(p-=8))&0xff; + if(p <= 0) { p += BI_DB; --i; } + } + if((d&0x80) != 0) d |= -256; + if(k == 0 && (this.s&0x80) != (d&0x80)) ++k; + if(k > 0 || d != this.s) r[k++] = d; + } + } + return r; +} + +function bnEquals(a) { return(this.compareTo(a)==0); } +function bnMin(a) { return(this.compareTo(a)<0)?this:a; } +function bnMax(a) { return(this.compareTo(a)>0)?this:a; } + +// (protected) r = this op a (bitwise) +function bnpBitwiseTo(a,op,r) { + var this_array = this.array; + var a_array = a.array; + var r_array = r.array; + var i, f, m = Math.min(a.t,this.t); + for(i = 0; i < m; ++i) r_array[i] = op(this_array[i],a_array[i]); + if(a.t < this.t) { + f = a.s&BI_DM; + for(i = m; i < this.t; ++i) r_array[i] = op(this_array[i],f); + r.t = this.t; + } + else { + f = this.s&BI_DM; + for(i = m; i < a.t; ++i) r_array[i] = op(f,a_array[i]); + r.t = a.t; + } + r.s = op(this.s,a.s); + r.clamp(); +} + +// (public) this & a +function op_and(x,y) { return x&y; } +function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; } + +// (public) this | a +function op_or(x,y) { return x|y; } +function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; } + +// (public) this ^ a +function op_xor(x,y) { return x^y; } +function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; } + +// (public) this & ~a +function op_andnot(x,y) { return x&~y; } +function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; } + +// (public) ~this +function bnNot() { + var this_array = this.array; + var r = nbi(); + var r_array = r.array; + + for(var i = 0; i < this.t; ++i) r_array[i] = BI_DM&~this_array[i]; + r.t = this.t; + r.s = ~this.s; + return r; +} + +// (public) this << n +function bnShiftLeft(n) { + var r = nbi(); + if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r); + return r; +} + +// (public) this >> n +function bnShiftRight(n) { + var r = nbi(); + if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r); + return r; +} + +// return index of lowest 1-bit in x, x < 2^31 +function lbit(x) { + if(x == 0) return -1; + var r = 0; + if((x&0xffff) == 0) { x >>= 16; r += 16; } + if((x&0xff) == 0) { x >>= 8; r += 8; } + if((x&0xf) == 0) { x >>= 4; r += 4; } + if((x&3) == 0) { x >>= 2; r += 2; } + if((x&1) == 0) ++r; + return r; +} + +// (public) returns index of lowest 1-bit (or -1 if none) +function bnGetLowestSetBit() { + var this_array = this.array; + for(var i = 0; i < this.t; ++i) + if(this_array[i] != 0) return i*BI_DB+lbit(this_array[i]); + if(this.s < 0) return this.t*BI_DB; + return -1; +} + +// return number of 1 bits in x +function cbit(x) { + var r = 0; + while(x != 0) { x &= x-1; ++r; } + return r; +} + +// (public) return number of set bits +function bnBitCount() { + var r = 0, x = this.s&BI_DM; + for(var i = 0; i < this.t; ++i) r += cbit(this_array[i]^x); + return r; +} + +// (public) true iff nth bit is set +function bnTestBit(n) { + var this_array = this.array; + var j = Math.floor(n/BI_DB); + if(j >= this.t) return(this.s!=0); + return((this_array[j]&(1<<(n%BI_DB)))!=0); +} + +// (protected) this op (1<<n) +function bnpChangeBit(n,op) { + var r = BigInteger.ONE.shiftLeft(n); + this.bitwiseTo(r,op,r); + return r; +} + +// (public) this | (1<<n) +function bnSetBit(n) { return this.changeBit(n,op_or); } + +// (public) this & ~(1<<n) +function bnClearBit(n) { return this.changeBit(n,op_andnot); } + +// (public) this ^ (1<<n) +function bnFlipBit(n) { return this.changeBit(n,op_xor); } + +// (protected) r = this + a +function bnpAddTo(a,r) { + var this_array = this.array; + var a_array = a.array; + var r_array = r.array; + var i = 0, c = 0, m = Math.min(a.t,this.t); + while(i < m) { + c += this_array[i]+a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + if(a.t < this.t) { + c += a.s; + while(i < this.t) { + c += this_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c += a_array[i]; + r_array[i++] = c&BI_DM; + c >>= BI_DB; + } + c += a.s; + } + r.s = (c<0)?-1:0; + if(c > 0) r_array[i++] = c; + else if(c < -1) r_array[i++] = BI_DV+c; + r.t = i; + r.clamp(); +} + +// (public) this + a +function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; } + +// (public) this - a +function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; } + +// (public) this * a +function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; } + +// (public) this / a +function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; } + +// (public) this % a +function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; } + +// (public) [this/a,this%a] +function bnDivideAndRemainder(a) { + var q = nbi(), r = nbi(); + this.divRemTo(a,q,r); + return new Array(q,r); +} + +// (protected) this *= n, this >= 0, 1 < n < DV +function bnpDMultiply(n) { + var this_array = this.array; + this_array[this.t] = this.am(0,n-1,this,0,0,this.t); + ++this.t; + this.clamp(); +} + +// (protected) this += n << w words, this >= 0 +function bnpDAddOffset(n,w) { + var this_array = this.array; + while(this.t <= w) this_array[this.t++] = 0; + this_array[w] += n; + while(this_array[w] >= BI_DV) { + this_array[w] -= BI_DV; + if(++w >= this.t) this_array[this.t++] = 0; + ++this_array[w]; + } +} + +// A "null" reducer +function NullExp() {} +function nNop(x) { return x; } +function nMulTo(x,y,r) { x.multiplyTo(y,r); } +function nSqrTo(x,r) { x.squareTo(r); } + +NullExp.prototype.convert = nNop; +NullExp.prototype.revert = nNop; +NullExp.prototype.mulTo = nMulTo; +NullExp.prototype.sqrTo = nSqrTo; + +// (public) this^e +function bnPow(e) { return this.exp(e,new NullExp()); } + +// (protected) r = lower n words of "this * a", a.t <= n +// "this" should be the larger one if appropriate. +function bnpMultiplyLowerTo(a,n,r) { + var r_array = r.array; + var a_array = a.array; + var i = Math.min(this.t+a.t,n); + r.s = 0; // assumes a,this >= 0 + r.t = i; + while(i > 0) r_array[--i] = 0; + var j; + for(j = r.t-this.t; i < j; ++i) r_array[i+this.t] = this.am(0,a_array[i],r,i,0,this.t); + for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a_array[i],r,i,0,n-i); + r.clamp(); +} + +// (protected) r = "this * a" without lower n words, n > 0 +// "this" should be the larger one if appropriate. +function bnpMultiplyUpperTo(a,n,r) { + var r_array = r.array; + var a_array = a.array; + --n; + var i = r.t = this.t+a.t-n; + r.s = 0; // assumes a,this >= 0 + while(--i >= 0) r_array[i] = 0; + for(i = Math.max(n-this.t,0); i < a.t; ++i) + r_array[this.t+i-n] = this.am(n-i,a_array[i],r,0,0,this.t+i-n); + r.clamp(); + r.drShiftTo(1,r); +} + +// Barrett modular reduction +function Barrett(m) { + // setup Barrett + this.r2 = nbi(); + this.q3 = nbi(); + BigInteger.ONE.dlShiftTo(2*m.t,this.r2); + this.mu = this.r2.divide(m); + this.m = m; +} + +function barrettConvert(x) { + if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m); + else if(x.compareTo(this.m) < 0) return x; + else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } +} + +function barrettRevert(x) { return x; } + +// x = x mod m (HAC 14.42) +function barrettReduce(x) { + x.drShiftTo(this.m.t-1,this.r2); + if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); } + this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3); + this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2); + while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1); + x.subTo(this.r2,x); + while(x.compareTo(this.m) >= 0) x.subTo(this.m,x); +} + +// r = x^2 mod m; x != r +function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +// r = x*y mod m; x,y != r +function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + +Barrett.prototype.convert = barrettConvert; +Barrett.prototype.revert = barrettRevert; +Barrett.prototype.reduce = barrettReduce; +Barrett.prototype.mulTo = barrettMulTo; +Barrett.prototype.sqrTo = barrettSqrTo; + +// (public) this^e % m (HAC 14.85) +function bnModPow(e,m) { + var e_array = e.array; + var i = e.bitLength(), k, r = nbv(1), z; + if(i <= 0) return r; + else if(i < 18) k = 1; + else if(i < 48) k = 3; + else if(i < 144) k = 4; + else if(i < 768) k = 5; + else k = 6; + if(i < 8) + z = new Classic(m); + else if(m.isEven()) + z = new Barrett(m); + else + z = new Montgomery(m); + + // precomputation + var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1; + g[1] = z.convert(this); + if(k > 1) { + var g2 = nbi(); + z.sqrTo(g[1],g2); + while(n <= km) { + g[n] = nbi(); + z.mulTo(g2,g[n-2],g[n]); + n += 2; + } + } + + var j = e.t-1, w, is1 = true, r2 = nbi(), t; + i = nbits(e_array[j])-1; + while(j >= 0) { + if(i >= k1) w = (e_array[j]>>(i-k1))&km; + else { + w = (e_array[j]&((1<<(i+1))-1))<<(k1-i); + if(j > 0) w |= e_array[j-1]>>(BI_DB+i-k1); + } + + n = k; + while((w&1) == 0) { w >>= 1; --n; } + if((i -= n) < 0) { i += BI_DB; --j; } + if(is1) { // ret == 1, don't bother squaring or multiplying it + g[w].copyTo(r); + is1 = false; + } + else { + while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; } + if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; } + z.mulTo(r2,g[w],r); + } + + while(j >= 0 && (e_array[j]&(1<<i)) == 0) { + z.sqrTo(r,r2); t = r; r = r2; r2 = t; + if(--i < 0) { i = BI_DB-1; --j; } + } + } + return z.revert(r); +} + +// (public) gcd(this,a) (HAC 14.54) +function bnGCD(a) { + var x = (this.s<0)?this.negate():this.clone(); + var y = (a.s<0)?a.negate():a.clone(); + if(x.compareTo(y) < 0) { var t = x; x = y; y = t; } + var i = x.getLowestSetBit(), g = y.getLowestSetBit(); + if(g < 0) return x; + if(i < g) g = i; + if(g > 0) { + x.rShiftTo(g,x); + y.rShiftTo(g,y); + } + while(x.signum() > 0) { + if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x); + if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y); + if(x.compareTo(y) >= 0) { + x.subTo(y,x); + x.rShiftTo(1,x); + } + else { + y.subTo(x,y); + y.rShiftTo(1,y); + } + } + if(g > 0) y.lShiftTo(g,y); + return y; +} + +// (protected) this % n, n < 2^26 +function bnpModInt(n) { + var this_array = this.array; + if(n <= 0) return 0; + var d = BI_DV%n, r = (this.s<0)?n-1:0; + if(this.t > 0) + if(d == 0) r = this_array[0]%n; + else for(var i = this.t-1; i >= 0; --i) r = (d*r+this_array[i])%n; + return r; +} + +// (public) 1/this % m (HAC 14.61) +function bnModInverse(m) { + var ac = m.isEven(); + if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; + var u = m.clone(), v = this.clone(); + var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); + while(u.signum() != 0) { + while(u.isEven()) { + u.rShiftTo(1,u); + if(ac) { + if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } + a.rShiftTo(1,a); + } + else if(!b.isEven()) b.subTo(m,b); + b.rShiftTo(1,b); + } + while(v.isEven()) { + v.rShiftTo(1,v); + if(ac) { + if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } + c.rShiftTo(1,c); + } + else if(!d.isEven()) d.subTo(m,d); + d.rShiftTo(1,d); + } + if(u.compareTo(v) >= 0) { + u.subTo(v,u); + if(ac) a.subTo(c,a); + b.subTo(d,b); + } + else { + v.subTo(u,v); + if(ac) c.subTo(a,c); + d.subTo(b,d); + } + } + if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; + if(d.compareTo(m) >= 0) return d.subtract(m); + if(d.signum() < 0) d.addTo(m,d); else return d; + if(d.signum() < 0) return d.add(m); else return d; +} + +var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509]; +var lplim = (1<<26)/lowprimes[lowprimes.length-1]; + +// (public) test primality with certainty >= 1-.5^t +function bnIsProbablePrime(t) { + var i, x = this.abs(); + var x_array = x.array; + if(x.t == 1 && x_array[0] <= lowprimes[lowprimes.length-1]) { + for(i = 0; i < lowprimes.length; ++i) + if(x_array[0] == lowprimes[i]) return true; + return false; + } + if(x.isEven()) return false; + i = 1; + while(i < lowprimes.length) { + var m = lowprimes[i], j = i+1; + while(j < lowprimes.length && m < lplim) m *= lowprimes[j++]; + m = x.modInt(m); + while(i < j) if(m%lowprimes[i++] == 0) return false; + } + return x.millerRabin(t); +} + +// (protected) true if probably prime (HAC 4.24, Miller-Rabin) +function bnpMillerRabin(t) { + var n1 = this.subtract(BigInteger.ONE); + var k = n1.getLowestSetBit(); + if(k <= 0) return false; + var r = n1.shiftRight(k); + t = (t+1)>>1; + if(t > lowprimes.length) t = lowprimes.length; + var a = nbi(); + for(var i = 0; i < t; ++i) { + a.fromInt(lowprimes[i]); + var y = a.modPow(r,this); + if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { + var j = 1; + while(j++ < k && y.compareTo(n1) != 0) { + y = y.modPowInt(2,this); + if(y.compareTo(BigInteger.ONE) == 0) return false; + } + if(y.compareTo(n1) != 0) return false; + } + } + return true; +} + +// protected +BigInteger.prototype.chunkSize = bnpChunkSize; +BigInteger.prototype.toRadix = bnpToRadix; +BigInteger.prototype.fromRadix = bnpFromRadix; +BigInteger.prototype.fromNumber = bnpFromNumber; +BigInteger.prototype.bitwiseTo = bnpBitwiseTo; +BigInteger.prototype.changeBit = bnpChangeBit; +BigInteger.prototype.addTo = bnpAddTo; +BigInteger.prototype.dMultiply = bnpDMultiply; +BigInteger.prototype.dAddOffset = bnpDAddOffset; +BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; +BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; +BigInteger.prototype.modInt = bnpModInt; +BigInteger.prototype.millerRabin = bnpMillerRabin; + +// public +BigInteger.prototype.clone = bnClone; +BigInteger.prototype.intValue = bnIntValue; +BigInteger.prototype.byteValue = bnByteValue; +BigInteger.prototype.shortValue = bnShortValue; +BigInteger.prototype.signum = bnSigNum; +BigInteger.prototype.toByteArray = bnToByteArray; +BigInteger.prototype.equals = bnEquals; +BigInteger.prototype.min = bnMin; +BigInteger.prototype.max = bnMax; +BigInteger.prototype.and = bnAnd; +BigInteger.prototype.or = bnOr; +BigInteger.prototype.xor = bnXor; +BigInteger.prototype.andNot = bnAndNot; +BigInteger.prototype.not = bnNot; +BigInteger.prototype.shiftLeft = bnShiftLeft; +BigInteger.prototype.shiftRight = bnShiftRight; +BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; +BigInteger.prototype.bitCount = bnBitCount; +BigInteger.prototype.testBit = bnTestBit; +BigInteger.prototype.setBit = bnSetBit; +BigInteger.prototype.clearBit = bnClearBit; +BigInteger.prototype.flipBit = bnFlipBit; +BigInteger.prototype.add = bnAdd; +BigInteger.prototype.subtract = bnSubtract; +BigInteger.prototype.multiply = bnMultiply; +BigInteger.prototype.divide = bnDivide; +BigInteger.prototype.remainder = bnRemainder; +BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; +BigInteger.prototype.modPow = bnModPow; +BigInteger.prototype.modInverse = bnModInverse; +BigInteger.prototype.pow = bnPow; +BigInteger.prototype.gcd = bnGCD; +BigInteger.prototype.isProbablePrime = bnIsProbablePrime; + +// BigInteger interfaces not implemented in jsbn: + +// BigInteger(int signum, byte[] magnitude) +// double doubleValue() +// float floatValue() +// int hashCode() +// long longValue() +// static BigInteger valueOf(long val) +// prng4.js - uses Arcfour as a PRNG + +function Arcfour() { + this.i = 0; + this.j = 0; + this.S = new Array(); +} + +// Initialize arcfour context from key, an array of ints, each from [0..255] +function ARC4init(key) { + var i, j, t; + for(i = 0; i < 256; ++i) + this.S[i] = i; + j = 0; + for(i = 0; i < 256; ++i) { + j = (j + this.S[i] + key[i % key.length]) & 255; + t = this.S[i]; + this.S[i] = this.S[j]; + this.S[j] = t; + } + this.i = 0; + this.j = 0; +} + +function ARC4next() { + var t; + this.i = (this.i + 1) & 255; + this.j = (this.j + this.S[this.i]) & 255; + t = this.S[this.i]; + this.S[this.i] = this.S[this.j]; + this.S[this.j] = t; + return this.S[(t + this.S[this.i]) & 255]; +} + +Arcfour.prototype.init = ARC4init; +Arcfour.prototype.next = ARC4next; + +// Plug in your RNG constructor here +function prng_newstate() { + return new Arcfour(); +} + +// Pool size must be a multiple of 4 and greater than 32. +// An array of bytes the size of the pool will be passed to init() +var rng_psize = 256; +// Random number generator - requires a PRNG backend, e.g. prng4.js + +// For best results, put code like +// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'> +// in your main HTML document. + +var rng_state; +var rng_pool; +var rng_pptr; + +// Mix in a 32-bit integer into the pool +function rng_seed_int(x) { + rng_pool[rng_pptr++] ^= x & 255; + rng_pool[rng_pptr++] ^= (x >> 8) & 255; + rng_pool[rng_pptr++] ^= (x >> 16) & 255; + rng_pool[rng_pptr++] ^= (x >> 24) & 255; + if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; +} + +// Mix in the current time (w/milliseconds) into the pool +function rng_seed_time() { + // Use pre-computed date to avoid making the benchmark + // results dependent on the current date. + rng_seed_int(1122926989487); +} + +// Initialize the pool with junk if needed. +if(rng_pool == null) { + rng_pool = new Array(); + rng_pptr = 0; + var t; + while(rng_pptr < rng_psize) { // extract some randomness from Math.random() + t = Math.floor(65536 * Math.random()); + rng_pool[rng_pptr++] = t >>> 8; + rng_pool[rng_pptr++] = t & 255; + } + rng_pptr = 0; + rng_seed_time(); + //rng_seed_int(window.screenX); + //rng_seed_int(window.screenY); +} + +function rng_get_byte() { + if(rng_state == null) { + rng_seed_time(); + rng_state = prng_newstate(); + rng_state.init(rng_pool); + for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) + rng_pool[rng_pptr] = 0; + rng_pptr = 0; + //rng_pool = null; + } + // TODO: allow reseeding after first request + return rng_state.next(); +} + +function rng_get_bytes(ba) { + var i; + for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte(); +} + +function SecureRandom() {} + +SecureRandom.prototype.nextBytes = rng_get_bytes; +// Depends on jsbn.js and rng.js + +// convert a (hex) string to a bignum object +function parseBigInt(str,r) { + return new BigInteger(str,r); +} + +function linebrk(s,n) { + var ret = ""; + var i = 0; + while(i + n < s.length) { + ret += s.substring(i,i+n) + "\n"; + i += n; + } + return ret + s.substring(i,s.length); +} + +function byte2Hex(b) { + if(b < 0x10) + return "0" + b.toString(16); + else + return b.toString(16); +} + +// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint +function pkcs1pad2(s,n) { + if(n < s.length + 11) { + alert("Message too long for RSA"); + return null; + } + var ba = new Array(); + var i = s.length - 1; + while(i >= 0 && n > 0) ba[--n] = s.charCodeAt(i--); + ba[--n] = 0; + var rng = new SecureRandom(); + var x = new Array(); + while(n > 2) { // random non-zero pad + x[0] = 0; + while(x[0] == 0) rng.nextBytes(x); + ba[--n] = x[0]; + } + ba[--n] = 2; + ba[--n] = 0; + return new BigInteger(ba); +} + +// "empty" RSA key constructor +function RSAKey() { + this.n = null; + this.e = 0; + this.d = null; + this.p = null; + this.q = null; + this.dmp1 = null; + this.dmq1 = null; + this.coeff = null; +} + +// Set the public key fields N and e from hex strings +function RSASetPublic(N,E) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + } + else + alert("Invalid RSA public key"); +} + +// Perform raw public operation on "x": return x^e (mod n) +function RSADoPublic(x) { + return x.modPowInt(this.e, this.n); +} + +// Return the PKCS#1 RSA encryption of "text" as an even-length hex string +function RSAEncrypt(text) { + var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3); + if(m == null) return null; + var c = this.doPublic(m); + if(c == null) return null; + var h = c.toString(16); + if((h.length & 1) == 0) return h; else return "0" + h; +} + +// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string +//function RSAEncryptB64(text) { +// var h = this.encrypt(text); +// if(h) return hex2b64(h); else return null; +//} + +// protected +RSAKey.prototype.doPublic = RSADoPublic; + +// public +RSAKey.prototype.setPublic = RSASetPublic; +RSAKey.prototype.encrypt = RSAEncrypt; +//RSAKey.prototype.encrypt_b64 = RSAEncryptB64; +// Depends on rsa.js and jsbn2.js + +// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext +function pkcs1unpad2(d,n) { + var b = d.toByteArray(); + var i = 0; + while(i < b.length && b[i] == 0) ++i; + if(b.length-i != n-1 || b[i] != 2) + return null; + ++i; + while(b[i] != 0) + if(++i >= b.length) return null; + var ret = ""; + while(++i < b.length) + ret += String.fromCharCode(b[i]); + return ret; +} + +// Set the private key fields N, e, and d from hex strings +function RSASetPrivate(N,E,D) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + this.d = parseBigInt(D,16); + } + else + alert("Invalid RSA private key"); +} + +// Set the private key fields N, e, d and CRT params from hex strings +function RSASetPrivateEx(N,E,D,P,Q,DP,DQ,C) { + if(N != null && E != null && N.length > 0 && E.length > 0) { + this.n = parseBigInt(N,16); + this.e = parseInt(E,16); + this.d = parseBigInt(D,16); + this.p = parseBigInt(P,16); + this.q = parseBigInt(Q,16); + this.dmp1 = parseBigInt(DP,16); + this.dmq1 = parseBigInt(DQ,16); + this.coeff = parseBigInt(C,16); + } + else + alert("Invalid RSA private key"); +} + +// Generate a new random private key B bits long, using public expt E +function RSAGenerate(B,E) { + var rng = new SecureRandom(); + var qs = B>>1; + this.e = parseInt(E,16); + var ee = new BigInteger(E,16); + for(;;) { + for(;;) { + this.p = new BigInteger(B-qs,1,rng); + if(this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) break; + } + for(;;) { + this.q = new BigInteger(qs,1,rng); + if(this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) break; + } + if(this.p.compareTo(this.q) <= 0) { + var t = this.p; + this.p = this.q; + this.q = t; + } + var p1 = this.p.subtract(BigInteger.ONE); + var q1 = this.q.subtract(BigInteger.ONE); + var phi = p1.multiply(q1); + if(phi.gcd(ee).compareTo(BigInteger.ONE) == 0) { + this.n = this.p.multiply(this.q); + this.d = ee.modInverse(phi); + this.dmp1 = this.d.mod(p1); + this.dmq1 = this.d.mod(q1); + this.coeff = this.q.modInverse(this.p); + break; + } + } +} + +// Perform raw private operation on "x": return x^d (mod n) +function RSADoPrivate(x) { + if(this.p == null || this.q == null) + return x.modPow(this.d, this.n); + + // TODO: re-calculate any missing CRT params + var xp = x.mod(this.p).modPow(this.dmp1, this.p); + var xq = x.mod(this.q).modPow(this.dmq1, this.q); + + while(xp.compareTo(xq) < 0) + xp = xp.add(this.p); + return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq); +} + +// Return the PKCS#1 RSA decryption of "ctext". +// "ctext" is an even-length hex string and the output is a plain string. +function RSADecrypt(ctext) { + var c = parseBigInt(ctext, 16); + var m = this.doPrivate(c); + if(m == null) return null; + return pkcs1unpad2(m, (this.n.bitLength()+7)>>3); +} + +// Return the PKCS#1 RSA decryption of "ctext". +// "ctext" is a Base64-encoded string and the output is a plain string. +//function RSAB64Decrypt(ctext) { +// var h = b64tohex(ctext); +// if(h) return this.decrypt(h); else return null; +//} + +// protected +RSAKey.prototype.doPrivate = RSADoPrivate; + +// public +RSAKey.prototype.setPrivate = RSASetPrivate; +RSAKey.prototype.setPrivateEx = RSASetPrivateEx; +RSAKey.prototype.generate = RSAGenerate; +RSAKey.prototype.decrypt = RSADecrypt; +//RSAKey.prototype.b64_decrypt = RSAB64Decrypt; + + +nValue="a5261939975948bb7a58dffe5ff54e65f0498f9175f5a09288810b8975871e99af3b5dd94057b0fc07535f5f97444504fa35169d461d0d30cf0192e307727c065168c788771c561a9400fb49175e9e6aa4e23fe11af69e9412dd23b0cb6684c4c2429bce139e848ab26d0829073351f4acd36074eafd036a5eb83359d2a698d3"; +eValue="10001"; +dValue="8e9912f6d3645894e8d38cb58c0db81ff516cf4c7e5a14c7f1eddb1459d2cded4d8d293fc97aee6aefb861859c8b6a3d1dfe710463e1f9ddc72048c09751971c4a580aa51eb523357a3cc48d31cfad1d4a165066ed92d4748fb6571211da5cb14bc11b6e2df7c1a559e6d5ac1cd5c94703a22891464fba23d0d965086277a161"; +pValue="d090ce58a92c75233a6486cb0a9209bf3583b64f540c76f5294bb97d285eed33aec220bde14b2417951178ac152ceab6da7090905b478195498b352048f15e7d"; +qValue="cab575dc652bb66df15a0359609d51d1db184750c00c6698b90ef3465c99655103edbf0d54c56aec0ce3c4d22592338092a126a0cc49f65a4a30d222b411e58f"; +dmp1Value="1a24bca8e273df2f0e47c199bbf678604e7df7215480c77c8db39f49b000ce2cf7500038acfff5433b7d582a01f1826e6f4d42e1c57f5e1fef7b12aabc59fd25"; +dmq1Value="3d06982efbbe47339e1f6d36b1216b8a741d410b0c662f54f7118b27b9a4ec9d914337eb39841d8666f3034408cf94f5b62f11c402fc994fe15a05493150d9fd"; +coeffValue="3a3e731acd8960b7ff9eb81a7ff93bd1cfa74cbd56987db58b4594fb09c09084db1734c8143f98b602b981aaa9243ca28deb69b5b280ee8dcee0fd2625e53250"; + +setupEngine(am3, 28); + +var TEXT = "The quick brown fox jumped over the extremely lazy frog! " + + "Now is the time for all good men to come to the party."; +var encrypted; + +function encrypt() { + var RSA = new RSAKey(); + RSA.setPublic(nValue, eValue); + RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value, coeffValue); + encrypted = RSA.encrypt(TEXT); +} + +function decrypt() { + var RSA = new RSAKey(); + RSA.setPublic(nValue, eValue); + RSA.setPrivateEx(nValue, eValue, dValue, pValue, qValue, dmp1Value, dmq1Value, coeffValue); + var decrypted = RSA.decrypt(encrypted); + if (decrypted != TEXT) { + throw new Error("Crypto operation failed"); + } +} +// The ray tracer code in this file is written by Adam Burmister. It +// is available in its original form from: +// +// http://labs.flog.nz.co/raytracer/ +// +// It has been modified slightly by Google to work as a standalone +// benchmark, but the all the computational code remains +// untouched. This file also contains a copy of parts of the Prototype +// JavaScript framework which is used by the ray tracer. + +var RayTrace = new BenchmarkSuite('RayTrace', 739989, [ + new Benchmark('RayTrace', renderScene) +]); + + +// Variable used to hold a number that can be used to verify that +// the scene was ray traced correctly. +var checkNumber; + + +// ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ + +// The following is a copy of parts of the Prototype JavaScript library: + +// Prototype JavaScript framework, version 1.5.0 +// (c) 2005-2007 Sam Stephenson +// +// Prototype is freely distributable under the terms of an MIT-style license. +// For details, see the Prototype web site: http://prototype.conio.net/ + + +var Class = { + create: function() { + return function() { + this.initialize.apply(this, arguments); + } + } +}; + + +Object.extend = function(destination, source) { + for (var property in source) { + destination[property] = source[property]; + } + return destination; +}; + + +// ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ + +// The rest of this file is the actual ray tracer written by Adam +// Burmister. It's a concatenation of the following files: +// +// flog/color.js +// flog/light.js +// flog/vector.js +// flog/ray.js +// flog/scene.js +// flog/material/basematerial.js +// flog/material/solid.js +// flog/material/chessboard.js +// flog/shape/baseshape.js +// flog/shape/sphere.js +// flog/shape/plane.js +// flog/intersectioninfo.js +// flog/camera.js +// flog/background.js +// flog/engine.js + + +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Color = Class.create(); + +Flog.RayTracer.Color.prototype = { + red : 0.0, + green : 0.0, + blue : 0.0, + + initialize : function(r, g, b) { + if(!r) r = 0.0; + if(!g) g = 0.0; + if(!b) b = 0.0; + + this.red = r; + this.green = g; + this.blue = b; + }, + + add : function(c1, c2){ + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red + c2.red; + result.green = c1.green + c2.green; + result.blue = c1.blue + c2.blue; + + return result; + }, + + addScalar: function(c1, s){ + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red + s; + result.green = c1.green + s; + result.blue = c1.blue + s; + + result.limit(); + + return result; + }, + + subtract: function(c1, c2){ + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red - c2.red; + result.green = c1.green - c2.green; + result.blue = c1.blue - c2.blue; + + return result; + }, + + multiply : function(c1, c2) { + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red * c2.red; + result.green = c1.green * c2.green; + result.blue = c1.blue * c2.blue; + + return result; + }, + + multiplyScalar : function(c1, f) { + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red * f; + result.green = c1.green * f; + result.blue = c1.blue * f; + + return result; + }, + + divideFactor : function(c1, f) { + var result = new Flog.RayTracer.Color(0,0,0); + + result.red = c1.red / f; + result.green = c1.green / f; + result.blue = c1.blue / f; + + return result; + }, + + limit: function(){ + this.red = (this.red > 0.0) ? ( (this.red > 1.0) ? 1.0 : this.red ) : 0.0; + this.green = (this.green > 0.0) ? ( (this.green > 1.0) ? 1.0 : this.green ) : 0.0; + this.blue = (this.blue > 0.0) ? ( (this.blue > 1.0) ? 1.0 : this.blue ) : 0.0; + }, + + distance : function(color) { + var d = Math.abs(this.red - color.red) + Math.abs(this.green - color.green) + Math.abs(this.blue - color.blue); + return d; + }, + + blend: function(c1, c2, w){ + var result = new Flog.RayTracer.Color(0,0,0); + result = Flog.RayTracer.Color.prototype.add( + Flog.RayTracer.Color.prototype.multiplyScalar(c1, 1 - w), + Flog.RayTracer.Color.prototype.multiplyScalar(c2, w) + ); + return result; + }, + + brightness : function() { + var r = Math.floor(this.red*255); + var g = Math.floor(this.green*255); + var b = Math.floor(this.blue*255); + return (r * 77 + g * 150 + b * 29) >> 8; + }, + + toString : function () { + var r = Math.floor(this.red*255); + var g = Math.floor(this.green*255); + var b = Math.floor(this.blue*255); + + return "rgb("+ r +","+ g +","+ b +")"; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Light = Class.create(); + +Flog.RayTracer.Light.prototype = { + position: null, + color: null, + intensity: 10.0, + + initialize : function(pos, color, intensity) { + this.position = pos; + this.color = color; + this.intensity = (intensity ? intensity : 10.0); + }, + + toString : function () { + return 'Light [' + this.position.x + ',' + this.position.y + ',' + this.position.z + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Vector = Class.create(); + +Flog.RayTracer.Vector.prototype = { + x : 0.0, + y : 0.0, + z : 0.0, + + initialize : function(x, y, z) { + this.x = (x ? x : 0); + this.y = (y ? y : 0); + this.z = (z ? z : 0); + }, + + copy: function(vector){ + this.x = vector.x; + this.y = vector.y; + this.z = vector.z; + }, + + normalize : function() { + var m = this.magnitude(); + return new Flog.RayTracer.Vector(this.x / m, this.y / m, this.z / m); + }, + + magnitude : function() { + return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z)); + }, + + cross : function(w) { + return new Flog.RayTracer.Vector( + -this.z * w.y + this.y * w.z, + this.z * w.x - this.x * w.z, + -this.y * w.x + this.x * w.y); + }, + + dot : function(w) { + return this.x * w.x + this.y * w.y + this.z * w.z; + }, + + add : function(v, w) { + return new Flog.RayTracer.Vector(w.x + v.x, w.y + v.y, w.z + v.z); + }, + + subtract : function(v, w) { + if(!w || !v) throw 'Vectors must be defined [' + v + ',' + w + ']'; + return new Flog.RayTracer.Vector(v.x - w.x, v.y - w.y, v.z - w.z); + }, + + multiplyVector : function(v, w) { + return new Flog.RayTracer.Vector(v.x * w.x, v.y * w.y, v.z * w.z); + }, + + multiplyScalar : function(v, w) { + return new Flog.RayTracer.Vector(v.x * w, v.y * w, v.z * w); + }, + + toString : function () { + return 'Vector [' + this.x + ',' + this.y + ',' + this.z + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Ray = Class.create(); + +Flog.RayTracer.Ray.prototype = { + position : null, + direction : null, + initialize : function(pos, dir) { + this.position = pos; + this.direction = dir; + }, + + toString : function () { + return 'Ray [' + this.position + ',' + this.direction + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Scene = Class.create(); + +Flog.RayTracer.Scene.prototype = { + camera : null, + shapes : [], + lights : [], + background : null, + + initialize : function() { + this.camera = new Flog.RayTracer.Camera( + new Flog.RayTracer.Vector(0,0,-5), + new Flog.RayTracer.Vector(0,0,1), + new Flog.RayTracer.Vector(0,1,0) + ); + this.shapes = new Array(); + this.lights = new Array(); + this.background = new Flog.RayTracer.Background(new Flog.RayTracer.Color(0,0,0.5), 0.2); + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; +if(typeof(Flog.RayTracer.Material) == 'undefined') Flog.RayTracer.Material = {}; + +Flog.RayTracer.Material.BaseMaterial = Class.create(); + +Flog.RayTracer.Material.BaseMaterial.prototype = { + + gloss: 2.0, // [0...infinity] 0 = matt + transparency: 0.0, // 0=opaque + reflection: 0.0, // [0...infinity] 0 = no reflection + refraction: 0.50, + hasTexture: false, + + initialize : function() { + + }, + + getColor: function(u, v){ + + }, + + wrapUp: function(t){ + t = t % 2.0; + if(t < -1) t += 2.0; + if(t >= 1) t -= 2.0; + return t; + }, + + toString : function () { + return 'Material [gloss=' + this.gloss + ', transparency=' + this.transparency + ', hasTexture=' + this.hasTexture +']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Material.Solid = Class.create(); + +Flog.RayTracer.Material.Solid.prototype = Object.extend( + new Flog.RayTracer.Material.BaseMaterial(), { + initialize : function(color, reflection, refraction, transparency, gloss) { + this.color = color; + this.reflection = reflection; + this.transparency = transparency; + this.gloss = gloss; + this.hasTexture = false; + }, + + getColor: function(u, v){ + return this.color; + }, + + toString : function () { + return 'SolidMaterial [gloss=' + this.gloss + ', transparency=' + this.transparency + ', hasTexture=' + this.hasTexture +']'; + } + } +); +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Material.Chessboard = Class.create(); + +Flog.RayTracer.Material.Chessboard.prototype = Object.extend( + new Flog.RayTracer.Material.BaseMaterial(), { + colorEven: null, + colorOdd: null, + density: 0.5, + + initialize : function(colorEven, colorOdd, reflection, transparency, gloss, density) { + this.colorEven = colorEven; + this.colorOdd = colorOdd; + this.reflection = reflection; + this.transparency = transparency; + this.gloss = gloss; + this.density = density; + this.hasTexture = true; + }, + + getColor: function(u, v){ + var t = this.wrapUp(u * this.density) * this.wrapUp(v * this.density); + + if(t < 0.0) + return this.colorEven; + else + return this.colorOdd; + }, + + toString : function () { + return 'ChessMaterial [gloss=' + this.gloss + ', transparency=' + this.transparency + ', hasTexture=' + this.hasTexture +']'; + } + } +); +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; +if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; + +Flog.RayTracer.Shape.Sphere = Class.create(); + +Flog.RayTracer.Shape.Sphere.prototype = { + initialize : function(pos, radius, material) { + this.radius = radius; + this.position = pos; + this.material = material; + }, + + intersect: function(ray){ + var info = new Flog.RayTracer.IntersectionInfo(); + info.shape = this; + + var dst = Flog.RayTracer.Vector.prototype.subtract(ray.position, this.position); + + var B = dst.dot(ray.direction); + var C = dst.dot(dst) - (this.radius * this.radius); + var D = (B * B) - C; + + if(D > 0){ // intersection! + info.isHit = true; + info.distance = (-B) - Math.sqrt(D); + info.position = Flog.RayTracer.Vector.prototype.add( + ray.position, + Flog.RayTracer.Vector.prototype.multiplyScalar( + ray.direction, + info.distance + ) + ); + info.normal = Flog.RayTracer.Vector.prototype.subtract( + info.position, + this.position + ).normalize(); + + info.color = this.material.getColor(0,0); + } else { + info.isHit = false; + } + return info; + }, + + toString : function () { + return 'Sphere [position=' + this.position + ', radius=' + this.radius + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; +if(typeof(Flog.RayTracer.Shape) == 'undefined') Flog.RayTracer.Shape = {}; + +Flog.RayTracer.Shape.Plane = Class.create(); + +Flog.RayTracer.Shape.Plane.prototype = { + d: 0.0, + + initialize : function(pos, d, material) { + this.position = pos; + this.d = d; + this.material = material; + }, + + intersect: function(ray){ + var info = new Flog.RayTracer.IntersectionInfo(); + + var Vd = this.position.dot(ray.direction); + if(Vd == 0) return info; // no intersection + + var t = -(this.position.dot(ray.position) + this.d) / Vd; + if(t <= 0) return info; + + info.shape = this; + info.isHit = true; + info.position = Flog.RayTracer.Vector.prototype.add( + ray.position, + Flog.RayTracer.Vector.prototype.multiplyScalar( + ray.direction, + t + ) + ); + info.normal = this.position; + info.distance = t; + + if(this.material.hasTexture){ + var vU = new Flog.RayTracer.Vector(this.position.y, this.position.z, -this.position.x); + var vV = vU.cross(this.position); + var u = info.position.dot(vU); + var v = info.position.dot(vV); + info.color = this.material.getColor(u,v); + } else { + info.color = this.material.getColor(0,0); + } + + return info; + }, + + toString : function () { + return 'Plane [' + this.position + ', d=' + this.d + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.IntersectionInfo = Class.create(); + +Flog.RayTracer.IntersectionInfo.prototype = { + isHit: false, + hitCount: 0, + shape: null, + position: null, + normal: null, + color: null, + distance: null, + + initialize : function() { + this.color = new Flog.RayTracer.Color(0,0,0); + }, + + toString : function () { + return 'Intersection [' + this.position + ']'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Camera = Class.create(); + +Flog.RayTracer.Camera.prototype = { + position: null, + lookAt: null, + equator: null, + up: null, + screen: null, + + initialize : function(pos, lookAt, up) { + this.position = pos; + this.lookAt = lookAt; + this.up = up; + this.equator = lookAt.normalize().cross(this.up); + this.screen = Flog.RayTracer.Vector.prototype.add(this.position, this.lookAt); + }, + + getRay: function(vx, vy){ + var pos = Flog.RayTracer.Vector.prototype.subtract( + this.screen, + Flog.RayTracer.Vector.prototype.subtract( + Flog.RayTracer.Vector.prototype.multiplyScalar(this.equator, vx), + Flog.RayTracer.Vector.prototype.multiplyScalar(this.up, vy) + ) + ); + pos.y = pos.y * -1; + var dir = Flog.RayTracer.Vector.prototype.subtract( + pos, + this.position + ); + + var ray = new Flog.RayTracer.Ray(pos, dir.normalize()); + + return ray; + }, + + toString : function () { + return 'Ray []'; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Background = Class.create(); + +Flog.RayTracer.Background.prototype = { + color : null, + ambience : 0.0, + + initialize : function(color, ambience) { + this.color = color; + this.ambience = ambience; + } +} +/* Fake a Flog.* namespace */ +if(typeof(Flog) == 'undefined') var Flog = {}; +if(typeof(Flog.RayTracer) == 'undefined') Flog.RayTracer = {}; + +Flog.RayTracer.Engine = Class.create(); + +Flog.RayTracer.Engine.prototype = { + canvas: null, /* 2d context we can render to */ + + initialize: function(options){ + this.options = Object.extend({ + canvasHeight: 100, + canvasWidth: 100, + pixelWidth: 2, + pixelHeight: 2, + renderDiffuse: false, + renderShadows: false, + renderHighlights: false, + renderReflections: false, + rayDepth: 2 + }, options || {}); + + this.options.canvasHeight /= this.options.pixelHeight; + this.options.canvasWidth /= this.options.pixelWidth; + + /* TODO: dynamically include other scripts */ + }, + + setPixel: function(x, y, color){ + var pxW, pxH; + pxW = this.options.pixelWidth; + pxH = this.options.pixelHeight; + + if (this.canvas) { + this.canvas.fillStyle = color.toString(); + this.canvas.fillRect (x * pxW, y * pxH, pxW, pxH); + } else { + if (x === y) { + checkNumber += color.brightness(); + } + // print(x * pxW, y * pxH, pxW, pxH); + } + }, + + renderScene: function(scene, canvas){ + checkNumber = 0; + /* Get canvas */ + if (canvas) { + this.canvas = canvas.getContext("2d"); + } else { + this.canvas = null; + } + + var canvasHeight = this.options.canvasHeight; + var canvasWidth = this.options.canvasWidth; + + for(var y=0; y < canvasHeight; y++){ + for(var x=0; x < canvasWidth; x++){ + var yp = y * 1.0 / canvasHeight * 2 - 1; + var xp = x * 1.0 / canvasWidth * 2 - 1; + + var ray = scene.camera.getRay(xp, yp); + + var color = this.getPixelColor(ray, scene); + + this.setPixel(x, y, color); + } + } + if (checkNumber !== 2321) { + throw new Error("Scene rendered incorrectly"); + } + }, + + getPixelColor: function(ray, scene){ + var info = this.testIntersection(ray, scene, null); + if(info.isHit){ + var color = this.rayTrace(info, ray, scene, 0); + return color; + } + return scene.background.color; + }, + + testIntersection: function(ray, scene, exclude){ + var hits = 0; + var best = new Flog.RayTracer.IntersectionInfo(); + best.distance = 2000; + + for(var i=0; i<scene.shapes.length; i++){ + var shape = scene.shapes[i]; + + if(shape != exclude){ + var info = shape.intersect(ray); + if(info.isHit && info.distance >= 0 && info.distance < best.distance){ + best = info; + hits++; + } + } + } + best.hitCount = hits; + return best; + }, + + getReflectionRay: function(P,N,V){ + var c1 = -N.dot(V); + var R1 = Flog.RayTracer.Vector.prototype.add( + Flog.RayTracer.Vector.prototype.multiplyScalar(N, 2*c1), + V + ); + return new Flog.RayTracer.Ray(P, R1); + }, + + rayTrace: function(info, ray, scene, depth){ + // Calc ambient + var color = Flog.RayTracer.Color.prototype.multiplyScalar(info.color, scene.background.ambience); + var oldColor = color; + var shininess = Math.pow(10, info.shape.material.gloss + 1); + + for(var i=0; i<scene.lights.length; i++){ + var light = scene.lights[i]; + + // Calc diffuse lighting + var v = Flog.RayTracer.Vector.prototype.subtract( + light.position, + info.position + ).normalize(); + + if(this.options.renderDiffuse){ + var L = v.dot(info.normal); + if(L > 0.0){ + color = Flog.RayTracer.Color.prototype.add( + color, + Flog.RayTracer.Color.prototype.multiply( + info.color, + Flog.RayTracer.Color.prototype.multiplyScalar( + light.color, + L + ) + ) + ); + } + } + + // The greater the depth the more accurate the colours, but + // this is exponentially (!) expensive + if(depth <= this.options.rayDepth){ + // calculate reflection ray + if(this.options.renderReflections && info.shape.material.reflection > 0) + { + var reflectionRay = this.getReflectionRay(info.position, info.normal, ray.direction); + var refl = this.testIntersection(reflectionRay, scene, info.shape); + + if (refl.isHit && refl.distance > 0){ + refl.color = this.rayTrace(refl, reflectionRay, scene, depth + 1); + } else { + refl.color = scene.background.color; + } + + color = Flog.RayTracer.Color.prototype.blend( + color, + refl.color, + info.shape.material.reflection + ); + } + + // Refraction + /* TODO */ + } + + /* Render shadows and highlights */ + + var shadowInfo = new Flog.RayTracer.IntersectionInfo(); + + if(this.options.renderShadows){ + var shadowRay = new Flog.RayTracer.Ray(info.position, v); + + shadowInfo = this.testIntersection(shadowRay, scene, info.shape); + if(shadowInfo.isHit && shadowInfo.shape != info.shape /*&& shadowInfo.shape.type != 'PLANE'*/){ + var vA = Flog.RayTracer.Color.prototype.multiplyScalar(color, 0.5); + var dB = (0.5 * Math.pow(shadowInfo.shape.material.transparency, 0.5)); + color = Flog.RayTracer.Color.prototype.addScalar(vA,dB); + } + } + + // Phong specular highlights + if(this.options.renderHighlights && !shadowInfo.isHit && info.shape.material.gloss > 0){ + var Lv = Flog.RayTracer.Vector.prototype.subtract( + info.shape.position, + light.position + ).normalize(); + + var E = Flog.RayTracer.Vector.prototype.subtract( + scene.camera.position, + info.shape.position + ).normalize(); + + var H = Flog.RayTracer.Vector.prototype.subtract( + E, + Lv + ).normalize(); + + var glossWeight = Math.pow(Math.max(info.normal.dot(H), 0), shininess); + color = Flog.RayTracer.Color.prototype.add( + Flog.RayTracer.Color.prototype.multiplyScalar(light.color, glossWeight), + color + ); + } + } + color.limit(); + return color; + } +}; + + +function renderScene(){ + var scene = new Flog.RayTracer.Scene(); + + scene.camera = new Flog.RayTracer.Camera( + new Flog.RayTracer.Vector(0, 0, -15), + new Flog.RayTracer.Vector(-0.2, 0, 5), + new Flog.RayTracer.Vector(0, 1, 0) + ); + + scene.background = new Flog.RayTracer.Background( + new Flog.RayTracer.Color(0.5, 0.5, 0.5), + 0.4 + ); + + var sphere = new Flog.RayTracer.Shape.Sphere( + new Flog.RayTracer.Vector(-1.5, 1.5, 2), + 1.5, + new Flog.RayTracer.Material.Solid( + new Flog.RayTracer.Color(0,0.5,0.5), + 0.3, + 0.0, + 0.0, + 2.0 + ) + ); + + var sphere1 = new Flog.RayTracer.Shape.Sphere( + new Flog.RayTracer.Vector(1, 0.25, 1), + 0.5, + new Flog.RayTracer.Material.Solid( + new Flog.RayTracer.Color(0.9,0.9,0.9), + 0.1, + 0.0, + 0.0, + 1.5 + ) + ); + + var plane = new Flog.RayTracer.Shape.Plane( + new Flog.RayTracer.Vector(0.1, 0.9, -0.5).normalize(), + 1.2, + new Flog.RayTracer.Material.Chessboard( + new Flog.RayTracer.Color(1,1,1), + new Flog.RayTracer.Color(0,0,0), + 0.2, + 0.0, + 1.0, + 0.7 + ) + ); + + scene.shapes.push(plane); + scene.shapes.push(sphere); + scene.shapes.push(sphere1); + + var light = new Flog.RayTracer.Light( + new Flog.RayTracer.Vector(5, 10, -1), + new Flog.RayTracer.Color(0.8, 0.8, 0.8) + ); + + var light1 = new Flog.RayTracer.Light( + new Flog.RayTracer.Vector(-3, 5, -15), + new Flog.RayTracer.Color(0.8, 0.8, 0.8), + 100 + ); + + scene.lights.push(light); + scene.lights.push(light1); + + var imageWidth = 100; // $F('imageWidth'); + var imageHeight = 100; // $F('imageHeight'); + var pixelSize = "5,5".split(','); // $F('pixelSize').split(','); + var renderDiffuse = true; // $F('renderDiffuse'); + var renderShadows = true; // $F('renderShadows'); + var renderHighlights = true; // $F('renderHighlights'); + var renderReflections = true; // $F('renderReflections'); + var rayDepth = 2;//$F('rayDepth'); + + var raytracer = new Flog.RayTracer.Engine( + { + canvasWidth: imageWidth, + canvasHeight: imageHeight, + pixelWidth: pixelSize[0], + pixelHeight: pixelSize[1], + "renderDiffuse": renderDiffuse, + "renderHighlights": renderHighlights, + "renderShadows": renderShadows, + "renderReflections": renderReflections, + "rayDepth": rayDepth + } + ); + + raytracer.renderScene(scene, null, 0); +} +// This file is automatically generated by scheme2js, except for the +// benchmark harness code at the beginning and end of the file. + +var EarleyBoyer = new BenchmarkSuite('EarleyBoyer', 666463, [ + new Benchmark("Earley", function () { BgL_earleyzd2benchmarkzd2(); }), + new Benchmark("Boyer", function () { BgL_nboyerzd2benchmarkzd2(); }) +]); + + +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/************* GENERATED FILE - DO NOT EDIT *************/ +/* + * To use write/prints/... the default-output port has to be set first. + * Simply setting SC_DEFAULT_OUT and SC_ERROR_OUT to the desired values + * should do the trick. + * In the following example the std-out and error-port are redirected to + * a DIV. +function initRuntime() { + function escapeHTML(s) { + var tmp = s; + tmp = tmp.replace(/&/g, "&"); + tmp = tmp.replace(/</g, "<"); + tmp = tmp.replace(/>/g, ">"); + tmp = tmp.replace(/ /g, " "); + tmp = tmp.replace(/\n/g, "<br />"); + tmp = tmp.replace(/\t/g, "  "); + return tmp; + + } + + document.write("<div id='stdout'></div>"); + SC_DEFAULT_OUT = new sc_GenericOutputPort( + function(s) { + var stdout = document.getElementById('stdout'); + stdout.innerHTML = stdout.innerHTML + escapeHTML(s); + }); + SC_ERROR_OUT = SC_DEFAULT_OUT; +} +*/ + + +function sc_print_debug() { + sc_print.apply(null, arguments); +} +/*** META ((export *js*)) */ +var sc_JS_GLOBALS = this; + +var __sc_LINE=-1; +var __sc_FILE=""; + +/*** META ((export #t)) */ +function sc_alert() { + var len = arguments.length; + var s = ""; + var i; + + for( i = 0; i < len; i++ ) { + s += sc_toDisplayString(arguments[ i ]); + } + + return alert( s ); +} + +/*** META ((export #t)) */ +function sc_typeof( x ) { + return typeof x; +} + +/*** META ((export #t)) */ +function sc_error() { + var a = [sc_jsstring2symbol("*error*")]; + for (var i = 0; i < arguments.length; i++) { + a[i+1] = arguments[i]; + } + throw a; +} + +/*** META ((export #t) + (peephole (prefix "throw "))) +*/ +function sc_raise(obj) { + throw obj; +} + +/*** META ((export with-handler-lambda)) */ +function sc_withHandlerLambda(handler, body) { + try { + return body(); + } catch(e) { + if (!e._internalException) + return handler(e); + else + throw e; + } +} + +var sc_properties = new Object(); + +/*** META ((export #t)) */ +function sc_putpropBang(sym, key, val) { + var ht = sc_properties[sym]; + if (!ht) { + ht = new Object(); + sc_properties[sym] = ht; + } + ht[key] = val; +} + +/*** META ((export #t)) */ +function sc_getprop(sym, key) { + var ht = sc_properties[sym]; + if (ht) { + if (key in ht) + return ht[key]; + else + return false; + } else + return false; +} + +/*** META ((export #t)) */ +function sc_rempropBang(sym, key) { + var ht = sc_properties[sym]; + if (ht) + delete ht[key]; +} + +/*** META ((export #t)) */ +function sc_any2String(o) { + return jsstring2string(sc_toDisplayString(o)); +} + +/*** META ((export #t) + (peephole (infix 2 2 "===")) + (type bool)) +*/ +function sc_isEqv(o1, o2) { + return (o1 === o2); +} + +/*** META ((export #t) + (peephole (infix 2 2 "===")) + (type bool)) +*/ +function sc_isEq(o1, o2) { + return (o1 === o2); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isNumber(n) { + return (typeof n === "number"); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isComplex(n) { + return sc_isNumber(n); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isReal(n) { + return sc_isNumber(n); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isRational(n) { + return sc_isReal(n); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isInteger(n) { + return (parseInt(n) === n); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix ", false"))) +*/ +// we don't have exact numbers... +function sc_isExact(n) { + return false; +} + +/*** META ((export #t) + (peephole (postfix ", true")) + (type bool)) +*/ +function sc_isInexact(n) { + return true; +} + +/*** META ((export = =fx =fl) + (type bool) + (peephole (infix 2 2 "==="))) +*/ +function sc_equal(x) { + for (var i = 1; i < arguments.length; i++) + if (x !== arguments[i]) + return false; + return true; +} + +/*** META ((export < <fx <fl) + (type bool) + (peephole (infix 2 2 "<"))) +*/ +function sc_less(x) { + for (var i = 1; i < arguments.length; i++) { + if (x >= arguments[i]) + return false; + x = arguments[i]; + } + return true; +} + +/*** META ((export > >fx >fl) + (type bool) + (peephole (infix 2 2 ">"))) +*/ +function sc_greater(x, y) { + for (var i = 1; i < arguments.length; i++) { + if (x <= arguments[i]) + return false; + x = arguments[i]; + } + return true; +} + +/*** META ((export <= <=fx <=fl) + (type bool) + (peephole (infix 2 2 "<="))) +*/ +function sc_lessEqual(x, y) { + for (var i = 1; i < arguments.length; i++) { + if (x > arguments[i]) + return false; + x = arguments[i]; + } + return true; +} + +/*** META ((export >= >=fl >=fx) + (type bool) + (peephole (infix 2 2 ">="))) +*/ +function sc_greaterEqual(x, y) { + for (var i = 1; i < arguments.length; i++) { + if (x < arguments[i]) + return false; + x = arguments[i]; + } + return true; +} + +/*** META ((export #t) + (type bool) + (peephole (postfix "=== 0"))) +*/ +function sc_isZero(x) { + return (x === 0); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix "> 0"))) +*/ +function sc_isPositive(x) { + return (x > 0); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix "< 0"))) +*/ +function sc_isNegative(x) { + return (x < 0); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix "%2===1"))) +*/ +function sc_isOdd(x) { + return (x % 2 === 1); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix "%2===0"))) +*/ +function sc_isEven(x) { + return (x % 2 === 0); +} + +/*** META ((export #t)) */ +var sc_max = Math.max; +/*** META ((export #t)) */ +var sc_min = Math.min; + +/*** META ((export + +fx +fl) + (peephole (infix 0 #f "+" "0"))) +*/ +function sc_plus() { + var sum = 0; + for (var i = 0; i < arguments.length; i++) + sum += arguments[i]; + return sum; +} + +/*** META ((export * *fx *fl) + (peephole (infix 0 #f "*" "1"))) +*/ +function sc_multi() { + var product = 1; + for (var i = 0; i < arguments.length; i++) + product *= arguments[i]; + return product; +} + +/*** META ((export - -fx -fl) + (peephole (minus))) +*/ +function sc_minus(x) { + if (arguments.length === 1) + return -x; + else { + var res = x; + for (var i = 1; i < arguments.length; i++) + res -= arguments[i]; + return res; + } +} + +/*** META ((export / /fl) + (peephole (div))) +*/ +function sc_div(x) { + if (arguments.length === 1) + return 1/x; + else { + var res = x; + for (var i = 1; i < arguments.length; i++) + res /= arguments[i]; + return res; + } +} + +/*** META ((export #t)) */ +var sc_abs = Math.abs; + +/*** META ((export quotient /fx) + (peephole (hole 2 "parseInt(" x "/" y ")"))) +*/ +function sc_quotient(x, y) { + return parseInt(x / y); +} + +/*** META ((export #t) + (peephole (infix 2 2 "%"))) +*/ +function sc_remainder(x, y) { + return x % y; +} + +/*** META ((export #t) + (peephole (modulo))) +*/ +function sc_modulo(x, y) { + var remainder = x % y; + // if they don't have the same sign + if ((remainder * y) < 0) + return remainder + y; + else + return remainder; +} + +function sc_euclid_gcd(a, b) { + var temp; + if (a === 0) return b; + if (b === 0) return a; + if (a < 0) {a = -a;}; + if (b < 0) {b = -b;}; + if (b > a) {temp = a; a = b; b = temp;}; + while (true) { + a %= b; + if(a === 0) {return b;}; + b %= a; + if(b === 0) {return a;}; + }; + return b; +} + +/*** META ((export #t)) */ +function sc_gcd() { + var gcd = 0; + for (var i = 0; i < arguments.length; i++) + gcd = sc_euclid_gcd(gcd, arguments[i]); + return gcd; +} + +/*** META ((export #t)) */ +function sc_lcm() { + var lcm = 1; + for (var i = 0; i < arguments.length; i++) { + var f = Math.round(arguments[i] / sc_euclid_gcd(arguments[i], lcm)); + lcm *= Math.abs(f); + } + return lcm; +} + +// LIMITATION: numerator and denominator don't make sense in floating point world. +//var SC_MAX_DECIMALS = 1000000 +// +// function sc_numerator(x) { +// var rounded = Math.round(x * SC_MAX_DECIMALS); +// return Math.round(rounded / sc_euclid_gcd(rounded, SC_MAX_DECIMALS)); +// } + +// function sc_denominator(x) { +// var rounded = Math.round(x * SC_MAX_DECIMALS); +// return Math.round(SC_MAX_DECIMALS / sc_euclid_gcd(rounded, SC_MAX_DECIMALS)); +// } + +/*** META ((export #t)) */ +var sc_floor = Math.floor; +/*** META ((export #t)) */ +var sc_ceiling = Math.ceil; +/*** META ((export #t)) */ +var sc_truncate = parseInt; +/*** META ((export #t)) */ +var sc_round = Math.round; + +// LIMITATION: sc_rationalize doesn't make sense in a floating point world. + +/*** META ((export #t)) */ +var sc_exp = Math.exp; +/*** META ((export #t)) */ +var sc_log = Math.log; +/*** META ((export #t)) */ +var sc_sin = Math.sin; +/*** META ((export #t)) */ +var sc_cos = Math.cos; +/*** META ((export #t)) */ +var sc_tan = Math.tan; +/*** META ((export #t)) */ +var sc_asin = Math.asin; +/*** META ((export #t)) */ +var sc_acos = Math.acos; +/*** META ((export #t)) */ +var sc_atan = Math.atan; + +/*** META ((export #t)) */ +var sc_sqrt = Math.sqrt; +/*** META ((export #t)) */ +var sc_expt = Math.pow; + +// LIMITATION: we don't have complex numbers. +// LIMITATION: the following functions are hence not implemented. +// LIMITATION: make-rectangular, make-polar, real-part, imag-part, magnitude, angle +// LIMITATION: 2 argument atan + +/*** META ((export #t) + (peephole (id))) +*/ +function sc_exact2inexact(x) { + return x; +} + +/*** META ((export #t) + (peephole (id))) +*/ +function sc_inexact2exact(x) { + return x; +} + +function sc_number2jsstring(x, radix) { + if (radix) + return x.toString(radix); + else + return x.toString(); +} + +function sc_jsstring2number(s, radix) { + if (s === "") return false; + + if (radix) { + var t = parseInt(s, radix); + if (!t && t !== 0) return false; + // verify that each char is in range. (parseInt ignores leading + // white and trailing chars) + var allowedChars = "01234567890abcdefghijklmnopqrstuvwxyz".substring(0, radix+1); + if ((new RegExp("^["+allowedChars+"]*$", "i")).test(s)) + return t; + else return false; + } else { + var t = +s; // does not ignore trailing chars. + if (!t && t !== 0) return false; + // simply verify that first char is not whitespace. + var c = s.charAt(0); + // if +c is 0, but the char is not "0", then we have a whitespace. + if (+c === 0 && c !== "0") return false; + return t; + } +} + +/*** META ((export #t) + (type bool) + (peephole (not))) +*/ +function sc_not(b) { + return b === false; +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isBoolean(b) { + return (b === true) || (b === false); +} + +function sc_Pair(car, cdr) { + this.car = car; + this.cdr = cdr; +} + +sc_Pair.prototype.toString = function() { + return sc_toDisplayString(this); +}; +sc_Pair.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) { + var current = this; + + var res = "("; + + while(true) { + res += writeOrDisplay(current.car); + if (sc_isPair(current.cdr)) { + res += " "; + current = current.cdr; + } else if (current.cdr !== null) { + res += " . " + writeOrDisplay(current.cdr); + break; + } else // current.cdr == null + break; + } + + res += ")"; + + return res; +}; +sc_Pair.prototype.sc_toDisplayString = function() { + return this.sc_toWriteOrDisplayString(sc_toDisplayString); +}; +sc_Pair.prototype.sc_toWriteString = function() { + return this.sc_toWriteOrDisplayString(sc_toWriteString); +}; +// sc_Pair.prototype.sc_toWriteCircleString in IO.js + +/*** META ((export #t) + (type bool) + (peephole (postfix " instanceof sc_Pair"))) +*/ +function sc_isPair(p) { + return (p instanceof sc_Pair); +} + +function sc_isPairEqual(p1, p2, comp) { + return (comp(p1.car, p2.car) && comp(p1.cdr, p2.cdr)); +} + +/*** META ((export #t) + (peephole (hole 2 "new sc_Pair(" car ", " cdr ")"))) +*/ +function sc_cons(car, cdr) { + return new sc_Pair(car, cdr); +} + +/*** META ((export cons*)) */ +function sc_consStar() { + var res = arguments[arguments.length - 1]; + for (var i = arguments.length-2; i >= 0; i--) + res = new sc_Pair(arguments[i], res); + return res; +} + +/*** META ((export #t) + (peephole (postfix ".car"))) +*/ +function sc_car(p) { + return p.car; +} + +/*** META ((export #t) + (peephole (postfix ".cdr"))) +*/ +function sc_cdr(p) { + return p.cdr; +} + +/*** META ((export #t) + (peephole (hole 2 p ".car = " val))) +*/ +function sc_setCarBang(p, val) { + p.car = val; +} + +/*** META ((export #t) + (peephole (hole 2 p ".cdr = " val))) +*/ +function sc_setCdrBang(p, val) { + p.cdr = val; +} + +/*** META ((export #t) + (peephole (postfix ".car.car"))) +*/ +function sc_caar(p) { return p.car.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.car"))) +*/ +function sc_cadr(p) { return p.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".car.cdr"))) +*/ +function sc_cdar(p) { return p.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr"))) +*/ +function sc_cddr(p) { return p.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.car.car"))) +*/ +function sc_caaar(p) { return p.car.car.car; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.car"))) +*/ +function sc_cadar(p) { return p.car.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.car"))) +*/ +function sc_caadr(p) { return p.cdr.car.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.car"))) +*/ +function sc_caddr(p) { return p.cdr.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".car.car.cdr"))) +*/ +function sc_cdaar(p) { return p.car.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.cdr"))) +*/ +function sc_cdadr(p) { return p.cdr.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.cdr"))) +*/ +function sc_cddar(p) { return p.car.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.cdr"))) +*/ +function sc_cdddr(p) { return p.cdr.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.car.car.car"))) +*/ +function sc_caaaar(p) { return p.car.car.car.car; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.car.car"))) +*/ +function sc_caadar(p) { return p.car.cdr.car.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.car.car"))) +*/ +function sc_caaadr(p) { return p.cdr.car.car.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.car.car"))) +*/ +function sc_caaddr(p) { return p.cdr.cdr.car.car; } +/*** META ((export #t) + (peephole (postfix ".car.car.car.cdr"))) +*/ +function sc_cdaaar(p) { return p.car.car.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.car.cdr"))) +*/ +function sc_cdadar(p) { return p.car.cdr.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.car.cdr"))) +*/ +function sc_cdaadr(p) { return p.cdr.car.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.car.cdr"))) +*/ +function sc_cdaddr(p) { return p.cdr.cdr.car.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.car.cdr.car"))) +*/ +function sc_cadaar(p) { return p.car.car.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.cdr.car"))) +*/ +function sc_caddar(p) { return p.car.cdr.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.cdr.car"))) +*/ +function sc_cadadr(p) { return p.cdr.car.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.cdr.car"))) +*/ +function sc_cadddr(p) { return p.cdr.cdr.cdr.car; } +/*** META ((export #t) + (peephole (postfix ".car.car.cdr.cdr"))) +*/ +function sc_cddaar(p) { return p.car.car.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".car.cdr.cdr.cdr"))) +*/ +function sc_cdddar(p) { return p.car.cdr.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.car.cdr.cdr"))) +*/ +function sc_cddadr(p) { return p.cdr.car.cdr.cdr; } +/*** META ((export #t) + (peephole (postfix ".cdr.cdr.cdr.cdr"))) +*/ +function sc_cddddr(p) { return p.cdr.cdr.cdr.cdr; } + +/*** META ((export #t)) */ +function sc_lastPair(l) { + if (!sc_isPair(l)) sc_error("sc_lastPair: pair expected"); + var res = l; + var cdr = l.cdr; + while (sc_isPair(cdr)) { + res = cdr; + cdr = res.cdr; + } + return res; +} + +/*** META ((export #t) + (type bool) + (peephole (postfix " === null"))) +*/ +function sc_isNull(o) { + return (o === null); +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isList(o) { + var rabbit; + var turtle; + + var rabbit = o; + var turtle = o; + while (true) { + if (rabbit === null || + (rabbit instanceof sc_Pair && rabbit.cdr === null)) + return true; // end of list + else if ((rabbit instanceof sc_Pair) && + (rabbit.cdr instanceof sc_Pair)) { + rabbit = rabbit.cdr.cdr; + turtle = turtle.cdr; + if (rabbit === turtle) return false; // cycle + } else + return false; // not pair + } +} + +/*** META ((export #t)) */ +function sc_list() { + var res = null; + var a = arguments; + for (var i = a.length-1; i >= 0; i--) + res = new sc_Pair(a[i], res); + return res; +} + +/*** META ((export #t)) */ +function sc_iota(num, init) { + var res = null; + if (!init) init = 0; + for (var i = num - 1; i >= 0; i--) + res = new sc_Pair(i + init, res); + return res; +} + +/*** META ((export #t)) */ +function sc_makeList(nbEls, fill) { + var res = null; + for (var i = 0; i < nbEls; i++) + res = new sc_Pair(fill, res); + return res; +} + +/*** META ((export #t)) */ +function sc_length(l) { + var res = 0; + while (l !== null) { + res++; + l = l.cdr; + } + return res; +} + +/*** META ((export #t)) */ +function sc_remq(o, l) { + var dummy = { cdr : null }; + var tail = dummy; + while (l !== null) { + if (l.car !== o) { + tail.cdr = sc_cons(l.car, null); + tail = tail.cdr; + } + l = l.cdr; + } + return dummy.cdr; +} + +/*** META ((export #t)) */ +function sc_remqBang(o, l) { + var dummy = { cdr : null }; + var tail = dummy; + var needsAssig = true; + while (l !== null) { + if (l.car === o) { + needsAssig = true; + } else { + if (needsAssig) { + tail.cdr = l; + needsAssig = false; + } + tail = l; + } + l = l.cdr; + } + tail.cdr = null; + return dummy.cdr; +} + +/*** META ((export #t)) */ +function sc_delete(o, l) { + var dummy = { cdr : null }; + var tail = dummy; + while (l !== null) { + if (!sc_isEqual(l.car, o)) { + tail.cdr = sc_cons(l.car, null); + tail = tail.cdr; + } + l = l.cdr; + } + return dummy.cdr; +} + +/*** META ((export #t)) */ +function sc_deleteBang(o, l) { + var dummy = { cdr : null }; + var tail = dummy; + var needsAssig = true; + while (l !== null) { + if (sc_isEqual(l.car, o)) { + needsAssig = true; + } else { + if (needsAssig) { + tail.cdr = l; + needsAssig = false; + } + tail = l; + } + l = l.cdr; + } + tail.cdr = null; + return dummy.cdr; +} + +function sc_reverseAppendBang(l1, l2) { + var res = l2; + while (l1 !== null) { + var tmp = res; + res = l1; + l1 = l1.cdr; + res.cdr = tmp; + } + return res; +} + +function sc_dualAppend(l1, l2) { + if (l1 === null) return l2; + if (l2 === null) return l1; + var rev = sc_reverse(l1); + return sc_reverseAppendBang(rev, l2); +} + +/*** META ((export #t)) */ +function sc_append() { + if (arguments.length === 0) + return null; + var res = arguments[arguments.length - 1]; + for (var i = arguments.length - 2; i >= 0; i--) + res = sc_dualAppend(arguments[i], res); + return res; +} + +function sc_dualAppendBang(l1, l2) { + if (l1 === null) return l2; + if (l2 === null) return l1; + var tmp = l1; + while (tmp.cdr !== null) tmp=tmp.cdr; + tmp.cdr = l2; + return l1; +} + +/*** META ((export #t)) */ +function sc_appendBang() { + var res = null; + for (var i = 0; i < arguments.length; i++) + res = sc_dualAppendBang(res, arguments[i]); + return res; +} + +/*** META ((export #t)) */ +function sc_reverse(l1) { + var res = null; + while (l1 !== null) { + res = sc_cons(l1.car, res); + l1 = l1.cdr; + } + return res; +} + +/*** META ((export #t)) */ +function sc_reverseBang(l) { + return sc_reverseAppendBang(l, null); +} + +/*** META ((export #t)) */ +function sc_listTail(l, k) { + var res = l; + for (var i = 0; i < k; i++) { + res = res.cdr; + } + return res; +} + +/*** META ((export #t)) */ +function sc_listRef(l, k) { + return sc_listTail(l, k).car; +} + +/* // unoptimized generic versions +function sc_memX(o, l, comp) { + while (l != null) { + if (comp(l.car, o)) + return l; + l = l.cdr; + } + return false; +} +function sc_memq(o, l) { return sc_memX(o, l, sc_isEq); } +function sc_memv(o, l) { return sc_memX(o, l, sc_isEqv); } +function sc_member(o, l) { return sc_memX(o, l, sc_isEqual); } +*/ + +/* optimized versions */ +/*** META ((export #t)) */ +function sc_memq(o, l) { + while (l !== null) { + if (l.car === o) + return l; + l = l.cdr; + } + return false; +} +/*** META ((export #t)) */ +function sc_memv(o, l) { + while (l !== null) { + if (l.car === o) + return l; + l = l.cdr; + } + return false; +} +/*** META ((export #t)) */ +function sc_member(o, l) { + while (l !== null) { + if (sc_isEqual(l.car,o)) + return l; + l = l.cdr; + } + return false; +} + +/* // generic unoptimized versions +function sc_assX(o, al, comp) { + while (al != null) { + if (comp(al.car.car, o)) + return al.car; + al = al.cdr; + } + return false; +} +function sc_assq(o, al) { return sc_assX(o, al, sc_isEq); } +function sc_assv(o, al) { return sc_assX(o, al, sc_isEqv); } +function sc_assoc(o, al) { return sc_assX(o, al, sc_isEqual); } +*/ +// optimized versions +/*** META ((export #t)) */ +function sc_assq(o, al) { + while (al !== null) { + if (al.car.car === o) + return al.car; + al = al.cdr; + } + return false; +} +/*** META ((export #t)) */ +function sc_assv(o, al) { + while (al !== null) { + if (al.car.car === o) + return al.car; + al = al.cdr; + } + return false; +} +/*** META ((export #t)) */ +function sc_assoc(o, al) { + while (al !== null) { + if (sc_isEqual(al.car.car, o)) + return al.car; + al = al.cdr; + } + return false; +} + +/* can be used for mutable strings and characters */ +function sc_isCharStringEqual(cs1, cs2) { return cs1.val === cs2.val; } +function sc_isCharStringLess(cs1, cs2) { return cs1.val < cs2.val; } +function sc_isCharStringGreater(cs1, cs2) { return cs1.val > cs2.val; } +function sc_isCharStringLessEqual(cs1, cs2) { return cs1.val <= cs2.val; } +function sc_isCharStringGreaterEqual(cs1, cs2) { return cs1.val >= cs2.val; } +function sc_isCharStringCIEqual(cs1, cs2) + { return cs1.val.toLowerCase() === cs2.val.toLowerCase(); } +function sc_isCharStringCILess(cs1, cs2) + { return cs1.val.toLowerCase() < cs2.val.toLowerCase(); } +function sc_isCharStringCIGreater(cs1, cs2) + { return cs1.val.toLowerCase() > cs2.val.toLowerCase(); } +function sc_isCharStringCILessEqual(cs1, cs2) + { return cs1.val.toLowerCase() <= cs2.val.toLowerCase(); } +function sc_isCharStringCIGreaterEqual(cs1, cs2) + { return cs1.val.toLowerCase() >= cs2.val.toLowerCase(); } + + + + +function sc_Char(c) { + var cached = sc_Char.lazy[c]; + if (cached) + return cached; + this.val = c; + sc_Char.lazy[c] = this; + // add return, so FF does not complain. + return undefined; +} +sc_Char.lazy = new Object(); +// thanks to Eric +sc_Char.char2readable = { +// "\000": "#\\null", +// "\007": "#\\bell", +// "\010": "#\\backspace", +// "\011": "#\\tab", +// "\012": "#\\newline", +// "\014": "#\\page", +// "\015": "#\\return", +// "\033": "#\\escape", +// "\040": "#\\space", +// "\177": "#\\delete", + +// /* poeticless names */ +// "\001": "#\\soh", +// "\002": "#\\stx", +// "\003": "#\\etx", +// "\004": "#\\eot", +// "\005": "#\\enq", +// "\006": "#\\ack", + +// "\013": "#\\vt", +// "\016": "#\\so", +// "\017": "#\\si", + +// "\020": "#\\dle", +// "\021": "#\\dc1", +// "\022": "#\\dc2", +// "\023": "#\\dc3", +// "\024": "#\\dc4", +// "\025": "#\\nak", +// "\026": "#\\syn", +// "\027": "#\\etb", + +// "\030": "#\\can", +// "\031": "#\\em", +// "\032": "#\\sub", +// "\033": "#\\esc", +// "\034": "#\\fs", +// "\035": "#\\gs", +// "\036": "#\\rs", +// "\037": "#\\us" +}; + +sc_Char.readable2char = { +// "null": "\000", +// "bell": "\007", +// "backspace": "\010", +// "tab": "\011", +// "newline": "\012", +// "page": "\014", +// "return": "\015", +// "escape": "\033", +// "space": "\040", +// "delete": "\000", +// "soh": "\001", +// "stx": "\002", +// "etx": "\003", +// "eot": "\004", +// "enq": "\005", +// "ack": "\006", +// "bel": "\007", +// "bs": "\010", +// "ht": "\011", +// "nl": "\012", +// "vt": "\013", +// "np": "\014", +// "cr": "\015", +// "so": "\016", +// "si": "\017", +// "dle": "\020", +// "dc1": "\021", +// "dc2": "\022", +// "dc3": "\023", +// "dc4": "\024", +// "nak": "\025", +// "syn": "\026", +// "etb": "\027", +// "can": "\030", +// "em": "\031", +// "sub": "\032", +// "esc": "\033", +// "fs": "\034", +// "gs": "\035", +// "rs": "\036", +// "us": "\037", +// "sp": "\040", +// "del": "\177" +}; + +sc_Char.prototype.toString = function() { + return this.val; +}; +// sc_toDisplayString == toString +sc_Char.prototype.sc_toWriteString = function() { + var entry = sc_Char.char2readable[this.val]; + if (entry) + return entry; + else + return "#\\" + this.val; +}; + +/*** META ((export #t) + (type bool) + (peephole (postfix "instanceof sc_Char"))) +*/ +function sc_isChar(c) { + return (c instanceof sc_Char); +} + +/*** META ((export char=?) + (type bool) + (peephole (hole 2 c1 ".val === " c2 ".val"))) +*/ +var sc_isCharEqual = sc_isCharStringEqual; +/*** META ((export char<?) + (type bool) + (peephole (hole 2 c1 ".val < " c2 ".val"))) +*/ +var sc_isCharLess = sc_isCharStringLess; +/*** META ((export char>?) + (type bool) + (peephole (hole 2 c1 ".val > " c2 ".val"))) +*/ +var sc_isCharGreater = sc_isCharStringGreater; +/*** META ((export char<=?) + (type bool) + (peephole (hole 2 c1 ".val <= " c2 ".val"))) +*/ +var sc_isCharLessEqual = sc_isCharStringLessEqual; +/*** META ((export char>=?) + (type bool) + (peephole (hole 2 c1 ".val >= " c2 ".val"))) +*/ +var sc_isCharGreaterEqual = sc_isCharStringGreaterEqual; +/*** META ((export char-ci=?) + (type bool) + (peephole (hole 2 c1 ".val.toLowerCase() === " c2 ".val.toLowerCase()"))) +*/ +var sc_isCharCIEqual = sc_isCharStringCIEqual; +/*** META ((export char-ci<?) + (type bool) + (peephole (hole 2 c1 ".val.toLowerCase() < " c2 ".val.toLowerCase()"))) +*/ +var sc_isCharCILess = sc_isCharStringCILess; +/*** META ((export char-ci>?) + (type bool) + (peephole (hole 2 c1 ".val.toLowerCase() > " c2 ".val.toLowerCase()"))) +*/ +var sc_isCharCIGreater = sc_isCharStringCIGreater; +/*** META ((export char-ci<=?) + (type bool) + (peephole (hole 2 c1 ".val.toLowerCase() <= " c2 ".val.toLowerCase()"))) +*/ +var sc_isCharCILessEqual = sc_isCharStringCILessEqual; +/*** META ((export char-ci>=?) + (type bool) + (peephole (hole 2 c1 ".val.toLowerCase() >= " c2 ".val.toLowerCase()"))) +*/ +var sc_isCharCIGreaterEqual = sc_isCharStringCIGreaterEqual; + +var SC_NUMBER_CLASS = "0123456789"; +var SC_WHITESPACE_CLASS = ' \r\n\t\f'; +var SC_LOWER_CLASS = 'abcdefghijklmnopqrstuvwxyz'; +var SC_UPPER_CLASS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +function sc_isCharOfClass(c, cl) { return (cl.indexOf(c) != -1); } +/*** META ((export #t) + (type bool)) +*/ +function sc_isCharAlphabetic(c) + { return sc_isCharOfClass(c.val, SC_LOWER_CLASS) || + sc_isCharOfClass(c.val, SC_UPPER_CLASS); } +/*** META ((export #t) + (type bool) + (peephole (hole 1 "SC_NUMBER_CLASS.indexOf(" c ".val) != -1"))) +*/ +function sc_isCharNumeric(c) + { return sc_isCharOfClass(c.val, SC_NUMBER_CLASS); } +/*** META ((export #t) + (type bool)) +*/ +function sc_isCharWhitespace(c) { + var tmp = c.val; + return tmp === " " || tmp === "\r" || tmp === "\n" || tmp === "\t" || tmp === "\f"; +} +/*** META ((export #t) + (type bool) + (peephole (hole 1 "SC_UPPER_CLASS.indexOf(" c ".val) != -1"))) +*/ +function sc_isCharUpperCase(c) + { return sc_isCharOfClass(c.val, SC_UPPER_CLASS); } +/*** META ((export #t) + (type bool) + (peephole (hole 1 "SC_LOWER_CLASS.indexOf(" c ".val) != -1"))) +*/ +function sc_isCharLowerCase(c) + { return sc_isCharOfClass(c.val, SC_LOWER_CLASS); } + +/*** META ((export #t) + (peephole (postfix ".val.charCodeAt(0)"))) +*/ +function sc_char2integer(c) + { return c.val.charCodeAt(0); } +/*** META ((export #t) + (peephole (hole 1 "new sc_Char(String.fromCharCode(" n "))"))) +*/ +function sc_integer2char(n) + { return new sc_Char(String.fromCharCode(n)); } + +/*** META ((export #t) + (peephole (hole 1 "new sc_Char(" c ".val.toUpperCase())"))) +*/ +function sc_charUpcase(c) + { return new sc_Char(c.val.toUpperCase()); } +/*** META ((export #t) + (peephole (hole 1 "new sc_Char(" c ".val.toLowerCase())"))) +*/ +function sc_charDowncase(c) + { return new sc_Char(c.val.toLowerCase()); } + +function sc_makeJSStringOfLength(k, c) { + var fill; + if (c === undefined) + fill = " "; + else + fill = c; + var res = ""; + var len = 1; + // every round doubles the size of fill. + while (k >= len) { + if (k & len) + res = res.concat(fill); + fill = fill.concat(fill); + len *= 2; + } + return res; +} + +function sc_makejsString(k, c) { + var fill; + if (c) + fill = c.val; + else + fill = " "; + return sc_makeJSStringOfLength(k, fill); +} + +function sc_jsstring2list(s) { + var res = null; + for (var i = s.length - 1; i >= 0; i--) + res = sc_cons(new sc_Char(s.charAt(i)), res); + return res; +} + +function sc_list2jsstring(l) { + var a = new Array(); + while(l !== null) { + a.push(l.car.val); + l = l.cdr; + } + return "".concat.apply("", a); +} + +var sc_Vector = Array; + +sc_Vector.prototype.sc_toWriteOrDisplayString = function(writeOrDisplay) { + if (this.length === 0) return "#()"; + + var res = "#(" + writeOrDisplay(this[0]); + for (var i = 1; i < this.length; i++) + res += " " + writeOrDisplay(this[i]); + res += ")"; + return res; +}; +sc_Vector.prototype.sc_toDisplayString = function() { + return this.sc_toWriteOrDisplayString(sc_toDisplayString); +}; +sc_Vector.prototype.sc_toWriteString = function() { + return this.sc_toWriteOrDisplayString(sc_toWriteString); +}; + +/*** META ((export vector? array?) + (type bool) + (peephole (postfix " instanceof sc_Vector"))) +*/ +function sc_isVector(v) { + return (v instanceof sc_Vector); +} + +// only applies to vectors +function sc_isVectorEqual(v1, v2, comp) { + if (v1.length !== v2.length) return false; + for (var i = 0; i < v1.length; i++) + if (!comp(v1[i], v2[i])) return false; + return true; +} + +/*** META ((export make-vector make-array)) */ +function sc_makeVector(size, fill) { + var a = new sc_Vector(size); + if (fill !== undefined) + sc_vectorFillBang(a, fill); + return a; +} + +/*** META ((export vector array) + (peephole (vector))) +*/ +function sc_vector() { + var a = new sc_Vector(); + for (var i = 0; i < arguments.length; i++) + a.push(arguments[i]); + return a; +} + +/*** META ((export vector-length array-length) + (peephole (postfix ".length"))) +*/ +function sc_vectorLength(v) { + return v.length; +} + +/*** META ((export vector-ref array-ref) + (peephole (hole 2 v "[" pos "]"))) +*/ +function sc_vectorRef(v, pos) { + return v[pos]; +} + +/*** META ((export vector-set! array-set!) + (peephole (hole 3 v "[" pos "] = " val))) +*/ +function sc_vectorSetBang(v, pos, val) { + v[pos] = val; +} + +/*** META ((export vector->list array->list)) */ +function sc_vector2list(a) { + var res = null; + for (var i = a.length-1; i >= 0; i--) + res = sc_cons(a[i], res); + return res; +} + +/*** META ((export list->vector list->array)) */ +function sc_list2vector(l) { + var a = new sc_Vector(); + while(l !== null) { + a.push(l.car); + l = l.cdr; + } + return a; +} + +/*** META ((export vector-fill! array-fill!)) */ +function sc_vectorFillBang(a, fill) { + for (var i = 0; i < a.length; i++) + a[i] = fill; +} + + +/*** META ((export #t)) */ +function sc_copyVector(a, len) { + if (len <= a.length) + return a.slice(0, len); + else { + var tmp = a.concat(); + tmp.length = len; + return tmp; + } +} + +/*** META ((export #t) + (peephole (hole 3 a ".slice(" start "," end ")"))) +*/ +function sc_vectorCopy(a, start, end) { + return a.slice(start, end); +} + +/*** META ((export #t)) */ +function sc_vectorCopyBang(target, tstart, source, sstart, send) { + if (!sstart) sstart = 0; + if (!send) send = source.length; + + // if target == source we don't want to overwrite not yet copied elements. + if (tstart <= sstart) { + for (var i = tstart, j = sstart; j < send; i++, j++) { + target[i] = source[j]; + } + } else { + var diff = send - sstart; + for (var i = tstart + diff - 1, j = send - 1; + j >= sstart; + i--, j--) { + target[i] = source[j]; + } + } + return target; +} + +/*** META ((export #t) + (type bool) + (peephole (hole 1 "typeof " o " === 'function'"))) +*/ +function sc_isProcedure(o) { + return (typeof o === "function"); +} + +/*** META ((export #t)) */ +function sc_apply(proc) { + var args = new Array(); + // first part of arguments are not in list-form. + for (var i = 1; i < arguments.length - 1; i++) + args.push(arguments[i]); + var l = arguments[arguments.length - 1]; + while (l !== null) { + args.push(l.car); + l = l.cdr; + } + return proc.apply(null, args); +} + +/*** META ((export #t)) */ +function sc_map(proc, l1) { + if (l1 === undefined) + return null; + // else + var nbApplyArgs = arguments.length - 1; + var applyArgs = new Array(nbApplyArgs); + var revres = null; + while (l1 !== null) { + for (var i = 0; i < nbApplyArgs; i++) { + applyArgs[i] = arguments[i + 1].car; + arguments[i + 1] = arguments[i + 1].cdr; + } + revres = sc_cons(proc.apply(null, applyArgs), revres); + } + return sc_reverseAppendBang(revres, null); +} + +/*** META ((export #t)) */ +function sc_mapBang(proc, l1) { + if (l1 === undefined) + return null; + // else + var l1_orig = l1; + var nbApplyArgs = arguments.length - 1; + var applyArgs = new Array(nbApplyArgs); + while (l1 !== null) { + var tmp = l1; + for (var i = 0; i < nbApplyArgs; i++) { + applyArgs[i] = arguments[i + 1].car; + arguments[i + 1] = arguments[i + 1].cdr; + } + tmp.car = proc.apply(null, applyArgs); + } + return l1_orig; +} + +/*** META ((export #t)) */ +function sc_forEach(proc, l1) { + if (l1 === undefined) + return undefined; + // else + var nbApplyArgs = arguments.length - 1; + var applyArgs = new Array(nbApplyArgs); + while (l1 !== null) { + for (var i = 0; i < nbApplyArgs; i++) { + applyArgs[i] = arguments[i + 1].car; + arguments[i + 1] = arguments[i + 1].cdr; + } + proc.apply(null, applyArgs); + } + // add return so FF does not complain. + return undefined; +} + +/*** META ((export #t)) */ +function sc_filter(proc, l1) { + var dummy = { cdr : null }; + var tail = dummy; + while (l1 !== null) { + if (proc(l1.car) !== false) { + tail.cdr = sc_cons(l1.car, null); + tail = tail.cdr; + } + l1 = l1.cdr; + } + return dummy.cdr; +} + +/*** META ((export #t)) */ +function sc_filterBang(proc, l1) { + var head = sc_cons("dummy", l1); + var it = head; + var next = l1; + while (next !== null) { + if (proc(next.car) !== false) { + it.cdr = next + it = next; + } + next = next.cdr; + } + it.cdr = null; + return head.cdr; +} + +function sc_filterMap1(proc, l1) { + var revres = null; + while (l1 !== null) { + var tmp = proc(l1.car) + if (tmp !== false) revres = sc_cons(tmp, revres); + l1 = l1.cdr; + } + return sc_reverseAppendBang(revres, null); +} +function sc_filterMap2(proc, l1, l2) { + var revres = null; + while (l1 !== null) { + var tmp = proc(l1.car, l2.car); + if(tmp !== false) revres = sc_cons(tmp, revres); + l1 = l1.cdr; + l2 = l2.cdr + } + return sc_reverseAppendBang(revres, null); +} + +/*** META ((export #t)) */ +function sc_filterMap(proc, l1, l2, l3) { + if (l2 === undefined) + return sc_filterMap1(proc, l1); + else if (l3 === undefined) + return sc_filterMap2(proc, l1, l2); + // else + var nbApplyArgs = arguments.length - 1; + var applyArgs = new Array(nbApplyArgs); + var revres = null; + while (l1 !== null) { + for (var i = 0; i < nbApplyArgs; i++) { + applyArgs[i] = arguments[i + 1].car; + arguments[i + 1] = arguments[i + 1].cdr; + } + var tmp = proc.apply(null, applyArgs); + if(tmp !== false) revres = sc_cons(tmp, revres); + } + return sc_reverseAppendBang(revres, null); +} + +/*** META ((export #t)) */ +function sc_any(proc, l) { + var revres = null; + while (l !== null) { + var tmp = proc(l.car); + if(tmp !== false) return tmp; + l = l.cdr; + } + return false; +} + +/*** META ((export any?) + (peephole (hole 2 "sc_any(" proc "," l ") !== false"))) +*/ +function sc_anyPred(proc, l) { + return sc_any(proc, l)!== false; +} + +/*** META ((export #t)) */ +function sc_every(proc, l) { + var revres = null; + var tmp = true; + while (l !== null) { + tmp = proc(l.car); + if (tmp === false) return false; + l = l.cdr; + } + return tmp; +} + +/*** META ((export every?) + (peephole (hole 2 "sc_every(" proc "," l ") !== false"))) +*/ +function sc_everyPred(proc, l) { + var tmp = sc_every(proc, l); + if (tmp !== false) return true; + return false; +} + +/*** META ((export #t) + (peephole (postfix "()"))) +*/ +function sc_force(o) { + return o(); +} + +/*** META ((export #t)) */ +function sc_makePromise(proc) { + var isResultReady = false; + var result = undefined; + return function() { + if (!isResultReady) { + var tmp = proc(); + if (!isResultReady) { + isResultReady = true; + result = tmp; + } + } + return result; + }; +} + +function sc_Values(values) { + this.values = values; +} + +/*** META ((export #t) + (peephole (values))) +*/ +function sc_values() { + if (arguments.length === 1) + return arguments[0]; + else + return new sc_Values(arguments); +} + +/*** META ((export #t)) */ +function sc_callWithValues(producer, consumer) { + var produced = producer(); + if (produced instanceof sc_Values) + return consumer.apply(null, produced.values); + else + return consumer(produced); +} + +/*** META ((export #t)) */ +function sc_dynamicWind(before, thunk, after) { + before(); + try { + var res = thunk(); + return res; + } finally { + after(); + } +} + + +// TODO: eval/scheme-report-environment/null-environment/interaction-environment + +// LIMITATION: 'load' doesn't exist without files. +// LIMITATION: transcript-on/transcript-off doesn't exist without files. + + +function sc_Struct(name) { + this.name = name; +} +sc_Struct.prototype.sc_toDisplayString = function() { + return "#<struct" + sc_hash(this) + ">"; +}; +sc_Struct.prototype.sc_toWriteString = sc_Struct.prototype.sc_toDisplayString; + +/*** META ((export #t) + (peephole (hole 1 "new sc_Struct(" name ")"))) +*/ +function sc_makeStruct(name) { + return new sc_Struct(name); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix " instanceof sc_Struct"))) +*/ +function sc_isStruct(o) { + return (o instanceof sc_Struct); +} + +/*** META ((export #t) + (type bool) + (peephole (hole 2 "(" 1 " instanceof sc_Struct) && ( " 1 ".name === " 0 ")"))) +*/ +function sc_isStructNamed(name, s) { + return ((s instanceof sc_Struct) && (s.name === name)); +} + +/*** META ((export struct-field) + (peephole (hole 3 0 "[" 2 "]"))) +*/ +function sc_getStructField(s, name, field) { + return s[field]; +} + +/*** META ((export struct-field-set!) + (peephole (hole 4 0 "[" 2 "] = " 3))) +*/ +function sc_setStructFieldBang(s, name, field, val) { + s[field] = val; +} + +/*** META ((export #t) + (peephole (prefix "~"))) +*/ +function sc_bitNot(x) { + return ~x; +} + +/*** META ((export #t) + (peephole (infix 2 2 "&"))) +*/ +function sc_bitAnd(x, y) { + return x & y; +} + +/*** META ((export #t) + (peephole (infix 2 2 "|"))) +*/ +function sc_bitOr(x, y) { + return x | y; +} + +/*** META ((export #t) + (peephole (infix 2 2 "^"))) +*/ +function sc_bitXor(x, y) { + return x ^ y; +} + +/*** META ((export #t) + (peephole (infix 2 2 "<<"))) +*/ +function sc_bitLsh(x, y) { + return x << y; +} + +/*** META ((export #t) + (peephole (infix 2 2 ">>"))) +*/ +function sc_bitRsh(x, y) { + return x >> y; +} + +/*** META ((export #t) + (peephole (infix 2 2 ">>>"))) +*/ +function sc_bitUrsh(x, y) { + return x >>> y; +} + +/*** META ((export js-field js-property) + (peephole (hole 2 o "[" field "]"))) +*/ +function sc_jsField(o, field) { + return o[field]; +} + +/*** META ((export js-field-set! js-property-set!) + (peephole (hole 3 o "[" field "] = " val))) +*/ +function sc_setJsFieldBang(o, field, val) { + return o[field] = val; +} + +/*** META ((export js-field-delete! js-property-delete!) + (peephole (hole 2 "delete" o "[" field "]"))) +*/ +function sc_deleteJsFieldBang(o, field) { + delete o[field]; +} + +/*** META ((export #t) + (peephole (jsCall))) +*/ +function sc_jsCall(o, fun) { + var args = new Array(); + for (var i = 2; i < arguments.length; i++) + args[i-2] = arguments[i]; + return fun.apply(o, args); +} + +/*** META ((export #t) + (peephole (jsMethodCall))) +*/ +function sc_jsMethodCall(o, field) { + var args = new Array(); + for (var i = 2; i < arguments.length; i++) + args[i-2] = arguments[i]; + return o[field].apply(o, args); +} + +/*** META ((export new js-new) + (peephole (jsNew))) +*/ +function sc_jsNew(c) { + var evalStr = "new c("; + evalStr +=arguments.length > 1? "arguments[1]": ""; + for (var i = 2; i < arguments.length; i++) + evalStr += ", arguments[" + i + "]"; + evalStr +=")"; + return eval(evalStr); +} + +// ======================== RegExp ==================== +/*** META ((export #t)) */ +function sc_pregexp(re) { + return new RegExp(sc_string2jsstring(re)); +} + +/*** META ((export #t)) */ +function sc_pregexpMatch(re, s) { + var reg = (re instanceof RegExp) ? re : sc_pregexp(re); + var tmp = reg.exec(sc_string2jsstring(s)); + + if (tmp == null) return false; + + var res = null; + for (var i = tmp.length-1; i >= 0; i--) { + if (tmp[i] !== null) { + res = sc_cons(sc_jsstring2string(tmp[i]), res); + } else { + res = sc_cons(false, res); + } + } + return res; +} + +/*** META ((export #t)) */ +function sc_pregexpReplace(re, s1, s2) { + var reg; + var jss1 = sc_string2jsstring(s1); + var jss2 = sc_string2jsstring(s2); + + if (re instanceof RegExp) { + if (re.global) + reg = re; + else + reg = new RegExp(re.source); + } else { + reg = new RegExp(sc_string2jsstring(re)); + } + + return jss1.replace(reg, jss2); +} + +/*** META ((export pregexp-replace*)) */ +function sc_pregexpReplaceAll(re, s1, s2) { + var reg; + var jss1 = sc_string2jsstring(s1); + var jss2 = sc_string2jsstring(s2); + + if (re instanceof RegExp) { + if (re.global) + reg = re; + else + reg = new RegExp(re.source, "g"); + } else { + reg = new RegExp(sc_string2jsstring(re), "g"); + } + + return jss1.replace(reg, jss2); +} + +/*** META ((export #t)) */ +function sc_pregexpSplit(re, s) { + var reg = ((re instanceof RegExp) ? + re : + new RegExp(sc_string2jsstring(re))); + var jss = sc_string2jsstring(s); + var tmp = jss.split(reg); + + if (tmp == null) return false; + + return sc_vector2list(tmp); +} + + +/* =========================================================================== */ +/* Other library stuff */ +/* =========================================================================== */ + +/*** META ((export #t) + (peephole (hole 1 "Math.floor(Math.random()*" 'n ")"))) +*/ +function sc_random(n) { + return Math.floor(Math.random()*n); +} + +/*** META ((export current-date) + (peephole (hole 0 "new Date()"))) +*/ +function sc_currentDate() { + return new Date(); +} + +function sc_Hashtable() { +} +sc_Hashtable.prototype.toString = function() { + return "#{%hashtable}"; +}; +// sc_toWriteString == sc_toDisplayString == toString + +function sc_HashtableElement(key, val) { + this.key = key; + this.val = val; +} + +/*** META ((export #t) + (peephole (hole 0 "new sc_Hashtable()"))) +*/ +function sc_makeHashtable() { + return new sc_Hashtable(); +} + +/*** META ((export #t)) */ +function sc_hashtablePutBang(ht, key, val) { + var hash = sc_hash(key); + ht[hash] = new sc_HashtableElement(key, val); +} + +/*** META ((export #t)) */ +function sc_hashtableGet(ht, key) { + var hash = sc_hash(key); + if (hash in ht) + return ht[hash].val; + else + return false; +} + +/*** META ((export #t)) */ +function sc_hashtableForEach(ht, f) { + for (var v in ht) { + if (ht[v] instanceof sc_HashtableElement) + f(ht[v].key, ht[v].val); + } +} + +/*** META ((export hashtable-contains?) + (peephole (hole 2 "sc_hash(" 1 ") in " 0))) +*/ +function sc_hashtableContains(ht, key) { + var hash = sc_hash(key); + if (hash in ht) + return true; + else + return false; +} + +var SC_HASH_COUNTER = 0; + +function sc_hash(o) { + if (o === null) + return "null"; + else if (o === undefined) + return "undefined"; + else if (o === true) + return "true"; + else if (o === false) + return "false"; + else if (typeof o === "number") + return "num-" + o; + else if (typeof o === "string") + return "jsstr-" + o; + else if (o.sc_getHash) + return o.sc_getHash(); + else + return sc_counterHash.call(o); +} +function sc_counterHash() { + if (!this.sc_hash) { + this.sc_hash = "hash-" + SC_HASH_COUNTER; + SC_HASH_COUNTER++; + } + return this.sc_hash; +} + +function sc_Trampoline(args, maxTailCalls) { + this['__trampoline return__'] = true; + this.args = args; + this.MAX_TAIL_CALLs = maxTailCalls; +} +// TODO: call/cc stuff +sc_Trampoline.prototype.restart = function() { + var o = this; + while (true) { + // set both globals. + SC_TAIL_OBJECT.calls = o.MAX_TAIL_CALLs-1; + var fun = o.args.callee; + var res = fun.apply(SC_TAIL_OBJECT, o.args); + if (res instanceof sc_Trampoline) + o = res; + else + return res; + } +} + +/*** META ((export bind-exit-lambda)) */ +function sc_bindExitLambda(proc) { + var escape_obj = new sc_BindExitException(); + var escape = function(res) { + escape_obj.res = res; + throw escape_obj; + }; + try { + return proc(escape); + } catch(e) { + if (e === escape_obj) { + return e.res; + } + throw e; + } +} +function sc_BindExitException() { + this._internalException = true; +} + +var SC_SCM2JS_GLOBALS = new Object(); + +// default tail-call depth. +// normally the program should set it again. but just in case... +var SC_TAIL_OBJECT = new Object(); +SC_SCM2JS_GLOBALS.TAIL_OBJECT = SC_TAIL_OBJECT; +// ======================== I/O ======================= + +/*------------------------------------------------------------------*/ + +function sc_EOF() { +} +var SC_EOF_OBJECT = new sc_EOF(); + +function sc_Port() { +} + +/* --------------- Input ports -------------------------------------*/ + +function sc_InputPort() { +} +sc_InputPort.prototype = new sc_Port(); + +sc_InputPort.prototype.peekChar = function() { + if (!("peeked" in this)) + this.peeked = this.getNextChar(); + return this.peeked; +} +sc_InputPort.prototype.readChar = function() { + var tmp = this.peekChar(); + delete this.peeked; + return tmp; +} +sc_InputPort.prototype.isCharReady = function() { + return true; +} +sc_InputPort.prototype.close = function() { + // do nothing +} + +/* .............. String port ..........................*/ +function sc_ErrorInputPort() { +}; +sc_ErrorInputPort.prototype = new sc_InputPort(); +sc_ErrorInputPort.prototype.getNextChar = function() { + throw "can't read from error-port."; +}; +sc_ErrorInputPort.prototype.isCharReady = function() { + return false; +}; + + +/* .............. String port ..........................*/ + +function sc_StringInputPort(jsStr) { + // we are going to do some charAts on the str. + // instead of recreating all the time a String-object, we + // create one in the beginning. (not sure, if this is really an optim) + this.str = new String(jsStr); + this.pos = 0; +} +sc_StringInputPort.prototype = new sc_InputPort(); +sc_StringInputPort.prototype.getNextChar = function() { + if (this.pos >= this.str.length) + return SC_EOF_OBJECT; + return this.str.charAt(this.pos++); +}; + +/* ------------- Read and other lib-funs -------------------------------*/ +function sc_Token(type, val, pos) { + this.type = type; + this.val = val; + this.pos = pos; +} +sc_Token.EOF = 0/*EOF*/; +sc_Token.OPEN_PAR = 1/*OPEN_PAR*/; +sc_Token.CLOSE_PAR = 2/*CLOSE_PAR*/; +sc_Token.OPEN_BRACE = 3/*OPEN_BRACE*/; +sc_Token.CLOSE_BRACE = 4/*CLOSE_BRACE*/; +sc_Token.OPEN_BRACKET = 5/*OPEN_BRACKET*/; +sc_Token.CLOSE_BRACKET = 6/*CLOSE_BRACKET*/; +sc_Token.WHITESPACE = 7/*WHITESPACE*/; +sc_Token.QUOTE = 8/*QUOTE*/; +sc_Token.ID = 9/*ID*/; +sc_Token.DOT = 10/*DOT*/; +sc_Token.STRING = 11/*STRING*/; +sc_Token.NUMBER = 12/*NUMBER*/; +sc_Token.ERROR = 13/*ERROR*/; +sc_Token.VECTOR_BEGIN = 14/*VECTOR_BEGIN*/; +sc_Token.TRUE = 15/*TRUE*/; +sc_Token.FALSE = 16/*FALSE*/; +sc_Token.UNSPECIFIED = 17/*UNSPECIFIED*/; +sc_Token.REFERENCE = 18/*REFERENCE*/; +sc_Token.STORE = 19/*STORE*/; +sc_Token.CHAR = 20/*CHAR*/; + +var SC_ID_CLASS = SC_LOWER_CLASS + SC_UPPER_CLASS + "!$%*+-./:<=>?@^_~"; +function sc_Tokenizer(port) { + this.port = port; +} +sc_Tokenizer.prototype.peekToken = function() { + if (this.peeked) + return this.peeked; + var newToken = this.nextToken(); + this.peeked = newToken; + return newToken; +}; +sc_Tokenizer.prototype.readToken = function() { + var tmp = this.peekToken(); + delete this.peeked; + return tmp; +}; +sc_Tokenizer.prototype.nextToken = function() { + var port = this.port; + + function isNumberChar(c) { + return (c >= "0" && c <= "9"); + }; + function isIdOrNumberChar(c) { + return SC_ID_CLASS.indexOf(c) != -1 || // ID-char + (c >= "0" && c <= "9"); + } + function isWhitespace(c) { + return c === " " || c === "\r" || c === "\n" || c === "\t" || c === "\f"; + }; + function isWhitespaceOrEOF(c) { + return isWhitespace(c) || c === SC_EOF_OBJECT; + }; + + function readString() { + res = ""; + while (true) { + var c = port.readChar(); + switch (c) { + case '"': + return new sc_Token(11/*STRING*/, res); + case "\\": + var tmp = port.readChar(); + switch (tmp) { + case '0': res += "\0"; break; + case 'a': res += "\a"; break; + case 'b': res += "\b"; break; + case 'f': res += "\f"; break; + case 'n': res += "\n"; break; + case 'r': res += "\r"; break; + case 't': res += "\t"; break; + case 'v': res += "\v"; break; + case '"': res += '"'; break; + case '\\': res += '\\'; break; + case 'x': + /* hexa-number */ + var nb = 0; + while (true) { + var hexC = port.peekChar(); + if (hexC >= '0' && hexC <= '9') { + port.readChar(); + nb = nb * 16 + hexC.charCodeAt(0) - '0'.charCodeAt(0); + } else if (hexC >= 'a' && hexC <= 'f') { + port.readChar(); + nb = nb * 16 + hexC.charCodeAt(0) - 'a'.charCodeAt(0); + } else if (hexC >= 'A' && hexC <= 'F') { + port.readChar(); + nb = nb * 16 + hexC.charCodeAt(0) - 'A'.charCodeAt(0); + } else { + // next char isn't part of hex. + res += String.fromCharCode(nb); + break; + } + } + break; + default: + if (tmp === SC_EOF_OBJECT) { + return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res); + } + res += tmp; + } + break; + default: + if (c === SC_EOF_OBJECT) { + return new sc_Token(13/*ERROR*/, "unclosed string-literal" + res); + } + res += c; + } + } + }; + function readIdOrNumber(firstChar) { + var res = firstChar; + while (isIdOrNumberChar(port.peekChar())) + res += port.readChar(); + if (isNaN(res)) + return new sc_Token(9/*ID*/, res); + else + return new sc_Token(12/*NUMBER*/, res - 0); + }; + + function skipWhitespaceAndComments() { + var done = false; + while (!done) { + done = true; + while (isWhitespace(port.peekChar())) + port.readChar(); + if (port.peekChar() === ';') { + port.readChar(); + done = false; + while (true) { + curChar = port.readChar(); + if (curChar === SC_EOF_OBJECT || + curChar === '\n') + break; + } + } + } + }; + + function readDot() { + if (isWhitespace(port.peekChar())) + return new sc_Token(10/*DOT*/); + else + return readIdOrNumber("."); + }; + + function readSharp() { + var c = port.readChar(); + if (isWhitespace(c)) + return new sc_Token(13/*ERROR*/, "bad #-pattern0."); + + // reference + if (isNumberChar(c)) { + var nb = c - 0; + while (isNumberChar(port.peekChar())) + nb = nb*10 + (port.readChar() - 0); + switch (port.readChar()) { + case '#': + return new sc_Token(18/*REFERENCE*/, nb); + case '=': + return new sc_Token(19/*STORE*/, nb); + default: + return new sc_Token(13/*ERROR*/, "bad #-pattern1." + nb); + } + } + + if (c === "(") + return new sc_Token(14/*VECTOR_BEGIN*/); + + if (c === "\\") { // character + var tmp = "" + while (!isWhitespaceOrEOF(port.peekChar())) + tmp += port.readChar(); + switch (tmp.length) { + case 0: // it's escaping a whitespace char: + if (sc_isEOFObject(port.peekChar)) + return new sc_Token(13/*ERROR*/, "bad #-pattern2."); + else + return new sc_Token(20/*CHAR*/, port.readChar()); + case 1: + return new sc_Token(20/*CHAR*/, tmp); + default: + var entry = sc_Char.readable2char[tmp.toLowerCase()]; + if (entry) + return new sc_Token(20/*CHAR*/, entry); + else + return new sc_Token(13/*ERROR*/, "unknown character description: #\\" + tmp); + } + } + + // some constants (#t, #f, #unspecified) + var res; + var needing; + switch (c) { + case 't': res = new sc_Token(15/*TRUE*/, true); needing = ""; break; + case 'f': res = new sc_Token(16/*FALSE*/, false); needing = ""; break; + case 'u': res = new sc_Token(17/*UNSPECIFIED*/, undefined); needing = "nspecified"; break; + default: + return new sc_Token(13/*ERROR*/, "bad #-pattern3: " + c); + } + while(true) { + c = port.peekChar(); + if ((isWhitespaceOrEOF(c) || c === ')') && + needing == "") + return res; + else if (isWhitespace(c) || needing == "") + return new sc_Token(13/*ERROR*/, "bad #-pattern4 " + c + " " + needing); + else if (needing.charAt(0) == c) { + port.readChar(); // consume + needing = needing.slice(1); + } else + return new sc_Token(13/*ERROR*/, "bad #-pattern5"); + } + + }; + + skipWhitespaceAndComments(); + var curChar = port.readChar(); + if (curChar === SC_EOF_OBJECT) + return new sc_Token(0/*EOF*/, curChar); + switch (curChar) + { + case " ": + case "\n": + case "\t": + return readWhitespace(); + case "(": + return new sc_Token(1/*OPEN_PAR*/); + case ")": + return new sc_Token(2/*CLOSE_PAR*/); + case "{": + return new sc_Token(3/*OPEN_BRACE*/); + case "}": + return new sc_Token(4/*CLOSE_BRACE*/); + case "[": + return new sc_Token(5/*OPEN_BRACKET*/); + case "]": + return new sc_Token(6/*CLOSE_BRACKET*/); + case "'": + return new sc_Token(8/*QUOTE*/); + case "#": + return readSharp(); + case ".": + return readDot(); + case '"': + return readString(); + default: + if (isIdOrNumberChar(curChar)) + return readIdOrNumber(curChar); + throw "unexpected character: " + curChar; + } +}; + +function sc_Reader(tokenizer) { + this.tokenizer = tokenizer; + this.backref = new Array(); +} +sc_Reader.prototype.read = function() { + function readList(listBeginType) { + function matchesPeer(open, close) { + return open === 1/*OPEN_PAR*/ && close === 2/*CLOSE_PAR*/ + || open === 3/*OPEN_BRACE*/ && close === 4/*CLOSE_BRACE*/ + || open === 5/*OPEN_BRACKET*/ && close === 6/*CLOSE_BRACKET*/; + }; + var res = null; + + while (true) { + var token = tokenizer.peekToken(); + + switch (token.type) { + case 2/*CLOSE_PAR*/: + case 4/*CLOSE_BRACE*/: + case 6/*CLOSE_BRACKET*/: + if (matchesPeer(listBeginType, token.type)) { + tokenizer.readToken(); // consume token + return sc_reverseBang(res); + } else + throw "closing par doesn't match: " + listBeginType + + " " + listEndType; + + case 0/*EOF*/: + throw "unexpected end of file"; + + case 10/*DOT*/: + tokenizer.readToken(); // consume token + var cdr = this.read(); + var par = tokenizer.readToken(); + if (!matchesPeer(listBeginType, par.type)) + throw "closing par doesn't match: " + listBeginType + + " " + par.type; + else + return sc_reverseAppendBang(res, cdr); + + + default: + res = sc_cons(this.read(), res); + } + } + }; + function readQuote() { + return sc_cons("quote", sc_cons(this.read(), null)); + }; + function readVector() { + // opening-parenthesis is already consumed + var a = new Array(); + while (true) { + var token = tokenizer.peekToken(); + switch (token.type) { + case 2/*CLOSE_PAR*/: + tokenizer.readToken(); + return a; + + default: + a.push(this.read()); + } + } + }; + + function storeRefence(nb) { + var tmp = this.read(); + this.backref[nb] = tmp; + return tmp; + }; + + function readReference(nb) { + if (nb in this.backref) + return this.backref[nb]; + else + throw "bad reference: " + nb; + }; + + var tokenizer = this.tokenizer; + + var token = tokenizer.readToken(); + + // handle error + if (token.type === 13/*ERROR*/) + throw token.val; + + switch (token.type) { + case 1/*OPEN_PAR*/: + case 3/*OPEN_BRACE*/: + case 5/*OPEN_BRACKET*/: + return readList.call(this, token.type); + case 8/*QUOTE*/: + return readQuote.call(this); + case 11/*STRING*/: + return sc_jsstring2string(token.val); + case 20/*CHAR*/: + return new sc_Char(token.val); + case 14/*VECTOR_BEGIN*/: + return readVector.call(this); + case 18/*REFERENCE*/: + return readReference.call(this, token.val); + case 19/*STORE*/: + return storeRefence.call(this, token.val); + case 9/*ID*/: + return sc_jsstring2symbol(token.val); + case 0/*EOF*/: + case 12/*NUMBER*/: + case 15/*TRUE*/: + case 16/*FALSE*/: + case 17/*UNSPECIFIED*/: + return token.val; + default: + throw "unexpected token " + token.type + " " + token.val; + } +}; + +/*** META ((export #t)) */ +function sc_read(port) { + if (port === undefined) // we assume the port hasn't been given. + port = SC_DEFAULT_IN; // THREAD: shared var... + var reader = new sc_Reader(new sc_Tokenizer(port)); + return reader.read(); +} +/*** META ((export #t)) */ +function sc_readChar(port) { + if (port === undefined) // we assume the port hasn't been given. + port = SC_DEFAULT_IN; // THREAD: shared var... + var t = port.readChar(); + return t === SC_EOF_OBJECT? t: new sc_Char(t); +} +/*** META ((export #t)) */ +function sc_peekChar(port) { + if (port === undefined) // we assume the port hasn't been given. + port = SC_DEFAULT_IN; // THREAD: shared var... + var t = port.peekChar(); + return t === SC_EOF_OBJECT? t: new sc_Char(t); +} +/*** META ((export #t) + (type bool)) +*/ +function sc_isCharReady(port) { + if (port === undefined) // we assume the port hasn't been given. + port = SC_DEFAULT_IN; // THREAD: shared var... + return port.isCharReady(); +} +/*** META ((export #t) + (peephole (postfix ".close()"))) +*/ +function sc_closeInputPort(p) { + return p.close(); +} + +/*** META ((export #t) + (type bool) + (peephole (postfix " instanceof sc_InputPort"))) +*/ +function sc_isInputPort(o) { + return (o instanceof sc_InputPort); +} + +/*** META ((export eof-object?) + (type bool) + (peephole (postfix " === SC_EOF_OBJECT"))) +*/ +function sc_isEOFObject(o) { + return o === SC_EOF_OBJECT; +} + +/*** META ((export #t) + (peephole (hole 0 "SC_DEFAULT_IN"))) +*/ +function sc_currentInputPort() { + return SC_DEFAULT_IN; +} + +/* ------------ file operations are not supported -----------*/ +/*** META ((export #t)) */ +function sc_callWithInputFile(s, proc) { + throw "can't open " + s; +} + +/*** META ((export #t)) */ +function sc_callWithOutputFile(s, proc) { + throw "can't open " + s; +} + +/*** META ((export #t)) */ +function sc_withInputFromFile(s, thunk) { + throw "can't open " + s; +} + +/*** META ((export #t)) */ +function sc_withOutputToFile(s, thunk) { + throw "can't open " + s; +} + +/*** META ((export #t)) */ +function sc_openInputFile(s) { + throw "can't open " + s; +} + +/*** META ((export #t)) */ +function sc_openOutputFile(s) { + throw "can't open " + s; +} + +/* ----------------------------------------------------------------------------*/ +/*** META ((export #t)) */ +function sc_basename(p) { + var i = p.lastIndexOf('/'); + + if(i >= 0) + return p.substring(i + 1, p.length); + else + return ''; +} + +/*** META ((export #t)) */ +function sc_dirname(p) { + var i = p.lastIndexOf('/'); + + if(i >= 0) + return p.substring(0, i); + else + return ''; +} + +/* ----------------------------------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_withInputFromPort(p, thunk) { + try { + var tmp = SC_DEFAULT_IN; // THREAD: shared var. + SC_DEFAULT_IN = p; + return thunk(); + } finally { + SC_DEFAULT_IN = tmp; + } +} + +/*** META ((export #t)) */ +function sc_withInputFromString(s, thunk) { + return sc_withInputFromPort(new sc_StringInputPort(sc_string2jsstring(s)), thunk); +} + +/*** META ((export #t)) */ +function sc_withOutputToPort(p, thunk) { + try { + var tmp = SC_DEFAULT_OUT; // THREAD: shared var. + SC_DEFAULT_OUT = p; + return thunk(); + } finally { + SC_DEFAULT_OUT = tmp; + } +} + +/*** META ((export #t)) */ +function sc_withOutputToString(thunk) { + var p = new sc_StringOutputPort(); + sc_withOutputToPort(p, thunk); + return p.close(); +} + +/*** META ((export #t)) */ +function sc_withOutputToProcedure(proc, thunk) { + var t = function(s) { proc(sc_jsstring2string(s)); }; + return sc_withOutputToPort(new sc_GenericOutputPort(t), thunk); +} + +/*** META ((export #t) + (peephole (hole 0 "new sc_StringOutputPort()"))) +*/ +function sc_openOutputString() { + return new sc_StringOutputPort(); +} + +/*** META ((export #t)) */ +function sc_openInputString(str) { + return new sc_StringInputPort(sc_string2jsstring(str)); +} + +/* ----------------------------------------------------------------------------*/ + +function sc_OutputPort() { +} +sc_OutputPort.prototype = new sc_Port(); +sc_OutputPort.prototype.appendJSString = function(obj) { + /* do nothing */ +} +sc_OutputPort.prototype.close = function() { + /* do nothing */ +} + +function sc_StringOutputPort() { + this.res = ""; +} +sc_StringOutputPort.prototype = new sc_OutputPort(); +sc_StringOutputPort.prototype.appendJSString = function(s) { + this.res += s; +} +sc_StringOutputPort.prototype.close = function() { + return sc_jsstring2string(this.res); +} + +/*** META ((export #t)) */ +function sc_getOutputString(sp) { + return sc_jsstring2string(sp.res); +} + + +function sc_ErrorOutputPort() { +} +sc_ErrorOutputPort.prototype = new sc_OutputPort(); +sc_ErrorOutputPort.prototype.appendJSString = function(s) { + throw "don't write on ErrorPort!"; +} +sc_ErrorOutputPort.prototype.close = function() { + /* do nothing */ +} + +function sc_GenericOutputPort(appendJSString, close) { + this.appendJSString = appendJSString; + if (close) + this.close = close; +} +sc_GenericOutputPort.prototype = new sc_OutputPort(); + +/*** META ((export #t) + (type bool) + (peephole (postfix " instanceof sc_OutputPort"))) +*/ +function sc_isOutputPort(o) { + return (o instanceof sc_OutputPort); +} + +/*** META ((export #t) + (peephole (postfix ".close()"))) +*/ +function sc_closeOutputPort(p) { + return p.close(); +} + +/* ------------------ write ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_write(o, p) { + if (p === undefined) // we assume not given + p = SC_DEFAULT_OUT; + p.appendJSString(sc_toWriteString(o)); +} + +function sc_toWriteString(o) { + if (o === null) + return "()"; + else if (o === true) + return "#t"; + else if (o === false) + return "#f"; + else if (o === undefined) + return "#unspecified"; + else if (typeof o === 'function') + return "#<procedure " + sc_hash(o) + ">"; + else if (o.sc_toWriteString) + return o.sc_toWriteString(); + else + return o.toString(); +} + +function sc_escapeWriteString(s) { + var res = ""; + var j = 0; + for (i = 0; i < s.length; i++) { + switch (s.charAt(i)) { + case "\0": res += s.substring(j, i) + "\\0"; j = i + 1; break; + case "\b": res += s.substring(j, i) + "\\b"; j = i + 1; break; + case "\f": res += s.substring(j, i) + "\\f"; j = i + 1; break; + case "\n": res += s.substring(j, i) + "\\n"; j = i + 1; break; + case "\r": res += s.substring(j, i) + "\\r"; j = i + 1; break; + case "\t": res += s.substring(j, i) + "\\t"; j = i + 1; break; + case "\v": res += s.substring(j, i) + "\\v"; j = i + 1; break; + case '"': res += s.substring(j, i) + '\\"'; j = i + 1; break; + case "\\": res += s.substring(j, i) + "\\\\"; j = i + 1; break; + default: + var c = s.charAt(i); + if ("\a" !== "a" && c == "\a") { + res += s.substring(j, i) + "\\a"; j = i + 1; continue; + } + if ("\v" !== "v" && c == "\v") { + res += s.substring(j, i) + "\\v"; j = i + 1; continue; + } + //if (s.charAt(i) < ' ' || s.charCodeAt(i) > 127) { + // CARE: Manuel is this OK with HOP? + if (s.charAt(i) < ' ') { + /* non printable character and special chars */ + res += s.substring(j, i) + "\\x" + s.charCodeAt(i).toString(16); + j = i + 1; + } + // else just let i increase... + } + } + res += s.substring(j, i); + return res; +} + +/* ------------------ display ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_display(o, p) { + if (p === undefined) // we assume not given + p = SC_DEFAULT_OUT; + p.appendJSString(sc_toDisplayString(o)); +} + +function sc_toDisplayString(o) { + if (o === null) + return "()"; + else if (o === true) + return "#t"; + else if (o === false) + return "#f"; + else if (o === undefined) + return "#unspecified"; + else if (typeof o === 'function') + return "#<procedure " + sc_hash(o) + ">"; + else if (o.sc_toDisplayString) + return o.sc_toDisplayString(); + else + return o.toString(); +} + +/* ------------------ newline ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_newline(p) { + if (p === undefined) // we assume not given + p = SC_DEFAULT_OUT; + p.appendJSString("\n"); +} + +/* ------------------ write-char ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_writeChar(c, p) { + if (p === undefined) // we assume not given + p = SC_DEFAULT_OUT; + p.appendJSString(c.val); +} + +/* ------------------ write-circle ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_writeCircle(o, p) { + if (p === undefined) // we assume not given + p = SC_DEFAULT_OUT; + p.appendJSString(sc_toWriteCircleString(o)); +} + +function sc_toWriteCircleString(o) { + var symb = sc_gensym("writeCircle"); + var nbPointer = new Object(); + nbPointer.nb = 0; + sc_prepWriteCircle(o, symb, nbPointer); + return sc_genToWriteCircleString(o, symb); +} + +function sc_prepWriteCircle(o, symb, nbPointer) { + // TODO sc_Struct + if (o instanceof sc_Pair || + o instanceof sc_Vector) { + if (o[symb] !== undefined) { + // not the first visit. + o[symb]++; + // unless there is already a number, assign one. + if (!o[symb + "nb"]) o[symb + "nb"] = nbPointer.nb++; + return; + } + o[symb] = 0; + if (o instanceof sc_Pair) { + sc_prepWriteCircle(o.car, symb, nbPointer); + sc_prepWriteCircle(o.cdr, symb, nbPointer); + } else { + for (var i = 0; i < o.length; i++) + sc_prepWriteCircle(o[i], symb, nbPointer); + } + } +} + +function sc_genToWriteCircleString(o, symb) { + if (!(o instanceof sc_Pair || + o instanceof sc_Vector)) + return sc_toWriteString(o); + return o.sc_toWriteCircleString(symb); +} +sc_Pair.prototype.sc_toWriteCircleString = function(symb, inList) { + if (this[symb + "use"]) { // use-flag is set. Just use it. + var nb = this[symb + "nb"]; + if (this[symb]-- === 0) { // if we are the last use. remove all fields. + delete this[symb]; + delete this[symb + "nb"]; + delete this[symb + "use"]; + } + if (inList) + return '. #' + nb + '#'; + else + return '#' + nb + '#'; + } + if (this[symb]-- === 0) { // if we are the last use. remove all fields. + delete this[symb]; + delete this[symb + "nb"]; + delete this[symb + "use"]; + } + + var res = ""; + + if (this[symb] !== undefined) { // implies > 0 + this[symb + "use"] = true; + if (inList) + res += '. #' + this[symb + "nb"] + '='; + else + res += '#' + this[symb + "nb"] + '='; + inList = false; + } + + if (!inList) + res += "("; + + // print car + res += sc_genToWriteCircleString(this.car, symb); + + if (sc_isPair(this.cdr)) { + res += " " + this.cdr.sc_toWriteCircleString(symb, true); + } else if (this.cdr !== null) { + res += " . " + sc_genToWriteCircleString(this.cdr, symb); + } + if (!inList) + res += ")"; + return res; +}; +sc_Vector.prototype.sc_toWriteCircleString = function(symb) { + if (this[symb + "use"]) { // use-flag is set. Just use it. + var nb = this[symb + "nb"]; + if (this[symb]-- === 0) { // if we are the last use. remove all fields. + delete this[symb]; + delete this[symb + "nb"]; + delete this[symb + "use"]; + } + return '#' + nb + '#'; + } + if (this[symb]-- === 0) { // if we are the last use. remove all fields. + delete this[symb]; + delete this[symb + "nb"]; + delete this[symb + "use"]; + } + + var res = ""; + if (this[symb] !== undefined) { // implies > 0 + this[symb + "use"] = true; + res += '#' + this[symb + "nb"] + '='; + } + res += "#("; + for (var i = 0; i < this.length; i++) { + res += sc_genToWriteCircleString(this[i], symb); + if (i < this.length - 1) res += " "; + } + res += ")"; + return res; +}; + + +/* ------------------ print ---------------------------------------------------*/ + +/*** META ((export #t)) */ +function sc_print(s) { + if (arguments.length === 1) { + sc_display(s); + sc_newline(); + } + else { + for (var i = 0; i < arguments.length; i++) + sc_display(arguments[i]); + sc_newline(); + } +} + +/* ------------------ format ---------------------------------------------------*/ +/*** META ((export #t)) */ +function sc_format(s, args) { + var len = s.length; + var p = new sc_StringOutputPort(); + var i = 0, j = 1; + + while( i < len ) { + var i2 = s.indexOf("~", i); + + if (i2 == -1) { + p.appendJSString( s.substring( i, len ) ); + return p.close(); + } else { + if (i2 > i) { + if (i2 == (len - 1)) { + p.appendJSString(s.substring(i, len)); + return p.close(); + } else { + p.appendJSString(s.substring(i, i2)); + i = i2; + } + } + + switch(s.charCodeAt(i2 + 1)) { + case 65: + case 97: + // a + sc_display(arguments[j], p); + i += 2; j++; + break; + + case 83: + case 115: + // s + sc_write(arguments[j], p); + i += 2; j++; + break; + + case 86: + case 118: + // v + sc_display(arguments[j], p); + p.appendJSString("\n"); + i += 2; j++; + break; + + case 67: + case 99: + // c + p.appendJSString(String.fromCharCode(arguments[j])); + i += 2; j++; + break; + + case 88: + case 120: + // x + p.appendJSString(arguments[j].toString(6)); + i += 2; j++; + break; + + case 79: + case 111: + // o + p.appendJSString(arguments[j].toString(8)); + i += 2; j++; + break; + + case 66: + case 98: + // b + p.appendJSString(arguments[j].toString(2)); + i += 2; j++; + break; + + case 37: + case 110: + // %, n + p.appendJSString("\n"); + i += 2; break; + + case 114: + // r + p.appendJSString("\r"); + i += 2; break; + + case 126: + // ~ + p.appendJSString("~"); + i += 2; break; + + default: + sc_error( "format: illegal ~" + + String.fromCharCode(s.charCodeAt(i2 + 1)) + + " sequence" ); + return ""; + } + } + } + + return p.close(); +} + +/* ------------------ global ports ---------------------------------------------------*/ + +var SC_DEFAULT_IN = new sc_ErrorInputPort(); +var SC_DEFAULT_OUT = new sc_ErrorOutputPort(); +var SC_ERROR_OUT = new sc_ErrorOutputPort(); + +var sc_SYMBOL_PREFIX = "\u1E9C"; +var sc_KEYWORD_PREFIX = "\u1E9D"; + +/*** META ((export #t) + (peephole (id))) */ +function sc_jsstring2string(s) { + return s; +} + +/*** META ((export #t) + (peephole (prefix "'\\u1E9C' +"))) +*/ +function sc_jsstring2symbol(s) { + return sc_SYMBOL_PREFIX + s; +} + +/*** META ((export #t) + (peephole (id))) +*/ +function sc_string2jsstring(s) { + return s; +} + +/*** META ((export #t) + (peephole (symbol2jsstring_immutable))) +*/ +function sc_symbol2jsstring(s) { + return s.slice(1); +} + +/*** META ((export #t) + (peephole (postfix ".slice(1)"))) +*/ +function sc_keyword2jsstring(k) { + return k.slice(1); +} + +/*** META ((export #t) + (peephole (prefix "'\\u1E9D' +"))) +*/ +function sc_jsstring2keyword(s) { + return sc_KEYWORD_PREFIX + s; +} + +/*** META ((export #t) + (type bool)) +*/ +function sc_isKeyword(s) { + return (typeof s === "string") && + (s.charAt(0) === sc_KEYWORD_PREFIX); +} + + +/*** META ((export #t)) */ +var sc_gensym = function() { + var counter = 1000; + return function(sym) { + counter++; + if (!sym) sym = sc_SYMBOL_PREFIX; + return sym + "s" + counter + "~" + "^sC-GeNsYm "; + }; +}(); + + +/*** META ((export #t) + (type bool)) +*/ +function sc_isEqual(o1, o2) { + return ((o1 === o2) || + (sc_isPair(o1) && sc_isPair(o2) + && sc_isPairEqual(o1, o2, sc_isEqual)) || + (sc_isVector(o1) && sc_isVector(o2) + && sc_isVectorEqual(o1, o2, sc_isEqual))); +} + +/*** META ((export number->symbol integer->symbol)) */ +function sc_number2symbol(x, radix) { + return sc_SYMBOL_PREFIX + sc_number2jsstring(x, radix); +} + +/*** META ((export number->string integer->string)) */ +var sc_number2string = sc_number2jsstring; + +/*** META ((export #t)) */ +function sc_symbol2number(s, radix) { + return sc_jsstring2number(s.slice(1), radix); +} + +/*** META ((export #t)) */ +var sc_string2number = sc_jsstring2number; + +/*** META ((export #t) + (peephole (prefix "+" s))) + ;; peephole will only apply if no radix is given. +*/ +function sc_string2integer(s, radix) { + if (!radix) return +s; + return parseInt(s, radix); +} + +/*** META ((export #t) + (peephole (prefix "+"))) +*/ +function sc_string2real(s) { + return +s; +} + + +/*** META ((export #t) + (type bool)) +*/ +function sc_isSymbol(s) { + return (typeof s === "string") && + (s.charAt(0) === sc_SYMBOL_PREFIX); +} + +/*** META ((export #t) + (peephole (symbol2string_immutable))) +*/ +function sc_symbol2string(s) { + return s.slice(1); +} + +/*** META ((export #t) + (peephole (prefix "'\\u1E9C' +"))) +*/ +function sc_string2symbol(s) { + return sc_SYMBOL_PREFIX + s; +} + +/*** META ((export symbol-append) + (peephole (symbolAppend_immutable))) +*/ +function sc_symbolAppend() { + var res = sc_SYMBOL_PREFIX; + for (var i = 0; i < arguments.length; i++) + res += arguments[i].slice(1); + return res; +} + +/*** META ((export #t) + (peephole (postfix ".val"))) +*/ +function sc_char2string(c) { return c.val; } + +/*** META ((export #t) + (peephole (hole 1 "'\\u1E9C' + " c ".val"))) +*/ +function sc_char2symbol(c) { return sc_SYMBOL_PREFIX + c.val; } + +/*** META ((export #t) + (type bool)) +*/ +function sc_isString(s) { + return (typeof s === "string") && + (s.charAt(0) !== sc_SYMBOL_PREFIX); +} + +/*** META ((export #t)) */ +var sc_makeString = sc_makejsString; + + +/*** META ((export #t)) */ +function sc_string() { + for (var i = 0; i < arguments.length; i++) + arguments[i] = arguments[i].val; + return "".concat.apply("", arguments); +} + +/*** META ((export #t) + (peephole (postfix ".length"))) +*/ +function sc_stringLength(s) { return s.length; } + +/*** META ((export #t)) */ +function sc_stringRef(s, k) { + return new sc_Char(s.charAt(k)); +} + +/* there's no stringSet in the immutable version +function sc_stringSet(s, k, c) +*/ + + +/*** META ((export string=?) + (type bool) + (peephole (hole 2 str1 " === " str2))) +*/ +function sc_isStringEqual(s1, s2) { + return s1 === s2; +} +/*** META ((export string<?) + (type bool) + (peephole (hole 2 str1 " < " str2))) +*/ +function sc_isStringLess(s1, s2) { + return s1 < s2; +} +/*** META ((export string>?) + (type bool) + (peephole (hole 2 str1 " > " str2))) +*/ +function sc_isStringGreater(s1, s2) { + return s1 > s2; +} +/*** META ((export string<=?) + (type bool) + (peephole (hole 2 str1 " <= " str2))) +*/ +function sc_isStringLessEqual(s1, s2) { + return s1 <= s2; +} +/*** META ((export string>=?) + (type bool) + (peephole (hole 2 str1 " >= " str2))) +*/ +function sc_isStringGreaterEqual(s1, s2) { + return s1 >= s2; +} +/*** META ((export string-ci=?) + (type bool) + (peephole (hole 2 str1 ".toLowerCase() === " str2 ".toLowerCase()"))) +*/ +function sc_isStringCIEqual(s1, s2) { + return s1.toLowerCase() === s2.toLowerCase(); +} +/*** META ((export string-ci<?) + (type bool) + (peephole (hole 2 str1 ".toLowerCase() < " str2 ".toLowerCase()"))) +*/ +function sc_isStringCILess(s1, s2) { + return s1.toLowerCase() < s2.toLowerCase(); +} +/*** META ((export string-ci>?) + (type bool) + (peephole (hole 2 str1 ".toLowerCase() > " str2 ".toLowerCase()"))) +*/ +function sc_isStringCIGreater(s1, s2) { + return s1.toLowerCase() > s2.toLowerCase(); +} +/*** META ((export string-ci<=?) + (type bool) + (peephole (hole 2 str1 ".toLowerCase() <= " str2 ".toLowerCase()"))) +*/ +function sc_isStringCILessEqual(s1, s2) { + return s1.toLowerCase() <= s2.toLowerCase(); +} +/*** META ((export string-ci>=?) + (type bool) + (peephole (hole 2 str1 ".toLowerCase() >= " str2 ".toLowerCase()"))) +*/ +function sc_isStringCIGreaterEqual(s1, s2) { + return s1.toLowerCase() >= s2.toLowerCase(); +} + +/*** META ((export #t) + (peephole (hole 3 s ".substring(" start ", " end ")"))) +*/ +function sc_substring(s, start, end) { + return s.substring(start, end); +} + +/*** META ((export #t)) +*/ +function sc_isSubstring_at(s1, s2, i) { + return s2 == s1.substring(i, i+ s2.length); +} + +/*** META ((export #t) + (peephole (infix 0 #f "+" "''"))) +*/ +function sc_stringAppend() { + return "".concat.apply("", arguments); +} + +/*** META ((export #t)) */ +var sc_string2list = sc_jsstring2list; + +/*** META ((export #t)) */ +var sc_list2string = sc_list2jsstring; + +/*** META ((export #t) + (peephole (id))) +*/ +function sc_stringCopy(s) { + return s; +} + +/* there's no string-fill in the immutable version +function sc_stringFill(s, c) +*/ + +/*** META ((export #t) + (peephole (postfix ".slice(1)"))) +*/ +function sc_keyword2string(o) { + return o.slice(1); +} + +/*** META ((export #t) + (peephole (prefix "'\\u1E9D' +"))) +*/ +function sc_string2keyword(o) { + return sc_KEYWORD_PREFIX + o; +} + +String.prototype.sc_toDisplayString = function() { + if (this.charAt(0) === sc_SYMBOL_PREFIX) + // TODO: care for symbols with spaces (escape-chars symbols). + return this.slice(1); + else if (this.charAt(0) === sc_KEYWORD_PREFIX) + return ":" + this.slice(1); + else + return this.toString(); +}; + +String.prototype.sc_toWriteString = function() { + if (this.charAt(0) === sc_SYMBOL_PREFIX) + // TODO: care for symbols with spaces (escape-chars symbols). + return this.slice(1); + else if (this.charAt(0) === sc_KEYWORD_PREFIX) + return ":" + this.slice(1); + else + return '"' + sc_escapeWriteString(this) + '"'; +}; +/* Exported Variables */ +var BgL_testzd2boyerzd2; +var BgL_nboyerzd2benchmarkzd2; +var BgL_setupzd2boyerzd2; +/* End Exports */ + +var translate_term_nboyer; +var translate_args_nboyer; +var untranslate_term_nboyer; +var BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer; +var BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer; +var translate_alist_nboyer; +var apply_subst_nboyer; +var apply_subst_lst_nboyer; +var tautologyp_nboyer; +var if_constructor_nboyer; +var rewrite_count_nboyer; +var rewrite_nboyer; +var rewrite_args_nboyer; +var unify_subst_nboyer; +var one_way_unify1_nboyer; +var false_term_nboyer; +var true_term_nboyer; +var trans_of_implies1_nboyer; +var is_term_equal_nboyer; +var is_term_member_nboyer; +var const_nboyer; +var sc_const_3_nboyer; +var sc_const_4_nboyer; +{ + (sc_const_4_nboyer = (new sc_Pair("\u1E9Cimplies",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cu",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cw",null)))))),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cw",null)))))),null))))))); + (sc_const_3_nboyer = sc_list((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccompile",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Ccodegen",(new sc_Pair((new sc_Pair("\u1E9Coptimize",(new sc_Pair("\u1E9Cform",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreaterp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clesseqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cboolean",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ciff",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ceven1",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Codd",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccountps-",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccountps-loop",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cpred",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfact-",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfact-loop",(new sc_Pair("\u1E9Ci",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdivides",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-true",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassume-false",(new sc_Pair("\u1E9Cvar",(new sc_Pair("\u1E9Calist",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cvar",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))),(new sc_Pair("\u1E9Calist",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctautology-checker",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctautologyp",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfalsify",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfalsify1",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime1",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cx",null)))),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair("\u1E9Cp",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cimplies",(new sc_Pair("\u1E9Cp",(new sc_Pair("\u1E9Cq",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cp",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cq",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair((new sc_Pair("\u1E9Cf",null)),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Ct",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))))),(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",(new sc_Pair("\u1E9Ce",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cc",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cplus-fringe",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cexec",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cpds",(new sc_Pair("\u1E9Cenvrn",null)))))))),(new sc_Pair("\u1E9Cenvrn",null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmc-flatten",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Cintersect",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Ck",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ck",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair((new sc_Pair("\u1E9Cexp",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ck",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Cy",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Creverse-loop",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Csort-lp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ccount-list",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus1",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cl",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Ci",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cbase",null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cj",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cj",(new sc_Pair((1),null)))))),null)))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Ci",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cpower-eval",(new sc_Pair((new sc_Pair("\u1E9Cbig-plus",(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cpower-rep",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Cbase",null)))))))))),(new sc_Pair("\u1E9Cbase",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cj",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Ca",null)))),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cw",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cx",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cc",null)))))),null)))))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cb",(new sc_Pair("\u1E9Cc",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cz",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Cgcd",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair((new sc_Pair("\u1E9Cnormalize",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cvalue",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cy",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnlistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csamefringe",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((1),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair((new sc_Pair("\u1E9Cgreatest-factor",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ctimes-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cprime-list",(new sc_Pair("\u1E9Cy",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Cz",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cz",null)))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cz",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cw",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cgreatereqp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cor",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cand",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cy",(new sc_Pair((1),null)))))),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((1),null)))))),(new sc_Pair(sc_list("\u1E9Cand", (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair("\u1E9Cb",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Ca",null)))), (new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cb",null)))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csub1",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cl",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cl",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cl",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdsort",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Csort2",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx1",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx2",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx3",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx4",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx5",(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair("\u1E9Cx6",(new sc_Pair("\u1E9Cx7",null)))))),null)))))),null)))))),null)))))),null)))))),null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((6),(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cx7",null)))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((2),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair("\u1E9Cy",(new sc_Pair((2),null)))))),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Csigma",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ci",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Ci",null)))),null)))))),(new sc_Pair((2),null)))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cz",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnot",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cz",null)))),null)))))),null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair((new sc_Pair("\u1E9Cdelete",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmeaning",(new sc_Pair((new sc_Pair("\u1E9Cplus-tree",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair("\u1E9Ca",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cadd1",(new sc_Pair("\u1E9Cy",null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cnumberp",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cnth",(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Ci",null)))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Cb",null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Ca",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Clast",(new sc_Pair("\u1E9Ca",null)))),null)))),(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair("\u1E9Cb",null)))))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clessp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ct",null)),(new sc_Pair("\u1E9Cz",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cf",null)),(new sc_Pair("\u1E9Cz",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Cassignedp",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Ca",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cassignment",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cb",null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccar",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cgopher",(new sc_Pair("\u1E9Cx",null)))),null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Clistp",(new sc_Pair("\u1E9Cx",null)))),(new sc_Pair((new sc_Pair("\u1E9Ccdr",(new sc_Pair((new sc_Pair("\u1E9Cflatten",(new sc_Pair("\u1E9Cx",null)))),null)))),(new sc_Pair((new sc_Pair("\u1E9Ccons",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cquotient",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cx",null)))))),(new sc_Pair("\u1E9Cy",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Czerop",(new sc_Pair("\u1E9Cy",null)))),(new sc_Pair((new sc_Pair("\u1E9Czero",null)),(new sc_Pair((new sc_Pair("\u1E9Cfix",(new sc_Pair("\u1E9Cx",null)))),null)))))))),null)))))), (new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair((new sc_Pair("\u1E9Cset",(new sc_Pair("\u1E9Ci",(new sc_Pair("\u1E9Cval",(new sc_Pair("\u1E9Cmem",null)))))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cif",(new sc_Pair((new sc_Pair("\u1E9Ceqp",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Ci",null)))))),(new sc_Pair("\u1E9Cval",(new sc_Pair((new sc_Pair("\u1E9Cget",(new sc_Pair("\u1E9Cj",(new sc_Pair("\u1E9Cmem",null)))))),null)))))))),null)))))))); + (const_nboyer = (new sc_Pair((new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair((new sc_Pair("\u1E9Czero",null)),null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cy",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair((new sc_Pair("\u1E9Ctimes",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Cc",(new sc_Pair("\u1E9Cd",null)))))),null)))))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cz",(new sc_Pair("\u1E9Cf",(new sc_Pair((new sc_Pair("\u1E9Creverse",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair((new sc_Pair("\u1E9Cappend",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cnil",null)),null)))))),null)))),null)))))),(new sc_Pair((new sc_Pair("\u1E9Cu",(new sc_Pair("\u1E9Cequal",(new sc_Pair((new sc_Pair("\u1E9Cplus",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cdifference",(new sc_Pair("\u1E9Cx",(new sc_Pair("\u1E9Cy",null)))))),null)))))))),(new sc_Pair((new sc_Pair("\u1E9Cw",(new sc_Pair("\u1E9Clessp",(new sc_Pair((new sc_Pair("\u1E9Cremainder",(new sc_Pair("\u1E9Ca",(new sc_Pair("\u1E9Cb",null)))))),(new sc_Pair((new sc_Pair("\u1E9Cmember",(new sc_Pair("\u1E9Ca",(new sc_Pair((new sc_Pair("\u1E9Clength",(new sc_Pair("\u1E9Cb",null)))),null)))))),null)))))))),null))))))))))); + BgL_nboyerzd2benchmarkzd2 = function() { + var args = null; + for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) { + args = sc_cons(arguments[sc_tmp], args); + } + var n; + return ((n = ((args === null)?(0):(args.car))), (BgL_setupzd2boyerzd2()), (BgL_runzd2benchmarkzd2(("nboyer"+(sc_number2string(n))), (1), function() { + return (BgL_testzd2boyerzd2(n)); + }, function(rewrites) { + if ((sc_isNumber(rewrites))) + switch (n) { + case (0): + return (rewrites===(95024)); + break; + case (1): + return (rewrites===(591777)); + break; + case (2): + return (rewrites===(1813975)); + break; + case (3): + return (rewrites===(5375678)); + break; + case (4): + return (rewrites===(16445406)); + break; + case (5): + return (rewrites===(51507739)); + break; + default: + return true; + break; + } + else + return false; + }))); + }; + BgL_setupzd2boyerzd2 = function() { + return true; + }; + BgL_testzd2boyerzd2 = function() { + return true; + }; + translate_term_nboyer = function(term) { + var lst; + return (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((translate_term_nboyer((lst.car))), (translate_args_nboyer((lst.cdr)))))))))); + }; + translate_args_nboyer = function(lst) { + var sc_lst_5; + var term; + return ((lst === null)?null:(new sc_Pair(((term = (lst.car)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))), ((sc_lst_5 = (lst.cdr)), ((sc_lst_5 === null)?null:(new sc_Pair((translate_term_nboyer((sc_lst_5.car))), (translate_args_nboyer((sc_lst_5.cdr)))))))))); + }; + untranslate_term_nboyer = function(term) { + var optrOpnd; + var tail1131; + var L1127; + var falseHead1130; + var symbol_record; + if (!(term instanceof sc_Pair)) + return term; + else + { + (falseHead1130 = (new sc_Pair(null, null))); + (L1127 = (term.cdr)); + (tail1131 = falseHead1130); + while (!(L1127 === null)) { + { + (tail1131.cdr = (new sc_Pair((untranslate_term_nboyer((L1127.car))), null))); + (tail1131 = (tail1131.cdr)); + (L1127 = (L1127.cdr)); + } + } + (optrOpnd = (falseHead1130.cdr)); + return (new sc_Pair(((symbol_record = (term.car)), (symbol_record[(0)])), optrOpnd)); + } + }; + BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer = function(sym) { + var r; + var x; + return ((x = (sc_assq(sym, BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), ((x!== false)?(x.cdr):((r = [sym, null]), (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = (new sc_Pair((new sc_Pair(sym, r)), BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer))), r))); + }; + (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null); + translate_alist_nboyer = function(alist) { + var sc_alist_6; + var term; + return ((alist === null)?null:(new sc_Pair((new sc_Pair((alist.car.car), ((term = (alist.car.cdr)), (!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr))))))))), ((sc_alist_6 = (alist.cdr)), ((sc_alist_6 === null)?null:(new sc_Pair((new sc_Pair((sc_alist_6.car.car), (translate_term_nboyer((sc_alist_6.car.cdr))))), (translate_alist_nboyer((sc_alist_6.cdr)))))))))); + }; + apply_subst_nboyer = function(alist, term) { + var lst; + var temp_temp; + return (!(term instanceof sc_Pair)?((temp_temp = (sc_assq(term, alist))), ((temp_temp!== false)?(temp_temp.cdr):term)):(new sc_Pair((term.car), ((lst = (term.cdr)), ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), (apply_subst_lst_nboyer(alist, (lst.cdr)))))))))); + }; + apply_subst_lst_nboyer = function(alist, lst) { + var sc_lst_7; + return ((lst === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (lst.car))), ((sc_lst_7 = (lst.cdr)), ((sc_lst_7 === null)?null:(new sc_Pair((apply_subst_nboyer(alist, (sc_lst_7.car))), (apply_subst_lst_nboyer(alist, (sc_lst_7.cdr)))))))))); + }; + tautologyp_nboyer = function(sc_x_11, true_lst, false_lst) { + var tmp1125; + var x; + var tmp1126; + var sc_x_8; + var sc_tmp1125_9; + var sc_tmp1126_10; + var sc_x_11; + var true_lst; + var false_lst; + while (true) { + if ((((sc_tmp1126_10 = (is_term_equal_nboyer(sc_x_11, true_term_nboyer))), ((sc_tmp1126_10!== false)?sc_tmp1126_10:(is_term_member_nboyer(sc_x_11, true_lst))))!== false)) + return true; + else + if ((((sc_tmp1125_9 = (is_term_equal_nboyer(sc_x_11, false_term_nboyer))), ((sc_tmp1125_9!== false)?sc_tmp1125_9:(is_term_member_nboyer(sc_x_11, false_lst))))!== false)) + return false; + else + if (!(sc_x_11 instanceof sc_Pair)) + return false; + else + if (((sc_x_11.car)===if_constructor_nboyer)) + if ((((sc_x_8 = (sc_x_11.cdr.car)), (tmp1126 = (is_term_equal_nboyer(sc_x_8, true_term_nboyer))), ((tmp1126!== false)?tmp1126:(is_term_member_nboyer(sc_x_8, true_lst))))!== false)) + (sc_x_11 = (sc_x_11.cdr.cdr.car)); + else + if ((((x = (sc_x_11.cdr.car)), (tmp1125 = (is_term_equal_nboyer(x, false_term_nboyer))), ((tmp1125!== false)?tmp1125:(is_term_member_nboyer(x, false_lst))))!== false)) + (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car)); + else + if (((tautologyp_nboyer((sc_x_11.cdr.cdr.car), (new sc_Pair((sc_x_11.cdr.car), true_lst)), false_lst))!== false)) + { + (false_lst = (new sc_Pair((sc_x_11.cdr.car), false_lst))); + (sc_x_11 = (sc_x_11.cdr.cdr.cdr.car)); + } + else + return false; + else + return false; + } + }; + (if_constructor_nboyer = "\u1E9C*"); + (rewrite_count_nboyer = (0)); + rewrite_nboyer = function(term) { + var term2; + var sc_term_12; + var lst; + var symbol_record; + var sc_lst_13; + { + (++rewrite_count_nboyer); + if (!(term instanceof sc_Pair)) + return term; + else + { + (sc_term_12 = (new sc_Pair((term.car), ((sc_lst_13 = (term.cdr)), ((sc_lst_13 === null)?null:(new sc_Pair((rewrite_nboyer((sc_lst_13.car))), (rewrite_args_nboyer((sc_lst_13.cdr)))))))))); + (lst = ((symbol_record = (term.car)), (symbol_record[(1)]))); + while (true) { + if ((lst === null)) + return sc_term_12; + else + if ((((term2 = ((lst.car).cdr.car)), (unify_subst_nboyer = null), (one_way_unify1_nboyer(sc_term_12, term2)))!== false)) + return (rewrite_nboyer((apply_subst_nboyer(unify_subst_nboyer, ((lst.car).cdr.cdr.car))))); + else + (lst = (lst.cdr)); + } + } + } + }; + rewrite_args_nboyer = function(lst) { + var sc_lst_14; + return ((lst === null)?null:(new sc_Pair((rewrite_nboyer((lst.car))), ((sc_lst_14 = (lst.cdr)), ((sc_lst_14 === null)?null:(new sc_Pair((rewrite_nboyer((sc_lst_14.car))), (rewrite_args_nboyer((sc_lst_14.cdr)))))))))); + }; + (unify_subst_nboyer = "\u1E9C*"); + one_way_unify1_nboyer = function(term1, term2) { + var lst1; + var lst2; + var temp_temp; + if (!(term2 instanceof sc_Pair)) + { + (temp_temp = (sc_assq(term2, unify_subst_nboyer))); + if ((temp_temp!== false)) + return (is_term_equal_nboyer(term1, (temp_temp.cdr))); + else + if ((sc_isNumber(term2))) + return (sc_isEqual(term1, term2)); + else + { + (unify_subst_nboyer = (new sc_Pair((new sc_Pair(term2, term1)), unify_subst_nboyer))); + return true; + } + } + else + if (!(term1 instanceof sc_Pair)) + return false; + else + if (((term1.car)===(term2.car))) + { + (lst1 = (term1.cdr)); + (lst2 = (term2.cdr)); + while (true) { + if ((lst1 === null)) + return (lst2 === null); + else + if ((lst2 === null)) + return false; + else + if (((one_way_unify1_nboyer((lst1.car), (lst2.car)))!== false)) + { + (lst1 = (lst1.cdr)); + (lst2 = (lst2.cdr)); + } + else + return false; + } + } + else + return false; + }; + (false_term_nboyer = "\u1E9C*"); + (true_term_nboyer = "\u1E9C*"); + trans_of_implies1_nboyer = function(n) { + var sc_n_15; + return ((sc_isEqual(n, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (n-(1)), n)), ((sc_n_15 = (n-(1))), ((sc_isEqual(sc_n_15, (1)))?(sc_list("\u1E9Cimplies", (0), (1))):(sc_list("\u1E9Cand", (sc_list("\u1E9Cimplies", (sc_n_15-(1)), sc_n_15)), (trans_of_implies1_nboyer((sc_n_15-(1))))))))))); + }; + is_term_equal_nboyer = function(x, y) { + var lst1; + var lst2; + var r2; + var r1; + if ((x instanceof sc_Pair)) + if ((y instanceof sc_Pair)) + if ((((r1 = (x.car)), (r2 = (y.car)), (r1===r2))!== false)) + { + (lst1 = (x.cdr)); + (lst2 = (y.cdr)); + while (true) { + if ((lst1 === null)) + return (lst2 === null); + else + if ((lst2 === null)) + return false; + else + if (((is_term_equal_nboyer((lst1.car), (lst2.car)))!== false)) + { + (lst1 = (lst1.cdr)); + (lst2 = (lst2.cdr)); + } + else + return false; + } + } + else + return false; + else + return false; + else + return (sc_isEqual(x, y)); + }; + is_term_member_nboyer = function(x, lst) { + var x; + var lst; + while (true) { + if ((lst === null)) + return false; + else + if (((is_term_equal_nboyer(x, (lst.car)))!== false)) + return true; + else + (lst = (lst.cdr)); + } + }; + BgL_setupzd2boyerzd2 = function() { + var symbol_record; + var value; + var BgL_sc_symbolzd2record_16zd2; + var sym; + var sc_sym_17; + var term; + var lst; + var sc_term_18; + var sc_term_19; + { + (BgL_sc_za2symbolzd2recordszd2alistza2_2z00_nboyer = null); + (if_constructor_nboyer = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer("\u1E9Cif"))); + (false_term_nboyer = ((sc_term_19 = (new sc_Pair("\u1E9Cf",null))), (!(sc_term_19 instanceof sc_Pair)?sc_term_19:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_19.car))), (translate_args_nboyer((sc_term_19.cdr)))))))); + (true_term_nboyer = ((sc_term_18 = (new sc_Pair("\u1E9Ct",null))), (!(sc_term_18 instanceof sc_Pair)?sc_term_18:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_18.car))), (translate_args_nboyer((sc_term_18.cdr)))))))); + (lst = sc_const_3_nboyer); + while (!(lst === null)) { + { + (term = (lst.car)); + if (((term instanceof sc_Pair)&&(((term.car)==="\u1E9Cequal")&&((term.cdr.car) instanceof sc_Pair)))) + { + (sc_sym_17 = ((term.cdr.car).car)); + (value = (new sc_Pair((!(term instanceof sc_Pair)?term:(new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((term.car))), (translate_args_nboyer((term.cdr)))))), ((sym = ((term.cdr.car).car)), (BgL_sc_symbolzd2record_16zd2 = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sym))), (BgL_sc_symbolzd2record_16zd2[(1)]))))); + (symbol_record = (BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer(sc_sym_17))); + (symbol_record[(1)] = value); + } + else + (sc_error("ADD-LEMMA did not like term: ", term)); + (lst = (lst.cdr)); + } + } + return true; + } + }; + BgL_testzd2boyerzd2 = function(n) { + var optrOpnd; + var term; + var sc_n_20; + var answer; + var sc_term_21; + var sc_term_22; + { + (rewrite_count_nboyer = (0)); + (term = sc_const_4_nboyer); + (sc_n_20 = n); + while (!(sc_n_20=== 0)) { + { + (term = (sc_list("\u1E9Cor", term, (new sc_Pair("\u1E9Cf",null))))); + (--sc_n_20); + } + } + (sc_term_22 = term); + if (!(sc_term_22 instanceof sc_Pair)) + (optrOpnd = sc_term_22); + else + (optrOpnd = (new sc_Pair((BgL_sc_symbolzd2ze3symbolzd2record_1ze3_nboyer((sc_term_22.car))), (translate_args_nboyer((sc_term_22.cdr)))))); + (sc_term_21 = (apply_subst_nboyer(((const_nboyer === null)?null:(new sc_Pair((new sc_Pair((const_nboyer.car.car), (translate_term_nboyer((const_nboyer.car.cdr))))), (translate_alist_nboyer((const_nboyer.cdr)))))), optrOpnd))); + (answer = (tautologyp_nboyer((rewrite_nboyer(sc_term_21)), null, null))); + (sc_write(rewrite_count_nboyer)); + (sc_display(" rewrites")); + (sc_newline()); + if ((answer!== false)) + return rewrite_count_nboyer; + else + return false; + } + }; +} +/* Exported Variables */ +var BgL_parsezd2ze3nbzd2treesze3; +var BgL_earleyzd2benchmarkzd2; +var BgL_parsezd2ze3parsedzf3zc2; +var test; +var BgL_parsezd2ze3treesz31; +var BgL_makezd2parserzd2; +/* End Exports */ + +var const_earley; +{ + (const_earley = (new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair((new sc_Pair("\u1E9Ca",null)),(new sc_Pair((new sc_Pair("\u1E9Cs",(new sc_Pair("\u1E9Cs",null)))),null)))))),null))); + BgL_makezd2parserzd2 = function(grammar, lexer) { + var i; + var parser_descr; + var def_loop; + var nb_nts; + var names; + var steps; + var predictors; + var enders; + var starters; + var nts; + var sc_names_1; + var sc_steps_2; + var sc_predictors_3; + var sc_enders_4; + var sc_starters_5; + var nb_confs; + var BgL_sc_defzd2loop_6zd2; + var BgL_sc_nbzd2nts_7zd2; + var sc_nts_8; + var BgL_sc_defzd2loop_9zd2; + var ind; + { + ind = function(nt, sc_nts_10) { + var i; + { + (i = ((sc_nts_10.length)-(1))); + while (true) { + if ((i>=(0))) + if ((sc_isEqual((sc_nts_10[i]), nt))) + return i; + else + (--i); + else + return false; + } + } + }; + (sc_nts_8 = ((BgL_sc_defzd2loop_9zd2 = function(defs, sc_nts_11) { + var rule_loop; + var head; + var def; + return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, sc_nts_12) { + var nt; + var l; + var sc_nts_13; + var rule; + if ((rules instanceof sc_Pair)) + { + (rule = (rules.car)); + (l = rule); + (sc_nts_13 = sc_nts_12); + while ((l instanceof sc_Pair)) { + { + (nt = (l.car)); + (l = (l.cdr)); + (sc_nts_13 = (((sc_member(nt, sc_nts_13))!== false)?sc_nts_13:(new sc_Pair(nt, sc_nts_13)))); + } + } + return (rule_loop((rules.cdr), sc_nts_13)); + } + else + return (BgL_sc_defzd2loop_9zd2((defs.cdr), sc_nts_12)); + }), (rule_loop((def.cdr), (((sc_member(head, sc_nts_11))!== false)?sc_nts_11:(new sc_Pair(head, sc_nts_11)))))):(sc_list2vector((sc_reverse(sc_nts_11))))); + }), (BgL_sc_defzd2loop_9zd2(grammar, null)))); + (BgL_sc_nbzd2nts_7zd2 = (sc_nts_8.length)); + (nb_confs = (((BgL_sc_defzd2loop_6zd2 = function(defs, BgL_sc_nbzd2confs_14zd2) { + var rule_loop; + var def; + return ((defs instanceof sc_Pair)?((def = (defs.car)), (rule_loop = function(rules, BgL_sc_nbzd2confs_15zd2) { + var l; + var BgL_sc_nbzd2confs_16zd2; + var rule; + if ((rules instanceof sc_Pair)) + { + (rule = (rules.car)); + (l = rule); + (BgL_sc_nbzd2confs_16zd2 = BgL_sc_nbzd2confs_15zd2); + while ((l instanceof sc_Pair)) { + { + (l = (l.cdr)); + (++BgL_sc_nbzd2confs_16zd2); + } + } + return (rule_loop((rules.cdr), (BgL_sc_nbzd2confs_16zd2+(1)))); + } + else + return (BgL_sc_defzd2loop_6zd2((defs.cdr), BgL_sc_nbzd2confs_15zd2)); + }), (rule_loop((def.cdr), BgL_sc_nbzd2confs_14zd2))):BgL_sc_nbzd2confs_14zd2); + }), (BgL_sc_defzd2loop_6zd2(grammar, (0))))+BgL_sc_nbzd2nts_7zd2)); + (sc_starters_5 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); + (sc_enders_4 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); + (sc_predictors_3 = (sc_makeVector(BgL_sc_nbzd2nts_7zd2, null))); + (sc_steps_2 = (sc_makeVector(nb_confs, false))); + (sc_names_1 = (sc_makeVector(nb_confs, false))); + (nts = sc_nts_8); + (starters = sc_starters_5); + (enders = sc_enders_4); + (predictors = sc_predictors_3); + (steps = sc_steps_2); + (names = sc_names_1); + (nb_nts = (sc_nts_8.length)); + (i = (nb_nts-(1))); + while ((i>=(0))) { + { + (sc_steps_2[i] = (i-nb_nts)); + (sc_names_1[i] = (sc_list((sc_nts_8[i]), (0)))); + (sc_enders_4[i] = (sc_list(i))); + (--i); + } + } + def_loop = function(defs, conf) { + var rule_loop; + var head; + var def; + return ((defs instanceof sc_Pair)?((def = (defs.car)), (head = (def.car)), (rule_loop = function(rules, conf, rule_num) { + var i; + var sc_i_17; + var nt; + var l; + var sc_conf_18; + var sc_i_19; + var rule; + if ((rules instanceof sc_Pair)) + { + (rule = (rules.car)); + (names[conf] = (sc_list(head, rule_num))); + (sc_i_19 = (ind(head, nts))); + (starters[sc_i_19] = (new sc_Pair(conf, (starters[sc_i_19])))); + (l = rule); + (sc_conf_18 = conf); + while ((l instanceof sc_Pair)) { + { + (nt = (l.car)); + (steps[sc_conf_18] = (ind(nt, nts))); + (sc_i_17 = (ind(nt, nts))); + (predictors[sc_i_17] = (new sc_Pair(sc_conf_18, (predictors[sc_i_17])))); + (l = (l.cdr)); + (++sc_conf_18); + } + } + (steps[sc_conf_18] = ((ind(head, nts))-nb_nts)); + (i = (ind(head, nts))); + (enders[i] = (new sc_Pair(sc_conf_18, (enders[i])))); + return (rule_loop((rules.cdr), (sc_conf_18+(1)), (rule_num+(1)))); + } + else + return (def_loop((defs.cdr), conf)); + }), (rule_loop((def.cdr), conf, (1)))):undefined); + }; + (def_loop(grammar, (sc_nts_8.length))); + (parser_descr = [lexer, sc_nts_8, sc_starters_5, sc_enders_4, sc_predictors_3, sc_steps_2, sc_names_1]); + return function(input) { + var optrOpnd; + var sc_optrOpnd_20; + var sc_optrOpnd_21; + var sc_optrOpnd_22; + var loop1; + var BgL_sc_stateza2_23za2; + var toks; + var BgL_sc_nbzd2nts_24zd2; + var sc_steps_25; + var sc_enders_26; + var state_num; + var BgL_sc_statesza2_27za2; + var states; + var i; + var conf; + var l; + var tok_nts; + var sc_i_28; + var sc_i_29; + var l1; + var l2; + var tok; + var tail1129; + var L1125; + var goal_enders; + var BgL_sc_statesza2_30za2; + var BgL_sc_nbzd2nts_31zd2; + var BgL_sc_nbzd2confs_32zd2; + var nb_toks; + var goal_starters; + var sc_states_33; + var BgL_sc_nbzd2confs_34zd2; + var BgL_sc_nbzd2toks_35zd2; + var sc_toks_36; + var falseHead1128; + var sc_names_37; + var sc_steps_38; + var sc_predictors_39; + var sc_enders_40; + var sc_starters_41; + var sc_nts_42; + var lexer; + var sc_ind_43; + var make_states; + var BgL_sc_confzd2setzd2getza2_44za2; + var conf_set_merge_new_bang; + var conf_set_adjoin; + var BgL_sc_confzd2setzd2adjoinza2_45za2; + var BgL_sc_confzd2setzd2adjoinza2za2_46z00; + var conf_set_union; + var forw; + var is_parsed; + var deriv_trees; + var BgL_sc_derivzd2treesza2_47z70; + var nb_deriv_trees; + var BgL_sc_nbzd2derivzd2treesza2_48za2; + { + sc_ind_43 = function(nt, sc_nts_49) { + var i; + { + (i = ((sc_nts_49.length)-(1))); + while (true) { + if ((i>=(0))) + if ((sc_isEqual((sc_nts_49[i]), nt))) + return i; + else + (--i); + else + return false; + } + } + }; + make_states = function(BgL_sc_nbzd2toks_50zd2, BgL_sc_nbzd2confs_51zd2) { + var v; + var i; + var sc_states_52; + { + (sc_states_52 = (sc_makeVector((BgL_sc_nbzd2toks_50zd2+(1)), false))); + (i = BgL_sc_nbzd2toks_50zd2); + while ((i>=(0))) { + { + (v = (sc_makeVector((BgL_sc_nbzd2confs_51zd2+(1)), false))); + (v[(0)] = (-1)); + (sc_states_52[i] = v); + (--i); + } + } + return sc_states_52; + } + }; + BgL_sc_confzd2setzd2getza2_44za2 = function(state, BgL_sc_statezd2num_53zd2, sc_conf_54) { + var conf_set; + var BgL_sc_confzd2set_55zd2; + return ((BgL_sc_confzd2set_55zd2 = (state[(sc_conf_54+(1))])), ((BgL_sc_confzd2set_55zd2!== false)?BgL_sc_confzd2set_55zd2:((conf_set = (sc_makeVector((BgL_sc_statezd2num_53zd2+(6)), false))), (conf_set[(1)] = (-3)), (conf_set[(2)] = (-1)), (conf_set[(3)] = (-1)), (conf_set[(4)] = (-1)), (state[(sc_conf_54+(1))] = conf_set), conf_set))); + }; + conf_set_merge_new_bang = function(conf_set) { + return ((conf_set[((conf_set[(1)])+(5))] = (conf_set[(4)])), (conf_set[(1)] = (conf_set[(3)])), (conf_set[(3)] = (-1)), (conf_set[(4)] = (-1))); + }; + conf_set_adjoin = function(state, conf_set, sc_conf_56, i) { + var tail; + return ((tail = (conf_set[(3)])), (conf_set[(i+(5))] = (-1)), (conf_set[(tail+(5))] = i), (conf_set[(3)] = i), ((tail<(0))?((conf_set[(0)] = (state[(0)])), (state[(0)] = sc_conf_56)):undefined)); + }; + BgL_sc_confzd2setzd2adjoinza2_45za2 = function(sc_states_57, BgL_sc_statezd2num_58zd2, l, i) { + var conf_set; + var sc_conf_59; + var l1; + var state; + { + (state = (sc_states_57[BgL_sc_statezd2num_58zd2])); + (l1 = l); + while ((l1 instanceof sc_Pair)) { + { + (sc_conf_59 = (l1.car)); + (conf_set = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_58zd2, sc_conf_59))); + if (((conf_set[(i+(5))])=== false)) + { + (conf_set_adjoin(state, conf_set, sc_conf_59, i)); + (l1 = (l1.cdr)); + } + else + (l1 = (l1.cdr)); + } + } + return undefined; + } + }; + BgL_sc_confzd2setzd2adjoinza2za2_46z00 = function(sc_states_60, BgL_sc_statesza2_61za2, BgL_sc_statezd2num_62zd2, sc_conf_63, i) { + var BgL_sc_confzd2setza2_64z70; + var BgL_sc_stateza2_65za2; + var conf_set; + var state; + return ((state = (sc_states_60[BgL_sc_statezd2num_62zd2])), ((((conf_set = (state[(sc_conf_63+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)?((BgL_sc_stateza2_65za2 = (BgL_sc_statesza2_61za2[BgL_sc_statezd2num_62zd2])), (BgL_sc_confzd2setza2_64z70 = (BgL_sc_confzd2setzd2getza2_44za2(BgL_sc_stateza2_65za2, BgL_sc_statezd2num_62zd2, sc_conf_63))), (((BgL_sc_confzd2setza2_64z70[(i+(5))])=== false)?(conf_set_adjoin(BgL_sc_stateza2_65za2, BgL_sc_confzd2setza2_64z70, sc_conf_63, i)):undefined), true):false)); + }; + conf_set_union = function(state, conf_set, sc_conf_66, other_set) { + var i; + { + (i = (other_set[(2)])); + while ((i>=(0))) { + if (((conf_set[(i+(5))])=== false)) + { + (conf_set_adjoin(state, conf_set, sc_conf_66, i)); + (i = (other_set[(i+(5))])); + } + else + (i = (other_set[(i+(5))])); + } + return undefined; + } + }; + forw = function(sc_states_67, BgL_sc_statezd2num_68zd2, sc_starters_69, sc_enders_70, sc_predictors_71, sc_steps_72, sc_nts_73) { + var next_set; + var next; + var conf_set; + var ender; + var l; + var starter_set; + var starter; + var sc_l_74; + var sc_loop1_75; + var head; + var BgL_sc_confzd2set_76zd2; + var BgL_sc_statezd2num_77zd2; + var state; + var sc_states_78; + var preds; + var BgL_sc_confzd2set_79zd2; + var step; + var sc_conf_80; + var BgL_sc_nbzd2nts_81zd2; + var sc_state_82; + { + (sc_state_82 = (sc_states_67[BgL_sc_statezd2num_68zd2])); + (BgL_sc_nbzd2nts_81zd2 = (sc_nts_73.length)); + while (true) { + { + (sc_conf_80 = (sc_state_82[(0)])); + if ((sc_conf_80>=(0))) + { + (step = (sc_steps_72[sc_conf_80])); + (BgL_sc_confzd2set_79zd2 = (sc_state_82[(sc_conf_80+(1))])); + (head = (BgL_sc_confzd2set_79zd2[(4)])); + (sc_state_82[(0)] = (BgL_sc_confzd2set_79zd2[(0)])); + (conf_set_merge_new_bang(BgL_sc_confzd2set_79zd2)); + if ((step>=(0))) + { + (sc_l_74 = (sc_starters_69[step])); + while ((sc_l_74 instanceof sc_Pair)) { + { + (starter = (sc_l_74.car)); + (starter_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, starter))); + if (((starter_set[(BgL_sc_statezd2num_68zd2+(5))])=== false)) + { + (conf_set_adjoin(sc_state_82, starter_set, starter, BgL_sc_statezd2num_68zd2)); + (sc_l_74 = (sc_l_74.cdr)); + } + else + (sc_l_74 = (sc_l_74.cdr)); + } + } + (l = (sc_enders_70[step])); + while ((l instanceof sc_Pair)) { + { + (ender = (l.car)); + if ((((conf_set = (sc_state_82[(ender+(1))])), ((conf_set!== false)?(conf_set[(BgL_sc_statezd2num_68zd2+(5))]):false))!== false)) + { + (next = (sc_conf_80+(1))); + (next_set = (BgL_sc_confzd2setzd2getza2_44za2(sc_state_82, BgL_sc_statezd2num_68zd2, next))); + (conf_set_union(sc_state_82, next_set, next, BgL_sc_confzd2set_79zd2)); + (l = (l.cdr)); + } + else + (l = (l.cdr)); + } + } + } + else + { + (preds = (sc_predictors_71[(step+BgL_sc_nbzd2nts_81zd2)])); + (sc_states_78 = sc_states_67); + (state = sc_state_82); + (BgL_sc_statezd2num_77zd2 = BgL_sc_statezd2num_68zd2); + (BgL_sc_confzd2set_76zd2 = BgL_sc_confzd2set_79zd2); + sc_loop1_75 = function(l) { + var sc_state_83; + var BgL_sc_nextzd2set_84zd2; + var sc_next_85; + var pred_set; + var i; + var pred; + if ((l instanceof sc_Pair)) + { + (pred = (l.car)); + (i = head); + while ((i>=(0))) { + { + (pred_set = ((sc_state_83 = (sc_states_78[i])), (sc_state_83[(pred+(1))]))); + if ((pred_set!== false)) + { + (sc_next_85 = (pred+(1))); + (BgL_sc_nextzd2set_84zd2 = (BgL_sc_confzd2setzd2getza2_44za2(state, BgL_sc_statezd2num_77zd2, sc_next_85))); + (conf_set_union(state, BgL_sc_nextzd2set_84zd2, sc_next_85, pred_set)); + } + (i = (BgL_sc_confzd2set_76zd2[(i+(5))])); + } + } + return (sc_loop1_75((l.cdr))); + } + else + return undefined; + }; + (sc_loop1_75(preds)); + } + } + else + return undefined; + } + } + } + }; + is_parsed = function(nt, i, j, sc_nts_86, sc_enders_87, sc_states_88) { + var conf_set; + var state; + var sc_conf_89; + var l; + var BgL_sc_ntza2_90za2; + { + (BgL_sc_ntza2_90za2 = (sc_ind_43(nt, sc_nts_86))); + if ((BgL_sc_ntza2_90za2!== false)) + { + (sc_nts_86.length); + (l = (sc_enders_87[BgL_sc_ntza2_90za2])); + while (true) { + if ((l instanceof sc_Pair)) + { + (sc_conf_89 = (l.car)); + if ((((state = (sc_states_88[j])), (conf_set = (state[(sc_conf_89+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) + return true; + else + (l = (l.cdr)); + } + else + return false; + } + } + else + return false; + } + }; + deriv_trees = function(sc_conf_91, i, j, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2) { + var sc_loop1_98; + var prev; + var name; + return ((name = (sc_names_94[sc_conf_91])), ((name!== false)?((sc_conf_91<BgL_sc_nbzd2nts_97zd2)?(sc_list((sc_list(name, ((sc_toks_95[i]).car))))):(sc_list((sc_list(name))))):((prev = (sc_conf_91-(1))), (sc_loop1_98 = function(l1, l2) { + var loop2; + var ender_set; + var state; + var ender; + var l1; + var l2; + while (true) { + if ((l1 instanceof sc_Pair)) + { + (ender = (l1.car)); + (ender_set = ((state = (sc_states_96[j])), (state[(ender+(1))]))); + if ((ender_set!== false)) + { + loop2 = function(k, l2) { + var loop3; + var ender_trees; + var prev_trees; + var conf_set; + var sc_state_99; + var k; + var l2; + while (true) { + if ((k>=(0))) + if (((k>=i)&&(((sc_state_99 = (sc_states_96[k])), (conf_set = (sc_state_99[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))) + { + (prev_trees = (deriv_trees(prev, i, k, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2))); + (ender_trees = (deriv_trees(ender, k, j, sc_enders_92, sc_steps_93, sc_names_94, sc_toks_95, sc_states_96, BgL_sc_nbzd2nts_97zd2))); + loop3 = function(l3, l2) { + var l4; + var sc_l2_100; + var ender_tree; + if ((l3 instanceof sc_Pair)) + { + (ender_tree = (sc_list((l3.car)))); + (l4 = prev_trees); + (sc_l2_100 = l2); + while ((l4 instanceof sc_Pair)) { + { + (sc_l2_100 = (new sc_Pair((sc_append((l4.car), ender_tree)), sc_l2_100))); + (l4 = (l4.cdr)); + } + } + return (loop3((l3.cdr), sc_l2_100)); + } + else + return (loop2((ender_set[(k+(5))]), l2)); + }; + return (loop3(ender_trees, l2)); + } + else + (k = (ender_set[(k+(5))])); + else + return (sc_loop1_98((l1.cdr), l2)); + } + }; + return (loop2((ender_set[(2)]), l2)); + } + else + (l1 = (l1.cdr)); + } + else + return l2; + } + }), (sc_loop1_98((sc_enders_92[(sc_steps_93[prev])]), null))))); + }; + BgL_sc_derivzd2treesza2_47z70 = function(nt, i, j, sc_nts_101, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106) { + var conf_set; + var state; + var sc_conf_107; + var l; + var trees; + var BgL_sc_nbzd2nts_108zd2; + var BgL_sc_ntza2_109za2; + { + (BgL_sc_ntza2_109za2 = (sc_ind_43(nt, sc_nts_101))); + if ((BgL_sc_ntza2_109za2!== false)) + { + (BgL_sc_nbzd2nts_108zd2 = (sc_nts_101.length)); + (l = (sc_enders_102[BgL_sc_ntza2_109za2])); + (trees = null); + while ((l instanceof sc_Pair)) { + { + (sc_conf_107 = (l.car)); + if ((((state = (sc_states_106[j])), (conf_set = (state[(sc_conf_107+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) + { + (l = (l.cdr)); + (trees = (sc_append((deriv_trees(sc_conf_107, i, j, sc_enders_102, sc_steps_103, sc_names_104, sc_toks_105, sc_states_106, BgL_sc_nbzd2nts_108zd2)), trees))); + } + else + (l = (l.cdr)); + } + } + return trees; + } + else + return false; + } + }; + nb_deriv_trees = function(sc_conf_110, i, j, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2) { + var sc_loop1_116; + var tmp1124; + var prev; + return ((prev = (sc_conf_110-(1))), ((((tmp1124 = (sc_conf_110<BgL_sc_nbzd2nts_115zd2)), ((tmp1124!== false)?tmp1124:((sc_steps_112[prev])<(0))))!== false)?(1):((sc_loop1_116 = function(l, sc_n_118) { + var nb_ender_trees; + var nb_prev_trees; + var conf_set; + var state; + var k; + var n; + var ender_set; + var sc_state_117; + var ender; + var l; + var sc_n_118; + while (true) { + if ((l instanceof sc_Pair)) + { + (ender = (l.car)); + (ender_set = ((sc_state_117 = (sc_states_114[j])), (sc_state_117[(ender+(1))]))); + if ((ender_set!== false)) + { + (k = (ender_set[(2)])); + (n = sc_n_118); + while ((k>=(0))) { + if (((k>=i)&&(((state = (sc_states_114[k])), (conf_set = (state[(prev+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false))) + { + (nb_prev_trees = (nb_deriv_trees(prev, i, k, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2))); + (nb_ender_trees = (nb_deriv_trees(ender, k, j, sc_enders_111, sc_steps_112, sc_toks_113, sc_states_114, BgL_sc_nbzd2nts_115zd2))); + (k = (ender_set[(k+(5))])); + (n +=(nb_prev_trees*nb_ender_trees)); + } + else + (k = (ender_set[(k+(5))])); + } + return (sc_loop1_116((l.cdr), n)); + } + else + (l = (l.cdr)); + } + else + return sc_n_118; + } + }), (sc_loop1_116((sc_enders_111[(sc_steps_112[prev])]), (0)))))); + }; + BgL_sc_nbzd2derivzd2treesza2_48za2 = function(nt, i, j, sc_nts_119, sc_enders_120, sc_steps_121, sc_toks_122, sc_states_123) { + var conf_set; + var state; + var sc_conf_124; + var l; + var nb_trees; + var BgL_sc_nbzd2nts_125zd2; + var BgL_sc_ntza2_126za2; + { + (BgL_sc_ntza2_126za2 = (sc_ind_43(nt, sc_nts_119))); + if ((BgL_sc_ntza2_126za2!== false)) + { + (BgL_sc_nbzd2nts_125zd2 = (sc_nts_119.length)); + (l = (sc_enders_120[BgL_sc_ntza2_126za2])); + (nb_trees = (0)); + while ((l instanceof sc_Pair)) { + { + (sc_conf_124 = (l.car)); + if ((((state = (sc_states_123[j])), (conf_set = (state[(sc_conf_124+(1))])), ((conf_set!== false)?(conf_set[(i+(5))]):false))!== false)) + { + (l = (l.cdr)); + (nb_trees = ((nb_deriv_trees(sc_conf_124, i, j, sc_enders_120, sc_steps_121, sc_toks_122, sc_states_123, BgL_sc_nbzd2nts_125zd2))+nb_trees)); + } + else + (l = (l.cdr)); + } + } + return nb_trees; + } + else + return false; + } + }; + (lexer = (parser_descr[(0)])); + (sc_nts_42 = (parser_descr[(1)])); + (sc_starters_41 = (parser_descr[(2)])); + (sc_enders_40 = (parser_descr[(3)])); + (sc_predictors_39 = (parser_descr[(4)])); + (sc_steps_38 = (parser_descr[(5)])); + (sc_names_37 = (parser_descr[(6)])); + (falseHead1128 = (new sc_Pair(null, null))); + (L1125 = (lexer(input))); + (tail1129 = falseHead1128); + while (!(L1125 === null)) { + { + (tok = (L1125.car)); + (l1 = (tok.cdr)); + (l2 = null); + while ((l1 instanceof sc_Pair)) { + { + (sc_i_29 = (sc_ind_43((l1.car), sc_nts_42))); + if ((sc_i_29!== false)) + { + (l1 = (l1.cdr)); + (l2 = (new sc_Pair(sc_i_29, l2))); + } + else + (l1 = (l1.cdr)); + } + } + (sc_optrOpnd_22 = (new sc_Pair((tok.car), (sc_reverse(l2))))); + (sc_optrOpnd_21 = (new sc_Pair(sc_optrOpnd_22, null))); + (tail1129.cdr = sc_optrOpnd_21); + (tail1129 = (tail1129.cdr)); + (L1125 = (L1125.cdr)); + } + } + (sc_optrOpnd_20 = (falseHead1128.cdr)); + (sc_toks_36 = (sc_list2vector(sc_optrOpnd_20))); + (BgL_sc_nbzd2toks_35zd2 = (sc_toks_36.length)); + (BgL_sc_nbzd2confs_34zd2 = (sc_steps_38.length)); + (sc_states_33 = (make_states(BgL_sc_nbzd2toks_35zd2, BgL_sc_nbzd2confs_34zd2))); + (goal_starters = (sc_starters_41[(0)])); + (BgL_sc_confzd2setzd2adjoinza2_45za2(sc_states_33, (0), goal_starters, (0))); + (forw(sc_states_33, (0), sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_nts_42)); + (sc_i_28 = (0)); + while ((sc_i_28<BgL_sc_nbzd2toks_35zd2)) { + { + (tok_nts = ((sc_toks_36[sc_i_28]).cdr)); + (BgL_sc_confzd2setzd2adjoinza2_45za2(sc_states_33, (sc_i_28+(1)), tok_nts, sc_i_28)); + (forw(sc_states_33, (sc_i_28+(1)), sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_nts_42)); + (++sc_i_28); + } + } + (nb_toks = (sc_toks_36.length)); + (BgL_sc_nbzd2confs_32zd2 = (sc_steps_38.length)); + (BgL_sc_nbzd2nts_31zd2 = (sc_nts_42.length)); + (BgL_sc_statesza2_30za2 = (make_states(nb_toks, BgL_sc_nbzd2confs_32zd2))); + (goal_enders = (sc_enders_40[(0)])); + (l = goal_enders); + while ((l instanceof sc_Pair)) { + { + (conf = (l.car)); + (BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_33, BgL_sc_statesza2_30za2, nb_toks, conf, (0))); + (l = (l.cdr)); + } + } + (i = nb_toks); + while ((i>=(0))) { + { + (states = sc_states_33); + (BgL_sc_statesza2_27za2 = BgL_sc_statesza2_30za2); + (state_num = i); + (sc_enders_26 = sc_enders_40); + (sc_steps_25 = sc_steps_38); + (BgL_sc_nbzd2nts_24zd2 = BgL_sc_nbzd2nts_31zd2); + (toks = sc_toks_36); + (BgL_sc_stateza2_23za2 = (BgL_sc_statesza2_30za2[i])); + loop1 = function() { + var sc_loop1_127; + var prev; + var BgL_sc_statesza2_128za2; + var sc_states_129; + var j; + var i; + var sc_i_130; + var head; + var conf_set; + var sc_conf_131; + { + (sc_conf_131 = (BgL_sc_stateza2_23za2[(0)])); + if ((sc_conf_131>=(0))) + { + (conf_set = (BgL_sc_stateza2_23za2[(sc_conf_131+(1))])); + (head = (conf_set[(4)])); + (BgL_sc_stateza2_23za2[(0)] = (conf_set[(0)])); + (conf_set_merge_new_bang(conf_set)); + (sc_i_130 = head); + while ((sc_i_130>=(0))) { + { + (i = sc_i_130); + (j = state_num); + (sc_states_129 = states); + (BgL_sc_statesza2_128za2 = BgL_sc_statesza2_27za2); + (prev = (sc_conf_131-(1))); + if (((sc_conf_131>=BgL_sc_nbzd2nts_24zd2)&&((sc_steps_25[prev])>=(0)))) + { + sc_loop1_127 = function(l) { + var k; + var ender_set; + var state; + var ender; + var l; + while (true) { + if ((l instanceof sc_Pair)) + { + (ender = (l.car)); + (ender_set = ((state = (sc_states_129[j])), (state[(ender+(1))]))); + if ((ender_set!== false)) + { + (k = (ender_set[(2)])); + while ((k>=(0))) { + { + if ((k>=i)) + if (((BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, k, prev, i))!== false)) + (BgL_sc_confzd2setzd2adjoinza2za2_46z00(sc_states_129, BgL_sc_statesza2_128za2, j, ender, k)); + (k = (ender_set[(k+(5))])); + } + } + return (sc_loop1_127((l.cdr))); + } + else + (l = (l.cdr)); + } + else + return undefined; + } + }; + (sc_loop1_127((sc_enders_26[(sc_steps_25[prev])]))); + } + (sc_i_130 = (conf_set[(sc_i_130+(5))])); + } + } + return (loop1()); + } + else + return undefined; + } + }; + (loop1()); + (--i); + } + } + (optrOpnd = BgL_sc_statesza2_30za2); + return [sc_nts_42, sc_starters_41, sc_enders_40, sc_predictors_39, sc_steps_38, sc_names_37, sc_toks_36, optrOpnd, is_parsed, BgL_sc_derivzd2treesza2_47z70, BgL_sc_nbzd2derivzd2treesza2_48za2]; + } + }; + } + }; + BgL_parsezd2ze3parsedzf3zc2 = function(parse, nt, i, j) { + var is_parsed; + var states; + var enders; + var nts; + return ((nts = (parse[(0)])), (enders = (parse[(2)])), (states = (parse[(7)])), (is_parsed = (parse[(8)])), (is_parsed(nt, i, j, nts, enders, states))); + }; + BgL_parsezd2ze3treesz31 = function(parse, nt, i, j) { + var BgL_sc_derivzd2treesza2_132z70; + var states; + var toks; + var names; + var steps; + var enders; + var nts; + return ((nts = (parse[(0)])), (enders = (parse[(2)])), (steps = (parse[(4)])), (names = (parse[(5)])), (toks = (parse[(6)])), (states = (parse[(7)])), (BgL_sc_derivzd2treesza2_132z70 = (parse[(9)])), (BgL_sc_derivzd2treesza2_132z70(nt, i, j, nts, enders, steps, names, toks, states))); + }; + BgL_parsezd2ze3nbzd2treesze3 = function(parse, nt, i, j) { + var BgL_sc_nbzd2derivzd2treesza2_133za2; + var states; + var toks; + var steps; + var enders; + var nts; + return ((nts = (parse[(0)])), (enders = (parse[(2)])), (steps = (parse[(4)])), (toks = (parse[(6)])), (states = (parse[(7)])), (BgL_sc_nbzd2derivzd2treesza2_133za2 = (parse[(10)])), (BgL_sc_nbzd2derivzd2treesza2_133za2(nt, i, j, nts, enders, steps, toks, states))); + }; + test = function(k) { + var x; + var p; + return ((p = (BgL_makezd2parserzd2(const_earley, function(l) { + var sc_x_134; + var tail1134; + var L1130; + var falseHead1133; + { + (falseHead1133 = (new sc_Pair(null, null))); + (tail1134 = falseHead1133); + (L1130 = l); + while (!(L1130 === null)) { + { + (tail1134.cdr = (new sc_Pair(((sc_x_134 = (L1130.car)), (sc_list(sc_x_134, sc_x_134))), null))); + (tail1134 = (tail1134.cdr)); + (L1130 = (L1130.cdr)); + } + } + return (falseHead1133.cdr); + } + }))), (x = (p((sc_vector2list((sc_makeVector(k, "\u1E9Ca"))))))), (sc_length((BgL_parsezd2ze3treesz31(x, "\u1E9Cs", (0), k))))); + }; + BgL_earleyzd2benchmarkzd2 = function() { + var args = null; + for (var sc_tmp = arguments.length - 1; sc_tmp >= 0; sc_tmp--) { + args = sc_cons(arguments[sc_tmp], args); + } + var k; + return ((k = ((args === null)?(7):(args.car))), (BgL_runzd2benchmarkzd2("earley", (1), function() { + return (test(k)); + }, function(result) { + return ((sc_display(result)), (sc_newline()), result == 132); + }))); + }; +} + + +/************* END OF GENERATED CODE *************/ +// Invoke this function to run a benchmark. +// The first argument is a string identifying the benchmark. +// The second argument is the number of times to run the benchmark. +// The third argument is a function that runs the benchmark. +// The fourth argument is a unary function that warns if the result +// returned by the benchmark is incorrect. +// +// Example: +// RunBenchmark("new Array()", +// 1, +// function () { new Array(1000000); } +// function (v) { +// return (v instanceof Array) && (v.length == 1000000); +// }); + +SC_DEFAULT_OUT = new sc_GenericOutputPort(function(s) {}); +SC_ERROR_OUT = SC_DEFAULT_OUT; + +function RunBenchmark(name, count, run, warn) { + for (var n = 0; n < count; ++n) { + result = run(); + if (!warn(result)) { + throw new Error("Earley or Boyer did incorrect number of rewrites"); + } + } +} + +var BgL_runzd2benchmarkzd2 = RunBenchmark; +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Automatically generated on 2009-01-30. Manually updated on 2010-09-17. + +// This benchmark is generated by loading 50 of the most popular pages +// on the web and logging all regexp operations performed. Each +// operation is given a weight that is calculated from an estimate of +// the popularity of the pages where it occurs and the number of times +// it is executed while loading each page. Furthermore the literal +// letters in the data are encoded using ROT13 in a way that does not +// affect how the regexps match their input. Finally the strings are +// scrambled to exercise the regexp engine on different input strings. + + +var RegExp = new BenchmarkSuite('RegExp', 910985, [ + new Benchmark("RegExp", RegExpRun, RegExpSetup, RegExpTearDown) +]); + +var regExpBenchmark = null; + +function RegExpSetup() { + regExpBenchmark = new RegExpBenchmark(); + RegExpRun(); // run once to get system initialized +} + +function RegExpRun() { + regExpBenchmark.run(); +} + +function RegExpTearDown() { + regExpBenchmark = null; +} + +// Returns an array of n different variants of the input string str. +// The variants are computed by randomly rotating one random +// character. +function computeInputVariants(str, n) { + var variants = [ str ]; + for (var i = 1; i < n; i++) { + var pos = Math.floor(Math.random() * str.length); + var chr = String.fromCharCode((str.charCodeAt(pos) + Math.floor(Math.random() * 128)) % 128); + variants[i] = str.substring(0, pos) + chr + str.substring(pos + 1, str.length); + } + return variants; +} + +function RegExpBenchmark() { + var re0 = /^ba/; + var re1 = /(((\w+):\/\/)([^\/:]*)(:(\d+))?)?([^#?]*)(\?([^#]*))?(#(.*))?/; + var re2 = /^\s*|\s*$/g; + var re3 = /\bQBZPbageby_cynprubyqre\b/; + var re4 = /,/; + var re5 = /\bQBZPbageby_cynprubyqre\b/g; + var re6 = /^[\s\xa0]+|[\s\xa0]+$/g; + var re7 = /(\d*)(\D*)/g; + var re8 = /=/; + var re9 = /(^|\s)lhv\-h(\s|$)/; + var str0 = 'Zbmvyyn/5.0 (Jvaqbjf; H; Jvaqbjf AG 5.1; ra-HF) NccyrJroXvg/528.9 (XUGZY, yvxr Trpxb) Puebzr/2.0.157.0 Fnsnev/528.9'; + var re10 = /\#/g; + var re11 = /\./g; + var re12 = /'/g; + var re13 = /\?[\w\W]*(sevraqvq|punaaryvq|tebhcvq)=([^\&\?#]*)/i; + var str1 = 'Fubpxjnir Synfu 9.0 e115'; + var re14 = /\s+/g; + var re15 = /^\s*(\S*(\s+\S+)*)\s*$/; + var re16 = /(-[a-z])/i; + + var s0 = computeInputVariants('pyvpx', 6511); + var s1 = computeInputVariants('uggc://jjj.snprobbx.pbz/ybtva.cuc', 1844); + var s2 = computeInputVariants('QBZPbageby_cynprubyqre', 739); + var s3 = computeInputVariants('uggc://jjj.snprobbx.pbz/', 598); + var s4 = computeInputVariants('uggc://jjj.snprobbx.pbz/fepu.cuc', 454); + var s5 = computeInputVariants('qqqq, ZZZ q, llll', 352); + var s6 = computeInputVariants('vachggrkg QBZPbageby_cynprubyqre', 312); + var s7 = computeInputVariants('/ZlFcnprUbzrcntr/Vaqrk-FvgrUbzr,10000000', 282); + var s8 = computeInputVariants('vachggrkg', 177); + var s9 = computeInputVariants('528.9', 170); + var s10 = computeInputVariants('528', 170); + var s11 = computeInputVariants('VCPhygher=ra-HF', 156); + var s12 = computeInputVariants('CersreerqPhygher=ra-HF', 156); + var s13 = computeInputVariants('xrlcerff', 144); + var s14 = computeInputVariants('521', 139); + var s15 = computeInputVariants(str0, 139); + var s16 = computeInputVariants('qvi .so_zrah', 137); + var s17 = computeInputVariants('qvi.so_zrah', 137); + var s18 = computeInputVariants('uvqqra_ryrz', 117); + var s19 = computeInputVariants('sevraqfgre_naba=nvq%3Qn6ss9p85n868ro9s059pn854735956o3%26ers%3Q%26df%3Q%26vpgl%3QHF', 95); + var s20 = computeInputVariants('uggc://ubzr.zlfcnpr.pbz/vaqrk.psz', 93); + var s21 = computeInputVariants(str1, 92); + var s22 = computeInputVariants('svefg', 85); + var s23 = computeInputVariants('uggc://cebsvyr.zlfcnpr.pbz/vaqrk.psz', 85); + var s24 = computeInputVariants('ynfg', 85); + var s25 = computeInputVariants('qvfcynl', 85); + + function runBlock0() { + for (var i = 0; i < 6511; i++) { + re0.exec(s0[i]); + } + for (var i = 0; i < 1844; i++) { + re1.exec(s1[i]); + } + for (var i = 0; i < 739; i++) { + s2[i].replace(re2, ''); + } + for (var i = 0; i < 598; i++) { + re1.exec(s3[i]); + } + for (var i = 0; i < 454; i++) { + re1.exec(s4[i]); + } + for (var i = 0; i < 352; i++) { + /qqqq|qqq|qq|q|ZZZZ|ZZZ|ZZ|Z|llll|ll|l|uu|u|UU|U|zz|z|ff|f|gg|g|sss|ss|s|mmm|mm|m/g.exec(s5[i]); + } + for (var i = 0; i < 312; i++) { + re3.exec(s6[i]); + } + for (var i = 0; i < 282; i++) { + re4.exec(s7[i]); + } + for (var i = 0; i < 177; i++) { + s8[i].replace(re5, ''); + } + for (var i = 0; i < 170; i++) { + s9[i].replace(re6, ''); + re7.exec(s10[i]); + } + for (var i = 0; i < 156; i++) { + re8.exec(s11[i]); + re8.exec(s12[i]); + } + for (var i = 0; i < 144; i++) { + re0.exec(s13[i]); + } + for (var i = 0; i < 139; i++) { + s14[i].replace(re6, ''); + re7.exec(s14[i]); + re9.exec(''); + /JroXvg\/(\S+)/.exec(s15[i]); + } + for (var i = 0; i < 137; i++) { + s16[i].replace(re10, ''); + s16[i].replace(/\[/g, ''); + s17[i].replace(re11, ''); + } + for (var i = 0; i < 117; i++) { + s18[i].replace(re2, ''); + } + for (var i = 0; i < 95; i++) { + /(?:^|;)\s*sevraqfgre_ynat=([^;]*)/.exec(s19[i]); + } + for (var i = 0; i < 93; i++) { + s20[i].replace(re12, ''); + re13.exec(s20[i]); + } + for (var i = 0; i < 92; i++) { + s21[i].replace(/([a-zA-Z]|\s)+/, ''); + } + for (var i = 0; i < 85; i++) { + s22[i].replace(re14, ''); + s22[i].replace(re15, ''); + s23[i].replace(re12, ''); + s24[i].replace(re14, ''); + s24[i].replace(re15, ''); + re16.exec(s25[i]); + re13.exec(s23[i]); + } + } + var re17 = /(^|[^\\])\"\\\/Qngr\((-?[0-9]+)\)\\\/\"/g; + var str2 = '{"anzr":"","ahzoreSbezng":{"PheeraplQrpvznyQvtvgf":2,"PheeraplQrpvznyFrcnengbe":".","VfErnqBayl":gehr,"PheeraplTebhcFvmrf":[3],"AhzoreTebhcFvmrf":[3],"CrepragTebhcFvmrf":[3],"PheeraplTebhcFrcnengbe":",","PheeraplFlzoby":"\xa4","AnAFlzoby":"AnA","PheeraplArtngvirCnggrea":0,"AhzoreArtngvirCnggrea":1,"CrepragCbfvgvirCnggrea":0,"CrepragArtngvirCnggrea":0,"ArtngvirVasvavglFlzoby":"-Vasvavgl","ArtngvirFvta":"-","AhzoreQrpvznyQvtvgf":2,"AhzoreQrpvznyFrcnengbe":".","AhzoreTebhcFrcnengbe":",","PheeraplCbfvgvirCnggrea":0,"CbfvgvirVasvavglFlzoby":"Vasvavgl","CbfvgvirFvta":"+","CrepragQrpvznyQvtvgf":2,"CrepragQrpvznyFrcnengbe":".","CrepragTebhcFrcnengbe":",","CrepragFlzoby":"%","CreZvyyrFlzoby":"\u2030","AngvirQvtvgf":["0","1","2","3","4","5","6","7","8","9"],"QvtvgFhofgvghgvba":1},"qngrGvzrSbezng":{"NZQrfvtangbe":"NZ","Pnyraqne":{"ZvaFhccbegrqQngrGvzr":"@-62135568000000@","ZnkFhccbegrqQngrGvzr":"@253402300799999@","NytbevguzGlcr":1,"PnyraqneGlcr":1,"Renf":[1],"GjbQvtvgLrneZnk":2029,"VfErnqBayl":gehr},"QngrFrcnengbe":"/","SvefgQnlBsJrrx":0,"PnyraqneJrrxEhyr":0,"ShyyQngrGvzrCnggrea":"qqqq, qq ZZZZ llll UU:zz:ff","YbatQngrCnggrea":"qqqq, qq ZZZZ llll","YbatGvzrCnggrea":"UU:zz:ff","ZbaguQnlCnggrea":"ZZZZ qq","CZQrfvtangbe":"CZ","ESP1123Cnggrea":"qqq, qq ZZZ llll UU\':\'zz\':\'ff \'TZG\'","FubegQngrCnggrea":"ZZ/qq/llll","FubegGvzrCnggrea":"UU:zz","FbegnoyrQngrGvzrCnggrea":"llll\'-\'ZZ\'-\'qq\'G\'UU\':\'zz\':\'ff","GvzrFrcnengbe":":","HavirefnyFbegnoyrQngrGvzrCnggrea":"llll\'-\'ZZ\'-\'qq UU\':\'zz\':\'ff\'M\'","LrneZbaguCnggrea":"llll ZZZZ","NooerivngrqQnlAnzrf":["Fha","Zba","Ghr","Jrq","Guh","Sev","Fng"],"FubegrfgQnlAnzrf":["Fh","Zb","Gh","Jr","Gu","Se","Fn"],"QnlAnzrf":["Fhaqnl","Zbaqnl","Ghrfqnl","Jrqarfqnl","Guhefqnl","Sevqnl","Fngheqnl"],"NooerivngrqZbaguAnzrf":["Wna","Sro","Zne","Nce","Znl","Wha","Why","Nht","Frc","Bpg","Abi","Qrp",""],"ZbaguAnzrf":["Wnahnel","Sroehnel","Znepu","Ncevy","Znl","Whar","Whyl","Nhthfg","Frcgrzore","Bpgbore","Abirzore","Qrprzore",""],"VfErnqBayl":gehr,"AngvirPnyraqneAnzr":"Tertbevna Pnyraqne","NooerivngrqZbaguTravgvirAnzrf":["Wna","Sro","Zne","Nce","Znl","Wha","Why","Nht","Frc","Bpg","Abi","Qrp",""],"ZbaguTravgvirAnzrf":["Wnahnel","Sroehnel","Znepu","Ncevy","Znl","Whar","Whyl","Nhthfg","Frcgrzore","Bpgbore","Abirzore","Qrprzore",""]}}'; + var str3 = '{"anzr":"ra-HF","ahzoreSbezng":{"PheeraplQrpvznyQvtvgf":2,"PheeraplQrpvznyFrcnengbe":".","VfErnqBayl":snyfr,"PheeraplTebhcFvmrf":[3],"AhzoreTebhcFvmrf":[3],"CrepragTebhcFvmrf":[3],"PheeraplTebhcFrcnengbe":",","PheeraplFlzoby":"$","AnAFlzoby":"AnA","PheeraplArtngvirCnggrea":0,"AhzoreArtngvirCnggrea":1,"CrepragCbfvgvirCnggrea":0,"CrepragArtngvirCnggrea":0,"ArtngvirVasvavglFlzoby":"-Vasvavgl","ArtngvirFvta":"-","AhzoreQrpvznyQvtvgf":2,"AhzoreQrpvznyFrcnengbe":".","AhzoreTebhcFrcnengbe":",","PheeraplCbfvgvirCnggrea":0,"CbfvgvirVasvavglFlzoby":"Vasvavgl","CbfvgvirFvta":"+","CrepragQrpvznyQvtvgf":2,"CrepragQrpvznyFrcnengbe":".","CrepragTebhcFrcnengbe":",","CrepragFlzoby":"%","CreZvyyrFlzoby":"\u2030","AngvirQvtvgf":["0","1","2","3","4","5","6","7","8","9"],"QvtvgFhofgvghgvba":1},"qngrGvzrSbezng":{"NZQrfvtangbe":"NZ","Pnyraqne":{"ZvaFhccbegrqQngrGvzr":"@-62135568000000@","ZnkFhccbegrqQngrGvzr":"@253402300799999@","NytbevguzGlcr":1,"PnyraqneGlcr":1,"Renf":[1],"GjbQvtvgLrneZnk":2029,"VfErnqBayl":snyfr},"QngrFrcnengbe":"/","SvefgQnlBsJrrx":0,"PnyraqneJrrxEhyr":0,"ShyyQngrGvzrCnggrea":"qqqq, ZZZZ qq, llll u:zz:ff gg","YbatQngrCnggrea":"qqqq, ZZZZ qq, llll","YbatGvzrCnggrea":"u:zz:ff gg","ZbaguQnlCnggrea":"ZZZZ qq","CZQrfvtangbe":"CZ","ESP1123Cnggrea":"qqq, qq ZZZ llll UU\':\'zz\':\'ff \'TZG\'","FubegQngrCnggrea":"Z/q/llll","FubegGvzrCnggrea":"u:zz gg","FbegnoyrQngrGvzrCnggrea":"llll\'-\'ZZ\'-\'qq\'G\'UU\':\'zz\':\'ff","GvzrFrcnengbe":":","HavirefnyFbegnoyrQngrGvzrCnggrea":"llll\'-\'ZZ\'-\'qq UU\':\'zz\':\'ff\'M\'","LrneZbaguCnggrea":"ZZZZ, llll","NooerivngrqQnlAnzrf":["Fha","Zba","Ghr","Jrq","Guh","Sev","Fng"],"FubegrfgQnlAnzrf":["Fh","Zb","Gh","Jr","Gu","Se","Fn"],"QnlAnzrf":["Fhaqnl","Zbaqnl","Ghrfqnl","Jrqarfqnl","Guhefqnl","Sevqnl","Fngheqnl"],"NooerivngrqZbaguAnzrf":["Wna","Sro","Zne","Nce","Znl","Wha","Why","Nht","Frc","Bpg","Abi","Qrp",""],"ZbaguAnzrf":["Wnahnel","Sroehnel","Znepu","Ncevy","Znl","Whar","Whyl","Nhthfg","Frcgrzore","Bpgbore","Abirzore","Qrprzore",""],"VfErnqBayl":snyfr,"AngvirPnyraqneAnzr":"Tertbevna Pnyraqne","NooerivngrqZbaguTravgvirAnzrf":["Wna","Sro","Zne","Nce","Znl","Wha","Why","Nht","Frc","Bpg","Abi","Qrp",""],"ZbaguTravgvirAnzrf":["Wnahnel","Sroehnel","Znepu","Ncevy","Znl","Whar","Whyl","Nhthfg","Frcgrzore","Bpgbore","Abirzore","Qrprzore",""]}}'; + var str4 = 'HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str5 = 'HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var re18 = /^\s+|\s+$/g; + var str6 = 'uggc://jjj.snprobbx.pbz/vaqrk.cuc'; + var re19 = /(?:^|\s+)ba(?:\s+|$)/; + var re20 = /[+, ]/; + var re21 = /ybnqrq|pbzcyrgr/; + var str7 = ';;jvaqbj.IjPurpxZbhfrCbfvgvbaNQ_VQ=shapgvba(r){vs(!r)ine r=jvaqbj.rirag;ine c=-1;vs(d1)c=d1.EbyybssCnary;ine bo=IjTrgBow("IjCnayNQ_VQ_"+c);vs(bo&&bo.fglyr.ivfvovyvgl=="ivfvoyr"){ine fns=IjFns?8:0;ine pheK=r.pyvragK+IjBOFpe("U")+fns,pheL=r.pyvragL+IjBOFpe("I")+fns;ine y=IjBOEC(NQ_VQ,bo,"Y"),g=IjBOEC(NQ_VQ,bo,"G");ine e=y+d1.Cnaryf[c].Jvqgu,o=g+d1.Cnaryf[c].Urvtug;vs((pheK<y)||(pheK>e)||(pheL<g)||(pheL>o)){vs(jvaqbj.IjBaEbyybssNQ_VQ)IjBaEbyybssNQ_VQ(c);ryfr IjPybfrNq(NQ_VQ,c,gehr,"");}ryfr erghea;}IjPnapryZbhfrYvfgrareNQ_VQ();};;jvaqbj.IjFrgEbyybssCnaryNQ_VQ=shapgvba(c){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;c=IjTc(NQ_VQ,c);vs(d1&&d1.EbyybssCnary>-1)IjPnapryZbhfrYvfgrareNQ_VQ();vs(d1)d1.EbyybssCnary=c;gel{vs(q.nqqRiragYvfgrare)q.nqqRiragYvfgrare(z,s,snyfr);ryfr vs(q.nggnpuRirag)q.nggnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjPnapryZbhfrYvfgrareNQ_VQ=shapgvba(){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;vs(d1)d1.EbyybssCnary=-1;gel{vs(q.erzbirRiragYvfgrare)q.erzbirRiragYvfgrare(z,s,snyfr);ryfr vs(q.qrgnpuRirag)q.qrgnpuRirag("ba"+z,s);}pngpu(r){}};;d1.IjTc=d2(n,c){ine nq=d1;vs(vfAnA(c)){sbe(ine v=0;v<nq.Cnaryf.yratgu;v++)vs(nq.Cnaryf[v].Anzr==c)erghea v;erghea 0;}erghea c;};;d1.IjTpy=d2(n,c,p){ine cn=d1.Cnaryf[IjTc(n,c)];vs(!cn)erghea 0;vs(vfAnA(p)){sbe(ine v=0;v<cn.Pyvpxguehf.yratgu;v++)vs(cn.Pyvpxguehf[v].Anzr==p)erghea v;erghea 0;}erghea p;};;d1.IjGenpr=d2(n,f){gel{vs(jvaqbj["Ij"+"QtQ"])jvaqbj["Ij"+"QtQ"](n,1,f);}pngpu(r){}};;d1.IjYvzvg1=d2(n,f){ine nq=d1,vh=f.fcyvg("/");sbe(ine v=0,p=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.FzV.yratgu>0)nq.FzV+="/";nq.FzV+=vh[v];nq.FtZ[nq.FtZ.yratgu]=snyfr;}}};;d1.IjYvzvg0=d2(n,f){ine nq=d1,vh=f.fcyvg("/");sbe(ine v=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.OvC.yratgu>0)nq.OvC+="/";nq.OvC+=vh[v];}}};;d1.IjRVST=d2(n,c){jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]=IjTrgBow("IjCnayNQ_VQ_"+c+"_Bow");vs(jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]==ahyy)frgGvzrbhg("IjRVST(NQ_VQ,"+c+")",d1.rvsg);};;d1.IjNavzSHC=d2(n,c){ine nq=d1;vs(c>nq.Cnaryf.yratgu)erghea;ine cna=nq.Cnaryf[c],nn=gehr,on=gehr,yn=gehr,en=gehr,cn=nq.Cnaryf[0],sf=nq.ShF,j=cn.Jvqgu,u=cn.Urvtug;vs(j=="100%"){j=sf;en=snyfr;yn=snyfr;}vs(u=="100%"){u=sf;nn=snyfr;on=snyfr;}vs(cn.YnY=="Y")yn=snyfr;vs(cn.YnY=="E")en=snyfr;vs(cn.GnY=="G")nn=snyfr;vs(cn.GnY=="O")on=snyfr;ine k=0,l=0;fjvgpu(nq.NshP%8){pnfr 0:oernx;pnfr 1:vs(nn)l=-sf;oernx;pnfr 2:k=j-sf;oernx;pnfr 3:vs(en)k=j;oernx;pnfr 4:k=j-sf;l=u-sf;oernx;pnfr 5:k=j-sf;vs(on)l=u;oernx;pnfr 6:l=u-sf;oernx;pnfr 7:vs(yn)k=-sf;l=u-sf;oernx;}vs(nq.NshP++ <nq.NshG)frgGvzrbhg(("IjNavzSHC(NQ_VQ,"+c+")"),nq.NshC);ryfr{k=-1000;l=k;}cna.YrsgBssfrg=k;cna.GbcBssfrg=l;IjNhErcb(n,c);};;d1.IjTrgErnyCbfvgvba=d2(n,b,j){erghea IjBOEC.nccyl(guvf,nethzragf);};;d1.IjPnapryGvzrbhg=d2(n,c){c=IjTc(n,c);ine cay=d1.Cnaryf[c];vs(cay&&cay.UgU!=""){pyrneGvzrbhg(cay.UgU);}};;d1.IjPnapryNyyGvzrbhgf=d2(n){vs(d1.YbpxGvzrbhgPunatrf)erghea;sbe(ine c=0;c<d1.bac;c++)IjPnapryGvzrbhg(n,c);};;d1.IjFgnegGvzrbhg=d2(n,c,bG){c=IjTc(n,c);ine cay=d1.Cnaryf[c];vs(cay&&((cay.UvqrGvzrbhgInyhr>0)||(nethzragf.yratgu==3&&bG>0))){pyrneGvzrbhg(cay.UgU);cay.UgU=frgGvzrbhg(cay.UvqrNpgvba,(nethzragf.yratgu==3?bG:cay.UvqrGvzrbhgInyhr));}};;d1.IjErfrgGvzrbhg=d2(n,c,bG){c=IjTc(n,c);IjPnapryGvzrbhg(n,c);riny("IjFgnegGvzrbhg(NQ_VQ,c"+(nethzragf.yratgu==3?",bG":"")+")");};;d1.IjErfrgNyyGvzrbhgf=d2(n){sbe(ine c=0;c<d1.bac;c++)IjErfrgGvzrbhg(n,c);};;d1.IjQrgnpure=d2(n,rig,sap){gel{vs(IjQVR5)riny("jvaqbj.qrgnpuRirag(\'ba"+rig+"\',"+sap+"NQ_VQ)");ryfr vs(!IjQVRZnp)riny("jvaqbj.erzbirRiragYvfgrare(\'"+rig+"\',"+sap+"NQ_VQ,snyfr)");}pngpu(r){}};;d1.IjPyrnaHc=d2(n){IjCvat(n,"G");ine nq=d1;sbe(ine v=0;v<nq.Cnaryf.yratgu;v++){IjUvqrCnary(n,v,gehr);}gel{IjTrgBow(nq.gya).vaareUGZY="";}pngpu(r){}vs(nq.gya!=nq.gya2)gel{IjTrgBow(nq.gya2).vaareUGZY="";}pngpu(r){}gel{d1=ahyy;}pngpu(r){}gel{IjQrgnpure(n,"haybnq","IjHayNQ_VQ");}pngpu(r){}gel{jvaqbj.IjHayNQ_VQ=ahyy;}pngpu(r){}gel{IjQrgnpure(n,"fpebyy","IjFeNQ_VQ");}pngpu(r){}gel{jvaqbj.IjFeNQ_VQ=ahyy;}pngpu(r){}gel{IjQrgnpure(n,"erfvmr","IjEmNQ_VQ");}pngpu(r){}gel{jvaqbj.IjEmNQ_VQ=ahyy;}pngpu(r){}gel{IjQrgnpure(n'; + var str8 = ';;jvaqbj.IjPurpxZbhfrCbfvgvbaNQ_VQ=shapgvba(r){vs(!r)ine r=jvaqbj.rirag;ine c=-1;vs(jvaqbj.IjNqNQ_VQ)c=jvaqbj.IjNqNQ_VQ.EbyybssCnary;ine bo=IjTrgBow("IjCnayNQ_VQ_"+c);vs(bo&&bo.fglyr.ivfvovyvgl=="ivfvoyr"){ine fns=IjFns?8:0;ine pheK=r.pyvragK+IjBOFpe("U")+fns,pheL=r.pyvragL+IjBOFpe("I")+fns;ine y=IjBOEC(NQ_VQ,bo,"Y"),g=IjBOEC(NQ_VQ,bo,"G");ine e=y+jvaqbj.IjNqNQ_VQ.Cnaryf[c].Jvqgu,o=g+jvaqbj.IjNqNQ_VQ.Cnaryf[c].Urvtug;vs((pheK<y)||(pheK>e)||(pheL<g)||(pheL>o)){vs(jvaqbj.IjBaEbyybssNQ_VQ)IjBaEbyybssNQ_VQ(c);ryfr IjPybfrNq(NQ_VQ,c,gehr,"");}ryfr erghea;}IjPnapryZbhfrYvfgrareNQ_VQ();};;jvaqbj.IjFrgEbyybssCnaryNQ_VQ=shapgvba(c){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;c=IjTc(NQ_VQ,c);vs(jvaqbj.IjNqNQ_VQ&&jvaqbj.IjNqNQ_VQ.EbyybssCnary>-1)IjPnapryZbhfrYvfgrareNQ_VQ();vs(jvaqbj.IjNqNQ_VQ)jvaqbj.IjNqNQ_VQ.EbyybssCnary=c;gel{vs(q.nqqRiragYvfgrare)q.nqqRiragYvfgrare(z,s,snyfr);ryfr vs(q.nggnpuRirag)q.nggnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjPnapryZbhfrYvfgrareNQ_VQ=shapgvba(){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;vs(jvaqbj.IjNqNQ_VQ)jvaqbj.IjNqNQ_VQ.EbyybssCnary=-1;gel{vs(q.erzbirRiragYvfgrare)q.erzbirRiragYvfgrare(z,s,snyfr);ryfr vs(q.qrgnpuRirag)q.qrgnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjNqNQ_VQ.IjTc=shapgvba(n,c){ine nq=jvaqbj.IjNqNQ_VQ;vs(vfAnA(c)){sbe(ine v=0;v<nq.Cnaryf.yratgu;v++)vs(nq.Cnaryf[v].Anzr==c)erghea v;erghea 0;}erghea c;};;jvaqbj.IjNqNQ_VQ.IjTpy=shapgvba(n,c,p){ine cn=jvaqbj.IjNqNQ_VQ.Cnaryf[IjTc(n,c)];vs(!cn)erghea 0;vs(vfAnA(p)){sbe(ine v=0;v<cn.Pyvpxguehf.yratgu;v++)vs(cn.Pyvpxguehf[v].Anzr==p)erghea v;erghea 0;}erghea p;};;jvaqbj.IjNqNQ_VQ.IjGenpr=shapgvba(n,f){gel{vs(jvaqbj["Ij"+"QtQ"])jvaqbj["Ij"+"QtQ"](n,1,f);}pngpu(r){}};;jvaqbj.IjNqNQ_VQ.IjYvzvg1=shapgvba(n,f){ine nq=jvaqbj.IjNqNQ_VQ,vh=f.fcyvg("/");sbe(ine v=0,p=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.FzV.yratgu>0)nq.FzV+="/";nq.FzV+=vh[v];nq.FtZ[nq.FtZ.yratgu]=snyfr;}}};;jvaqbj.IjNqNQ_VQ.IjYvzvg0=shapgvba(n,f){ine nq=jvaqbj.IjNqNQ_VQ,vh=f.fcyvg("/");sbe(ine v=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.OvC.yratgu>0)nq.OvC+="/";nq.OvC+=vh[v];}}};;jvaqbj.IjNqNQ_VQ.IjRVST=shapgvba(n,c){jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]=IjTrgBow("IjCnayNQ_VQ_"+c+"_Bow");vs(jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]==ahyy)frgGvzrbhg("IjRVST(NQ_VQ,"+c+")",jvaqbj.IjNqNQ_VQ.rvsg);};;jvaqbj.IjNqNQ_VQ.IjNavzSHC=shapgvba(n,c){ine nq=jvaqbj.IjNqNQ_VQ;vs(c>nq.Cnaryf.yratgu)erghea;ine cna=nq.Cnaryf[c],nn=gehr,on=gehr,yn=gehr,en=gehr,cn=nq.Cnaryf[0],sf=nq.ShF,j=cn.Jvqgu,u=cn.Urvtug;vs(j=="100%"){j=sf;en=snyfr;yn=snyfr;}vs(u=="100%"){u=sf;nn=snyfr;on=snyfr;}vs(cn.YnY=="Y")yn=snyfr;vs(cn.YnY=="E")en=snyfr;vs(cn.GnY=="G")nn=snyfr;vs(cn.GnY=="O")on=snyfr;ine k=0,l=0;fjvgpu(nq.NshP%8){pnfr 0:oernx;pnfr 1:vs(nn)l=-sf;oernx;pnfr 2:k=j-sf;oernx;pnfr 3:vs(en)k=j;oernx;pnfr 4:k=j-sf;l=u-sf;oernx;pnfr 5:k=j-sf;vs(on)l=u;oernx;pnfr 6:l=u-sf;oernx;pnfr 7:vs(yn)k=-sf;l=u-sf;oernx;}vs(nq.NshP++ <nq.NshG)frgGvzrbhg(("IjNavzSHC(NQ_VQ,"+c+")"),nq.NshC);ryfr{k=-1000;l=k;}cna.YrsgBssfrg=k;cna.GbcBssfrg=l;IjNhErcb(n,c);};;jvaqbj.IjNqNQ_VQ.IjTrgErnyCbfvgvba=shapgvba(n,b,j){erghea IjBOEC.nccyl(guvf,nethzragf);};;jvaqbj.IjNqNQ_VQ.IjPnapryGvzrbhg=shapgvba(n,c){c=IjTc(n,c);ine cay=jvaqbj.IjNqNQ_VQ.Cnaryf[c];vs(cay&&cay.UgU!=""){pyrneGvzrbhg(cay.UgU);}};;jvaqbj.IjNqNQ_VQ.IjPnapryNyyGvzrbhgf=shapgvba(n){vs(jvaqbj.IjNqNQ_VQ.YbpxGvzrbhgPunatrf)erghea;sbe(ine c=0;c<jvaqbj.IjNqNQ_VQ.bac;c++)IjPnapryGvzrbhg(n,c);};;jvaqbj.IjNqNQ_VQ.IjFgnegGvzrbhg=shapgvba(n,c,bG){c=IjTc(n,c);ine cay=jvaqbj.IjNqNQ_VQ.Cnaryf[c];vs(cay&&((cay.UvqrGvzrbhgInyhr>0)||(nethzragf.yratgu==3&&bG>0))){pyrneGvzrbhg(cay.UgU);cay.UgU=frgGvzrbhg(cay.UvqrNpgvba,(nethzragf.yratgu==3?bG:cay.UvqrGvzrbhgInyhr));}};;jvaqbj.IjNqNQ_VQ.IjErfrgGvzrbhg=shapgvba(n,c,bG){c=IjTc(n,c);IjPnapryGvzrbhg(n,c);riny("IjFgnegGvzrbhg(NQ_VQ,c"+(nethzragf.yratgu==3?",bG":"")+")");};;jvaqbj.IjNqNQ_VQ.IjErfrgNyyGvzrbhgf=shapgvba(n){sbe(ine c=0;c<jvaqbj.IjNqNQ_VQ.bac;c++)IjErfrgGvzrbhg(n,c);};;jvaqbj.IjNqNQ_VQ.IjQrgnpure=shapgvba(n,rig,sap){gel{vs(IjQVR5)riny("jvaqbj.qrgnpuRirag(\'ba"+rig+"\',"+sap+"NQ_VQ)");ryfr vs(!IjQVRZnp)riny("jvaqbj.erzbir'; + var str9 = ';;jvaqbj.IjPurpxZbhfrCbfvgvbaNQ_VQ=shapgvba(r){vs(!r)ine r=jvaqbj.rirag;ine c=-1;vs(jvaqbj.IjNqNQ_VQ)c=jvaqbj.IjNqNQ_VQ.EbyybssCnary;ine bo=IjTrgBow("IjCnayNQ_VQ_"+c);vs(bo&&bo.fglyr.ivfvovyvgl=="ivfvoyr"){ine fns=IjFns?8:0;ine pheK=r.pyvragK+IjBOFpe("U")+fns,pheL=r.pyvragL+IjBOFpe("I")+fns;ine y=IjBOEC(NQ_VQ,bo,"Y"),g=IjBOEC(NQ_VQ,bo,"G");ine e=y+jvaqbj.IjNqNQ_VQ.Cnaryf[c].Jvqgu,o=g+jvaqbj.IjNqNQ_VQ.Cnaryf[c].Urvtug;vs((pheK<y)||(pheK>e)||(pheL<g)||(pheL>o)){vs(jvaqbj.IjBaEbyybssNQ_VQ)IjBaEbyybssNQ_VQ(c);ryfr IjPybfrNq(NQ_VQ,c,gehr,"");}ryfr erghea;}IjPnapryZbhfrYvfgrareNQ_VQ();};;jvaqbj.IjFrgEbyybssCnaryNQ_VQ=shapgvba(c){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;c=IjTc(NQ_VQ,c);vs(jvaqbj.IjNqNQ_VQ&&jvaqbj.IjNqNQ_VQ.EbyybssCnary>-1)IjPnapryZbhfrYvfgrareNQ_VQ();vs(jvaqbj.IjNqNQ_VQ)jvaqbj.IjNqNQ_VQ.EbyybssCnary=c;gel{vs(q.nqqRiragYvfgrare)q.nqqRiragYvfgrare(z,s,snyfr);ryfr vs(q.nggnpuRirag)q.nggnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjPnapryZbhfrYvfgrareNQ_VQ=shapgvba(){ine z="zbhfrzbir",q=qbphzrag,s=IjPurpxZbhfrCbfvgvbaNQ_VQ;vs(jvaqbj.IjNqNQ_VQ)jvaqbj.IjNqNQ_VQ.EbyybssCnary=-1;gel{vs(q.erzbirRiragYvfgrare)q.erzbirRiragYvfgrare(z,s,snyfr);ryfr vs(q.qrgnpuRirag)q.qrgnpuRirag("ba"+z,s);}pngpu(r){}};;jvaqbj.IjNqNQ_VQ.IjTc=d2(n,c){ine nq=jvaqbj.IjNqNQ_VQ;vs(vfAnA(c)){sbe(ine v=0;v<nq.Cnaryf.yratgu;v++)vs(nq.Cnaryf[v].Anzr==c)erghea v;erghea 0;}erghea c;};;jvaqbj.IjNqNQ_VQ.IjTpy=d2(n,c,p){ine cn=jvaqbj.IjNqNQ_VQ.Cnaryf[IjTc(n,c)];vs(!cn)erghea 0;vs(vfAnA(p)){sbe(ine v=0;v<cn.Pyvpxguehf.yratgu;v++)vs(cn.Pyvpxguehf[v].Anzr==p)erghea v;erghea 0;}erghea p;};;jvaqbj.IjNqNQ_VQ.IjGenpr=d2(n,f){gel{vs(jvaqbj["Ij"+"QtQ"])jvaqbj["Ij"+"QtQ"](n,1,f);}pngpu(r){}};;jvaqbj.IjNqNQ_VQ.IjYvzvg1=d2(n,f){ine nq=jvaqbj.IjNqNQ_VQ,vh=f.fcyvg("/");sbe(ine v=0,p=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.FzV.yratgu>0)nq.FzV+="/";nq.FzV+=vh[v];nq.FtZ[nq.FtZ.yratgu]=snyfr;}}};;jvaqbj.IjNqNQ_VQ.IjYvzvg0=d2(n,f){ine nq=jvaqbj.IjNqNQ_VQ,vh=f.fcyvg("/");sbe(ine v=0;v<vh.yratgu;v++){vs(vh[v].yratgu>0){vs(nq.OvC.yratgu>0)nq.OvC+="/";nq.OvC+=vh[v];}}};;jvaqbj.IjNqNQ_VQ.IjRVST=d2(n,c){jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]=IjTrgBow("IjCnayNQ_VQ_"+c+"_Bow");vs(jvaqbj["IjCnayNQ_VQ_"+c+"_Bow"]==ahyy)frgGvzrbhg("IjRVST(NQ_VQ,"+c+")",jvaqbj.IjNqNQ_VQ.rvsg);};;jvaqbj.IjNqNQ_VQ.IjNavzSHC=d2(n,c){ine nq=jvaqbj.IjNqNQ_VQ;vs(c>nq.Cnaryf.yratgu)erghea;ine cna=nq.Cnaryf[c],nn=gehr,on=gehr,yn=gehr,en=gehr,cn=nq.Cnaryf[0],sf=nq.ShF,j=cn.Jvqgu,u=cn.Urvtug;vs(j=="100%"){j=sf;en=snyfr;yn=snyfr;}vs(u=="100%"){u=sf;nn=snyfr;on=snyfr;}vs(cn.YnY=="Y")yn=snyfr;vs(cn.YnY=="E")en=snyfr;vs(cn.GnY=="G")nn=snyfr;vs(cn.GnY=="O")on=snyfr;ine k=0,l=0;fjvgpu(nq.NshP%8){pnfr 0:oernx;pnfr 1:vs(nn)l=-sf;oernx;pnfr 2:k=j-sf;oernx;pnfr 3:vs(en)k=j;oernx;pnfr 4:k=j-sf;l=u-sf;oernx;pnfr 5:k=j-sf;vs(on)l=u;oernx;pnfr 6:l=u-sf;oernx;pnfr 7:vs(yn)k=-sf;l=u-sf;oernx;}vs(nq.NshP++ <nq.NshG)frgGvzrbhg(("IjNavzSHC(NQ_VQ,"+c+")"),nq.NshC);ryfr{k=-1000;l=k;}cna.YrsgBssfrg=k;cna.GbcBssfrg=l;IjNhErcb(n,c);};;jvaqbj.IjNqNQ_VQ.IjTrgErnyCbfvgvba=d2(n,b,j){erghea IjBOEC.nccyl(guvf,nethzragf);};;jvaqbj.IjNqNQ_VQ.IjPnapryGvzrbhg=d2(n,c){c=IjTc(n,c);ine cay=jvaqbj.IjNqNQ_VQ.Cnaryf[c];vs(cay&&cay.UgU!=""){pyrneGvzrbhg(cay.UgU);}};;jvaqbj.IjNqNQ_VQ.IjPnapryNyyGvzrbhgf=d2(n){vs(jvaqbj.IjNqNQ_VQ.YbpxGvzrbhgPunatrf)erghea;sbe(ine c=0;c<jvaqbj.IjNqNQ_VQ.bac;c++)IjPnapryGvzrbhg(n,c);};;jvaqbj.IjNqNQ_VQ.IjFgnegGvzrbhg=d2(n,c,bG){c=IjTc(n,c);ine cay=jvaqbj.IjNqNQ_VQ.Cnaryf[c];vs(cay&&((cay.UvqrGvzrbhgInyhr>0)||(nethzragf.yratgu==3&&bG>0))){pyrneGvzrbhg(cay.UgU);cay.UgU=frgGvzrbhg(cay.UvqrNpgvba,(nethzragf.yratgu==3?bG:cay.UvqrGvzrbhgInyhr));}};;jvaqbj.IjNqNQ_VQ.IjErfrgGvzrbhg=d2(n,c,bG){c=IjTc(n,c);IjPnapryGvzrbhg(n,c);riny("IjFgnegGvzrbhg(NQ_VQ,c"+(nethzragf.yratgu==3?",bG":"")+")");};;jvaqbj.IjNqNQ_VQ.IjErfrgNyyGvzrbhgf=d2(n){sbe(ine c=0;c<jvaqbj.IjNqNQ_VQ.bac;c++)IjErfrgGvzrbhg(n,c);};;jvaqbj.IjNqNQ_VQ.IjQrgnpure=d2(n,rig,sap){gel{vs(IjQVR5)riny("jvaqbj.qrgnpuRirag(\'ba"+rig+"\',"+sap+"NQ_VQ)");ryfr vs(!IjQVRZnp)riny("jvaqbj.erzbirRiragYvfgrare(\'"+rig+"\',"+sap+"NQ_VQ,snyfr)");}pngpu(r){}};;jvaqbj.IjNqNQ_VQ.IjPyrna'; + + var s26 = computeInputVariants('VC=74.125.75.1', 81); + var s27 = computeInputVariants('9.0 e115', 78); + var s28 = computeInputVariants('k',78); + var s29 = computeInputVariants(str2, 81); + var s30 = computeInputVariants(str3, 81); + var s31 = computeInputVariants('144631658', 78); + var s32 = computeInputVariants('Pbhagel=IIZ%3Q', 78); + var s33 = computeInputVariants('Pbhagel=IIZ=', 78); + var s34 = computeInputVariants('CersreerqPhygherCraqvat=', 78); + var s35 = computeInputVariants(str4, 78); + var s36 = computeInputVariants(str5, 78); + var s37 = computeInputVariants('__hgzp=144631658', 78); + var s38 = computeInputVariants('gvzrMbar=-8', 78); + var s39 = computeInputVariants('gvzrMbar=0', 78); + // var s40 = computeInputVariants(s15[i], 78); + var s41 = computeInputVariants('vachggrkg QBZPbageby_cynprubyqre', 78); + var s42 = computeInputVariants('xrlqbja', 78); + var s43 = computeInputVariants('xrlhc', 78); + var s44 = computeInputVariants('uggc://zrffntvat.zlfcnpr.pbz/vaqrk.psz', 77); + var s45 = computeInputVariants('FrffvbaFgbentr=%7O%22GnoThvq%22%3N%7O%22thvq%22%3N1231367125017%7Q%7Q', 73); + var s46 = computeInputVariants(str6, 72); + var s47 = computeInputVariants('3.5.0.0', 70); + var s48 = computeInputVariants(str7, 70); + var s49 = computeInputVariants(str8, 70); + var s50 = computeInputVariants(str9, 70); + var s51 = computeInputVariants('NI%3Q1_CI%3Q1_PI%3Q1_EI%3Q1_HI%3Q1_HP%3Q1_IC%3Q0.0.0.0_IH%3Q0', 70); + var s52 = computeInputVariants('svz_zlfcnpr_ubzrcntr_abgybttrqva,svz_zlfcnpr_aba_HTP,svz_zlfcnpr_havgrq-fgngrf', 70); + var s53 = computeInputVariants('ybnqvat', 70); + var s54 = computeInputVariants('#', 68); + var s55 = computeInputVariants('ybnqrq', 68); + var s56 = computeInputVariants('pbybe', 49); + var s57 = computeInputVariants('uggc://sevraqf.zlfcnpr.pbz/vaqrk.psz', 44); + + function runBlock1() { + for (var i = 0; i < 81; i++) { + re8.exec(s26[i]); + } + for (var i = 0; i < 78; i++) { + s27[i].replace(/(\s)+e/, ''); + s28[i].replace(/./, ''); + s29[i].replace(re17, ''); + s30[i].replace(re17, ''); + re8.exec(s31[i]); + re8.exec(s32[i]); + re8.exec(s33[i]); + re8.exec(s34[i]); + re8.exec(s35[i]); + re8.exec(s36[i]); + re8.exec(s37[i]); + re8.exec(s38[i]); + re8.exec(s39[i]); + /Fnsnev\/(\d+\.\d+)/.exec(s15[i]); + re3.exec(s41[i]); + re0.exec(s42[i]); + re0.exec(s43[i]); + } + for (var i = 0; i < 77; i++) { + s44[i].replace(re12, ''); + re13.exec(s44[i]); + } + for (var i = 0; i < 73; i++) { + s45[i].replace(re18, ''); + } + for (var i = 0; i < 72; i++) { + re1.exec(s46[i]); + } + for (var i = 0; i < 71; i++) { + re19.exec(''); + } + for (var i = 0; i < 70; i++) { + s47[i].replace(re11, ''); + s48[i].replace(/d1/g, ''); + s49[i].replace(/NQ_VQ/g, ''); + s50[i].replace(/d2/g, ''); + s51[i].replace(/_/g, ''); + s52[i].split(re20); + re21.exec(s53[i]); + } + for (var i = 0; i < 68; i++) { + re1.exec(s54[i]); + /(?:ZFVR.(\d+\.\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\d+\.\d+))|(?:Bcren.(\d+\.\d+))|(?:NccyrJroXvg.(\d+(?:\.\d+)?))/.exec(s15[i]); + /(Znp BF K)|(Jvaqbjf;)/.exec(s15[i]); + /Trpxb\/([0-9]+)/.exec(s15[i]); + re21.exec(s55[i]); + } + for (var i = 0; i < 49; i++) { + re16.exec(s56[i]); + } + for (var i = 0; i < 44; i++) { + s57[i].replace(re12, ''); + re13.exec(s57[i]); + } + } + var re22 = /\bso_zrah\b/; + var re23 = /^(?:(?:[^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/; + var re24 = /uggcf?:\/\/([^\/]+\.)?snprobbx\.pbz\//; + var re25 = /"/g; + var re26 = /^([^?#]+)(?:\?([^#]*))?(#.*)?/; + var s57a = computeInputVariants('fryrpgrq', 40); + var s58 = computeInputVariants('vachggrkg uvqqra_ryrz', 40); + var s59 = computeInputVariants('vachggrkg ', 40); + var s60 = computeInputVariants('vachggrkg', 40); + var s61 = computeInputVariants('uggc://jjj.snprobbx.pbz/', 40); + var s62 = computeInputVariants('uggc://jjj.snprobbx.pbz/ybtva.cuc', 40); + var s63 = computeInputVariants('Funer guvf tnqtrg', 40); + var s64 = computeInputVariants('uggc://jjj.tbbtyr.pbz/vt/qverpgbel', 40); + var s65 = computeInputVariants('419', 40); + var s66 = computeInputVariants('gvzrfgnzc', 40); + + function runBlock2() { + for (var i = 0; i < 40; i++) { + s57a[i].replace(re14, ''); + s57a[i].replace(re15, ''); + } + for (var i = 0; i < 39; i++) { + s58[i].replace(/\buvqqra_ryrz\b/g, ''); + re3.exec(s59[i]); + re3.exec(s60[i]); + re22.exec('HVYvaxOhggba'); + re22.exec('HVYvaxOhggba_E'); + re22.exec('HVYvaxOhggba_EJ'); + re22.exec('zrah_ybtva_pbagnvare'); + /\buvqqra_ryrz\b/.exec('vachgcnffjbeq'); + } + for (var i = 0; i < 37; i++) { + re8.exec('111soqs57qo8o8480qo18sor2011r3n591q7s6s37r120904'); + re8.exec('SbeprqRkcvengvba=633669315660164980'); + re8.exec('FrffvbaQQS2=111soqs57qo8o8480qo18sor2011r3n591q7s6s37r120904'); + } + for (var i = 0; i < 35; i++) { + 'puvyq p1 svefg'.replace(re14, ''); + 'puvyq p1 svefg'.replace(re15, ''); + 'sylbhg pybfrq'.replace(re14, ''); + 'sylbhg pybfrq'.replace(re15, ''); + } + for (var i = 0; i < 34; i++) { + re19.exec('gno2'); + re19.exec('gno3'); + re8.exec('44132r503660'); + re8.exec('SbeprqRkcvengvba=633669316860113296'); + re8.exec('AFP_zp_dfctwzs-aowb_80=44132r503660'); + re8.exec('FrffvbaQQS2=s6r4579npn4rn2135s904r0s75pp1o5334p6s6pospo12696'); + re8.exec('s6r4579npn4rn2135s904r0s75pp1o5334p6s6pospo12696'); + } + for (var i = 0; i < 32; i++) { + /puebzr/i.exec(s15[i]); + } + for (var i = 0; i < 31; i++) { + s61[i].replace(re23, ''); + re8.exec('SbeprqRkcvengvba=633669358527244818'); + re8.exec('VC=66.249.85.130'); + re8.exec('FrffvbaQQS2=s15q53p9n372sn76npr13o271n4s3p5r29p235746p908p58'); + re8.exec('s15q53p9n372sn76npr13o271n4s3p5r29p235746p908p58'); + re24.exec(s61[i]); + } + for (var i = 0; i < 30; i++) { + s65[i].replace(re6, ''); + /(?:^|\s+)gvzrfgnzc(?:\s+|$)/.exec(s66[i]); + re7.exec(s65[i]); + } + for (var i = 0; i < 29; i++) { + s62[i].replace(re23, ''); + } + for (var i = 0; i < 28; i++) { + s63[i].replace(re25, ''); + s63[i].replace(re12, ''); + re26.exec(s64[i]); + } + } + var re27 = /-\D/g; + var re28 = /\bnpgvingr\b/; + var re29 = /%2R/gi; + var re30 = /%2S/gi; + var re31 = /^(mu-(PA|GJ)|wn|xb)$/; + var re32 = /\s?;\s?/; + var re33 = /%\w?$/; + var re34 = /TNQP=([^;]*)/i; + var str10 = 'FrffvbaQQS2=111soqs57qo8o8480qo18sor2011r3n591q7s6s37r120904; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669315660164980&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str11 = 'FrffvbaQQS2=111soqs57qo8o8480qo18sor2011r3n591q7s6s37r120904; __hgzm=144631658.1231363570.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.3426875219718084000.1231363570.1231363570.1231363570.1; __hgzo=144631658.0.10.1231363570; __hgzp=144631658; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669315660164980&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str12 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231363514065&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231363514065&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Subzr.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1326469221.1231363557&tn_fvq=1231363557&tn_uvq=1114636509&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str13 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669315660164980&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str14 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669315660164980&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var re35 = /[<>]/g; + var str15 = 'FrffvbaQQS2=s6r4579npn4rn2135s904r0s75pp1o5334p6s6pospo12696; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669316860113296&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R=; AFP_zp_dfctwzs-aowb_80=44132r503660'; + var str16 = 'FrffvbaQQS2=s6r4579npn4rn2135s904r0s75pp1o5334p6s6pospo12696; AFP_zp_dfctwzs-aowb_80=44132r503660; __hgzm=144631658.1231363638.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.965867047679498800.1231363638.1231363638.1231363638.1; __hgzo=144631658.0.10.1231363638; __hgzp=144631658; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669316860113296&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str17 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231363621014&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231363621014&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Scebsvyr.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=348699119.1231363624&tn_fvq=1231363624&tn_uvq=895511034&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str18 = 'uggc://jjj.yrobapbva.se/yv'; + var str19 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669316860113296&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str20 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669316860113296&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + + var s67 = computeInputVariants('e115', 27); + var s68 = computeInputVariants('qvfcynl', 27); + var s69 = computeInputVariants('cbfvgvba', 27); + var s70 = computeInputVariants('uggc://jjj.zlfcnpr.pbz/', 27); + var s71 = computeInputVariants('cntrivrj', 27); + var s72 = computeInputVariants('VC=74.125.75.3', 27); + var s73 = computeInputVariants('ra', 27); + var s74 = computeInputVariants(str10, 27); + var s75 = computeInputVariants(str11, 27); + var s76 = computeInputVariants(str12, 27); + var s77 = computeInputVariants(str17, 27); + var s78 = computeInputVariants(str18, 27); + + function runBlock3() { + for (var i = 0; i < 27; i++) { + s67[i].replace(/[A-Za-z]/g, ''); + } + for (var i = 0; i < 23; i++) { + s68[i].replace(re27, ''); + s69[i].replace(re27, ''); + } + for (var i = 0; i < 22; i++) { + 'unaqyr'.replace(re14, ''); + 'unaqyr'.replace(re15, ''); + 'yvar'.replace(re14, ''); + 'yvar'.replace(re15, ''); + 'cnerag puebzr6 fvatyr1 gno'.replace(re14, ''); + 'cnerag puebzr6 fvatyr1 gno'.replace(re15, ''); + 'fyvqre'.replace(re14, ''); + 'fyvqre'.replace(re15, ''); + re28.exec(''); + } + for (var i = 0; i < 21; i++) { + s70[i].replace(re12, ''); + re13.exec(s70[i]); + } + for (var i = 0; i < 20; i++) { + s71[i].replace(re29, ''); + s71[i].replace(re30, ''); + re19.exec('ynfg'); + re19.exec('ba svefg'); + re8.exec(s72[i]); + } + for (var i = 0; i < 19; i++) { + re31.exec(s73[i]); + } + for (var i = 0; i < 18; i++) { + s74[i].split(re32); + s75[i].split(re32); + s76[i].replace(re33, ''); + re8.exec('144631658.0.10.1231363570'); + re8.exec('144631658.1231363570.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.3426875219718084000.1231363570.1231363570.1231363570.1'); + re8.exec(str13); + re8.exec(str14); + re8.exec('__hgzn=144631658.3426875219718084000.1231363570.1231363570.1231363570.1'); + re8.exec('__hgzo=144631658.0.10.1231363570'); + re8.exec('__hgzm=144631658.1231363570.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(s74[i]); + re34.exec(s75[i]); + } + for (var i = 0; i < 17; i++) { + s15[i].match(/zfvr/gi); + s15[i].match(/bcren/gi); + str15.split(re32); + str16.split(re32); + 'ohggba'.replace(re14, ''); + 'ohggba'.replace(re15, ''); + 'puvyq p1 svefg sylbhg pybfrq'.replace(re14, ''); + 'puvyq p1 svefg sylbhg pybfrq'.replace(re15, ''); + 'pvgvrf'.replace(re14, ''); + 'pvgvrf'.replace(re15, ''); + 'pybfrq'.replace(re14, ''); + 'pybfrq'.replace(re15, ''); + 'qry'.replace(re14, ''); + 'qry'.replace(re15, ''); + 'uqy_zba'.replace(re14, ''); + 'uqy_zba'.replace(re15, ''); + s77[i].replace(re33, ''); + s78[i].replace(/%3P/g, ''); + s78[i].replace(/%3R/g, ''); + s78[i].replace(/%3q/g, ''); + s78[i].replace(re35, ''); + 'yvaxyvfg16'.replace(re14, ''); + 'yvaxyvfg16'.replace(re15, ''); + 'zvahf'.replace(re14, ''); + 'zvahf'.replace(re15, ''); + 'bcra'.replace(re14, ''); + 'bcra'.replace(re15, ''); + 'cnerag puebzr5 fvatyr1 ps NU'.replace(re14, ''); + 'cnerag puebzr5 fvatyr1 ps NU'.replace(re15, ''); + 'cynlre'.replace(re14, ''); + 'cynlre'.replace(re15, ''); + 'cyhf'.replace(re14, ''); + 'cyhf'.replace(re15, ''); + 'cb_uqy'.replace(re14, ''); + 'cb_uqy'.replace(re15, ''); + 'hyJVzt'.replace(re14, ''); + 'hyJVzt'.replace(re15, ''); + re8.exec('144631658.0.10.1231363638'); + re8.exec('144631658.1231363638.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.965867047679498800.1231363638.1231363638.1231363638.1'); + re8.exec('4413268q3660'); + re8.exec('4ss747o77904333q374or84qrr1s9r0nprp8r5q81534o94n'); + re8.exec('SbeprqRkcvengvba=633669321699093060'); + re8.exec('VC=74.125.75.20'); + re8.exec(str19); + re8.exec(str20); + re8.exec('AFP_zp_tfwsbrg-aowb_80=4413268q3660'); + re8.exec('FrffvbaQQS2=4ss747o77904333q374or84qrr1s9r0nprp8r5q81534o94n'); + re8.exec('__hgzn=144631658.965867047679498800.1231363638.1231363638.1231363638.1'); + re8.exec('__hgzo=144631658.0.10.1231363638'); + re8.exec('__hgzm=144631658.1231363638.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(str15); + re34.exec(str16); + } + } + var re36 = /uers|fep|fryrpgrq/; + var re37 = /\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g; + var re38 = /^(\w+|\*)$/; + var str21 = 'FrffvbaQQS2=s15q53p9n372sn76npr13o271n4s3p5r29p235746p908p58; ZFPhygher=VC=66.249.85.130&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669358527244818&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str22 = 'FrffvbaQQS2=s15q53p9n372sn76npr13o271n4s3p5r29p235746p908p58; __hgzm=144631658.1231367822.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.4127520630321984500.1231367822.1231367822.1231367822.1; __hgzo=144631658.0.10.1231367822; __hgzp=144631658; ZFPhygher=VC=66.249.85.130&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669358527244818&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str23 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231367803797&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231367803797&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Szrffntvat.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1192552091.1231367807&tn_fvq=1231367807&tn_uvq=1155446857&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str24 = 'ZFPhygher=VC=66.249.85.130&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669358527244818&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str25 = 'ZFPhygher=VC=66.249.85.130&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669358527244818&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str26 = 'hy.ynat-fryrpgbe'; + var re39 = /\\/g; + var re40 = / /g; + var re41 = /\/\xc4\/t/; + var re42 = /\/\xd6\/t/; + var re43 = /\/\xdc\/t/; + var re44 = /\/\xdf\/t/; + var re45 = /\/\xe4\/t/; + var re46 = /\/\xf6\/t/; + var re47 = /\/\xfc\/t/; + var re48 = /\W/g; + var re49 = /uers|fep|fglyr/; + var s79 = computeInputVariants(str21, 16); + var s80 = computeInputVariants(str22, 16); + var s81 = computeInputVariants(str23, 16); + var s82 = computeInputVariants(str26, 16); + + function runBlock4() { + for (var i = 0; i < 16; i++) { + ''.replace(/\*/g, ''); + /\bnpgvir\b/.exec('npgvir'); + /sversbk/i.exec(s15[i]); + re36.exec('glcr'); + /zfvr/i.exec(s15[i]); + /bcren/i.exec(s15[i]); + } + for (var i = 0; i < 15; i++) { + s79[i].split(re32); + s80[i].split(re32); + 'uggc://ohyyrgvaf.zlfcnpr.pbz/vaqrk.psz'.replace(re12, ''); + s81[i].replace(re33, ''); + 'yv'.replace(re37, ''); + 'yv'.replace(re18, ''); + re8.exec('144631658.0.10.1231367822'); + re8.exec('144631658.1231367822.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.4127520630321984500.1231367822.1231367822.1231367822.1'); + re8.exec(str24); + re8.exec(str25); + re8.exec('__hgzn=144631658.4127520630321984500.1231367822.1231367822.1231367822.1'); + re8.exec('__hgzo=144631658.0.10.1231367822'); + re8.exec('__hgzm=144631658.1231367822.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(s79[i]); + re34.exec(s80[i]); + /\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g.exec(s82[i]); + re13.exec('uggc://ohyyrgvaf.zlfcnpr.pbz/vaqrk.psz'); + re38.exec('yv'); + } + for (var i = 0; i < 14; i++) { + ''.replace(re18, ''); + '9.0 e115'.replace(/(\s+e|\s+o[0-9]+)/, ''); + 'Funer guvf tnqtrg'.replace(/</g, ''); + 'Funer guvf tnqtrg'.replace(/>/g, ''); + 'Funer guvf tnqtrg'.replace(re39, ''); + 'uggc://cebsvyrrqvg.zlfcnpr.pbz/vaqrk.psz'.replace(re12, ''); + 'grnfre'.replace(re40, ''); + 'grnfre'.replace(re41, ''); + 'grnfre'.replace(re42, ''); + 'grnfre'.replace(re43, ''); + 'grnfre'.replace(re44, ''); + 'grnfre'.replace(re45, ''); + 'grnfre'.replace(re46, ''); + 'grnfre'.replace(re47, ''); + 'grnfre'.replace(re48, ''); + re16.exec('znetva-gbc'); + re16.exec('cbfvgvba'); + re19.exec('gno1'); + re9.exec('qz'); + re9.exec('qg'); + re9.exec('zbqobk'); + re9.exec('zbqobkva'); + re9.exec('zbqgvgyr'); + re13.exec('uggc://cebsvyrrqvg.zlfcnpr.pbz/vaqrk.psz'); + re26.exec('/vt/znvytnqtrg'); + re49.exec('glcr'); + } + } + var re50 = /(?:^|\s+)fryrpgrq(?:\s+|$)/; + var re51 = /\&/g; + var re52 = /\+/g; + var re53 = /\?/g; + var re54 = /\t/g; + var re55 = /(\$\{nqiHey\})|(\$nqiHey\b)/g; + var re56 = /(\$\{cngu\})|(\$cngu\b)/g; + function runBlock5() { + for (var i = 0; i < 13; i++) { + 'purpx'.replace(re14, ''); + 'purpx'.replace(re15, ''); + 'pvgl'.replace(re14, ''); + 'pvgl'.replace(re15, ''); + 'qrpe fyvqrgrkg'.replace(re14, ''); + 'qrpe fyvqrgrkg'.replace(re15, ''); + 'svefg fryrpgrq'.replace(re14, ''); + 'svefg fryrpgrq'.replace(re15, ''); + 'uqy_rag'.replace(re14, ''); + 'uqy_rag'.replace(re15, ''); + 'vape fyvqrgrkg'.replace(re14, ''); + 'vape fyvqrgrkg'.replace(re15, ''); + 'vachggrkg QBZPbageby_cynprubyqre'.replace(re5, ''); + 'cnerag puebzr6 fvatyr1 gno fryrpgrq'.replace(re14, ''); + 'cnerag puebzr6 fvatyr1 gno fryrpgrq'.replace(re15, ''); + 'cb_guz'.replace(re14, ''); + 'cb_guz'.replace(re15, ''); + 'fhozvg'.replace(re14, ''); + 'fhozvg'.replace(re15, ''); + re50.exec(''); + /NccyrJroXvg\/([^\s]*)/.exec(s15[i]); + /XUGZY/.exec(s15[i]); + } + for (var i = 0; i < 12; i++) { + '${cebg}://${ubfg}${cngu}/${dz}'.replace(/(\$\{cebg\})|(\$cebg\b)/g, ''); + '1'.replace(re40, ''); + '1'.replace(re10, ''); + '1'.replace(re51, ''); + '1'.replace(re52, ''); + '1'.replace(re53, ''); + '1'.replace(re39, ''); + '1'.replace(re54, ''); + '9.0 e115'.replace(/^(.*)\..*$/, ''); + '9.0 e115'.replace(/^.*e(.*)$/, ''); + '<!-- ${nqiHey} -->'.replace(re55, ''); + '<fpevcg glcr="grkg/wninfpevcg" fep="${nqiHey}"></fpevcg>'.replace(re55, ''); + s21[i].replace(/^.*\s+(\S+\s+\S+$)/, ''); + 'tzk%2Subzrcntr%2Sfgneg%2Sqr%2S'.replace(re30, ''); + 'tzk'.replace(re30, ''); + 'uggc://${ubfg}${cngu}/${dz}'.replace(/(\$\{ubfg\})|(\$ubfg\b)/g, ''); + 'uggc://nqpyvrag.hvzfrei.arg${cngu}/${dz}'.replace(re56, ''); + 'uggc://nqpyvrag.hvzfrei.arg/wf.at/${dz}'.replace(/(\$\{dz\})|(\$dz\b)/g, ''); + 'frpgvba'.replace(re29, ''); + 'frpgvba'.replace(re30, ''); + 'fvgr'.replace(re29, ''); + 'fvgr'.replace(re30, ''); + 'fcrpvny'.replace(re29, ''); + 'fcrpvny'.replace(re30, ''); + re36.exec('anzr'); + /e/.exec('9.0 e115'); + } + } + var re57 = /##yv4##/gi; + var re58 = /##yv16##/gi; + var re59 = /##yv19##/gi; + var str27 = '<hy pynff="nqi">##yv4##Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.##yv19##Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.##yv16##Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.##OE## ##OE## ##N##Yrnea zber##/N##</hy>'; + var str28 = '<hy pynff="nqi"><yv vq="YvOYG4" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg4.cat)">Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.##yv19##Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.##yv16##Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.##OE## ##OE## ##N##Yrnea zber##/N##</hy>'; + var str29 = '<hy pynff="nqi"><yv vq="YvOYG4" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg4.cat)">Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.##yv19##Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.<yv vq="YvOYG16" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg16.cat)">Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.##OE## ##OE## ##N##Yrnea zber##/N##</hy>'; + var str30 = '<hy pynff="nqi"><yv vq="YvOYG4" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg4.cat)">Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.<yv vq="YvOYG19" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg19.cat)">Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.<yv vq="YvOYG16" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg16.cat)">Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.##OE## ##OE## ##N##Yrnea zber##/N##</hy>'; + var str31 = '<hy pynff="nqi"><yv vq="YvOYG4" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg4.cat)">Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.<yv vq="YvOYG19" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg19.cat)">Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.<yv vq="YvOYG16" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg16.cat)">Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.<oe> <oe> ##N##Yrnea zber##/N##</hy>'; + var str32 = '<hy pynff="nqi"><yv vq="YvOYG4" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg4.cat)">Cbjreshy Zvpebfbsg grpuabybtl urycf svtug fcnz naq vzcebir frphevgl.<yv vq="YvOYG19" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg19.cat)">Trg zber qbar gunaxf gb terngre rnfr naq fcrrq.<yv vq="YvOYG16" fglyr="onpxtebhaq-vzntr:hey(uggc://vzt.jykef.pbz/~Yvir.FvgrPbagrag.VQ/~14.2.1230/~/~/~/oyg16.cat)">Ybgf bs fgbentr (5 TO) - zber pbby fghss ba gur jnl.<oe> <oe> <n uers="uggc://znvy.yvir.pbz/znvy/nobhg.nfck" gnetrg="_oynax">Yrnea zber##/N##</hy>'; + var str33 = 'Bar Jvaqbjf Yvir VQ trgf lbh vagb <o>Ubgznvy</o>, <o>Zrffratre</o>, <o>Kobk YVIR</o> \u2014 naq bgure cynprf lbh frr #~#argjbexybtb#~#'; + var re60 = /(?:^|\s+)bss(?:\s+|$)/; + var re61 = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/; + var re62 = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; + var str34 = '${1}://${2}${3}${4}${5}'; + var str35 = ' O=6gnyg0g4znrrn&o=3&f=gc; Q=_lyu=K3bQZGSxnT4lZzD3OS9GNmV3ZGLkAQxRpTyxNmRlZmRmAmNkAQLRqTImqNZjOUEgpTjQnJ5xMKtgoN--; SCF=qy'; + var s83 = computeInputVariants(str27, 11); + var s84 = computeInputVariants(str28, 11); + var s85 = computeInputVariants(str29, 11); + var s86 = computeInputVariants(str30, 11); + var s87 = computeInputVariants(str31, 11); + var s88 = computeInputVariants(str32, 11); + var s89 = computeInputVariants(str33, 11); + var s90 = computeInputVariants(str34, 11); + + function runBlock6() { + for (var i = 0; i < 11; i++) { + s83[i].replace(/##yv0##/gi, ''); + s83[i].replace(re57, ''); + s84[i].replace(re58, ''); + s85[i].replace(re59, ''); + s86[i].replace(/##\/o##/gi, ''); + s86[i].replace(/##\/v##/gi, ''); + s86[i].replace(/##\/h##/gi, ''); + s86[i].replace(/##o##/gi, ''); + s86[i].replace(/##oe##/gi, ''); + s86[i].replace(/##v##/gi, ''); + s86[i].replace(/##h##/gi, ''); + s87[i].replace(/##n##/gi, ''); + s88[i].replace(/##\/n##/gi, ''); + s89[i].replace(/#~#argjbexybtb#~#/g, ''); + / Zbovyr\//.exec(s15[i]); + /##yv1##/gi.exec(s83[i]); + /##yv10##/gi.exec(s84[i]); + /##yv11##/gi.exec(s84[i]); + /##yv12##/gi.exec(s84[i]); + /##yv13##/gi.exec(s84[i]); + /##yv14##/gi.exec(s84[i]); + /##yv15##/gi.exec(s84[i]); + re58.exec(s84[i]); + /##yv17##/gi.exec(s85[i]); + /##yv18##/gi.exec(s85[i]); + re59.exec(s85[i]); + /##yv2##/gi.exec(s83[i]); + /##yv20##/gi.exec(s86[i]); + /##yv21##/gi.exec(s86[i]); + /##yv22##/gi.exec(s86[i]); + /##yv23##/gi.exec(s86[i]); + /##yv3##/gi.exec(s83[i]); + re57.exec(s83[i]); + /##yv5##/gi.exec(s84[i]); + /##yv6##/gi.exec(s84[i]); + /##yv7##/gi.exec(s84[i]); + /##yv8##/gi.exec(s84[i]); + /##yv9##/gi.exec(s84[i]); + re8.exec('473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29'); + re8.exec('SbeprqRkcvengvba=633669325184628362'); + re8.exec('FrffvbaQQS2=473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29'); + /AbxvnA[^\/]*/.exec(s15[i]); + } + for (var i = 0; i < 10; i++) { + ' bss'.replace(/(?:^|\s+)bss(?:\s+|$)/g, ''); + s90[i].replace(/(\$\{0\})|(\$0\b)/g, ''); + s90[i].replace(/(\$\{1\})|(\$1\b)/g, ''); + s90[i].replace(/(\$\{pbzcyrgr\})|(\$pbzcyrgr\b)/g, ''); + s90[i].replace(/(\$\{sentzrag\})|(\$sentzrag\b)/g, ''); + s90[i].replace(/(\$\{ubfgcbeg\})|(\$ubfgcbeg\b)/g, ''); + s90[i].replace(re56, ''); + s90[i].replace(/(\$\{cebgbpby\})|(\$cebgbpby\b)/g, ''); + s90[i].replace(/(\$\{dhrel\})|(\$dhrel\b)/g, ''); + 'nqfvmr'.replace(re29, ''); + 'nqfvmr'.replace(re30, ''); + 'uggc://${2}${3}${4}${5}'.replace(/(\$\{2\})|(\$2\b)/g, ''); + 'uggc://wf.hv-cbegny.qr${3}${4}${5}'.replace(/(\$\{3\})|(\$3\b)/g, ''); + 'arjf'.replace(re40, ''); + 'arjf'.replace(re41, ''); + 'arjf'.replace(re42, ''); + 'arjf'.replace(re43, ''); + 'arjf'.replace(re44, ''); + 'arjf'.replace(re45, ''); + 'arjf'.replace(re46, ''); + 'arjf'.replace(re47, ''); + 'arjf'.replace(re48, ''); + / PC=i=(\d+)&oe=(.)/.exec(str35); + re60.exec(' '); + re60.exec(' bss'); + re60.exec(''); + re19.exec(' '); + re19.exec('svefg ba'); + re19.exec('ynfg vtaber'); + re19.exec('ba'); + re9.exec('scnq so '); + re9.exec('zrqvgobk'); + re9.exec('hsgy'); + re9.exec('lhv-h'); + /Fnsnev|Xbadhrebe|XUGZY/gi.exec(s15[i]); + re61.exec('uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/onfr.wf'); + re62.exec('#Ybtva_rznvy'); + } + } + var re63 = /\{0\}/g; + var str36 = 'FrffvbaQQS2=4ss747o77904333q374or84qrr1s9r0nprp8r5q81534o94n; ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669321699093060&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R=; AFP_zp_tfwsbrg-aowb_80=4413268q3660'; + var str37 = 'FrffvbaQQS2=4ss747o77904333q374or84qrr1s9r0nprp8r5q81534o94n; AFP_zp_tfwsbrg-aowb_80=4413268q3660; __hgzm=144631658.1231364074.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.2294274870215848400.1231364074.1231364074.1231364074.1; __hgzo=144631658.0.10.1231364074; __hgzp=144631658; ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669321699093060&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str38 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231364057761&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231364057761&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Ssevraqf.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1667363813.1231364061&tn_fvq=1231364061&tn_uvq=1917563877&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str39 = 'ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669321699093060&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str40 = 'ZFPhygher=VC=74.125.75.20&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669321699093060&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var s91 = computeInputVariants(str36, 9); + var s92 = computeInputVariants(str37, 9); + var s93 = computeInputVariants(str38, 9); + function runBlock7() { + for (var i = 0; i < 9; i++) { + '0'.replace(re40, ''); + '0'.replace(re10, ''); + '0'.replace(re51, ''); + '0'.replace(re52, ''); + '0'.replace(re53, ''); + '0'.replace(re39, ''); + '0'.replace(re54, ''); + 'Lrf'.replace(re40, ''); + 'Lrf'.replace(re10, ''); + 'Lrf'.replace(re51, ''); + 'Lrf'.replace(re52, ''); + 'Lrf'.replace(re53, ''); + 'Lrf'.replace(re39, ''); + 'Lrf'.replace(re54, ''); + } + for (var i = 0; i < 8; i++) { + 'Pybfr {0}'.replace(re63, ''); + 'Bcra {0}'.replace(re63, ''); + s91[i].split(re32); + s92[i].split(re32); + 'puvyq p1 svefg gnournqref'.replace(re14, ''); + 'puvyq p1 svefg gnournqref'.replace(re15, ''); + 'uqy_fcb'.replace(re14, ''); + 'uqy_fcb'.replace(re15, ''); + 'uvag'.replace(re14, ''); + 'uvag'.replace(re15, ''); + s93[i].replace(re33, ''); + 'yvfg'.replace(re14, ''); + 'yvfg'.replace(re15, ''); + 'at_bhgre'.replace(re30, ''); + 'cnerag puebzr5 qbhoyr2 NU'.replace(re14, ''); + 'cnerag puebzr5 qbhoyr2 NU'.replace(re15, ''); + 'cnerag puebzr5 dhnq5 ps NU osyvax zbarl'.replace(re14, ''); + 'cnerag puebzr5 dhnq5 ps NU osyvax zbarl'.replace(re15, ''); + 'cnerag puebzr6 fvatyr1'.replace(re14, ''); + 'cnerag puebzr6 fvatyr1'.replace(re15, ''); + 'cb_qrs'.replace(re14, ''); + 'cb_qrs'.replace(re15, ''); + 'gnopbagrag'.replace(re14, ''); + 'gnopbagrag'.replace(re15, ''); + 'iv_svefg_gvzr'.replace(re30, ''); + /(^|.)(ronl|qri-ehf3.wbg)(|fgberf|zbgbef|yvirnhpgvbaf|jvxv|rkcerff|punggre).(pbz(|.nh|.pa|.ux|.zl|.ft|.oe|.zk)|pb(.hx|.xe|.am)|pn|qr|se|vg|ay|or|ng|pu|vr|va|rf|cy|cu|fr)$/i.exec('cntrf.ronl.pbz'); + re8.exec('144631658.0.10.1231364074'); + re8.exec('144631658.1231364074.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.2294274870215848400.1231364074.1231364074.1231364074.1'); + re8.exec('4413241q3660'); + re8.exec('SbeprqRkcvengvba=633669357391353591'); + re8.exec(str39); + re8.exec(str40); + re8.exec('AFP_zp_kkk-gdzogv_80=4413241q3660'); + re8.exec('FrffvbaQQS2=p98s8o9q42nr21or1r61pqorn1n002nsss569635984s6qp7'); + re8.exec('__hgzn=144631658.2294274870215848400.1231364074.1231364074.1231364074.1'); + re8.exec('__hgzo=144631658.0.10.1231364074'); + re8.exec('__hgzm=144631658.1231364074.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('p98s8o9q42nr21or1r61pqorn1n002nsss569635984s6qp7'); + re34.exec(s91[i]); + re34.exec(s92[i]); + } + } + var re64 = /\b[a-z]/g; + var re65 = /^uggc:\/\//; + var re66 = /(?:^|\s+)qvfnoyrq(?:\s+|$)/; + var str41 = 'uggc://cebsvyr.zlfcnpr.pbz/Zbqhyrf/Nccyvpngvbaf/Cntrf/Pnainf.nfck'; + function runBlock8() { + for (var i = 0; i < 7; i++) { + s21[i].match(/\d+/g); + 'nsgre'.replace(re64, ''); + 'orsber'.replace(re64, ''); + 'obggbz'.replace(re64, ''); + 'ohvygva_jrngure.kzy'.replace(re65, ''); + 'ohggba'.replace(re37, ''); + 'ohggba'.replace(re18, ''); + 'qngrgvzr.kzy'.replace(re65, ''); + 'uggc://eff.paa.pbz/eff/paa_gbcfgbevrf.eff'.replace(re65, ''); + 'vachg'.replace(re37, ''); + 'vachg'.replace(re18, ''); + 'vafvqr'.replace(re64, ''); + 'cbvagre'.replace(re27, ''); + 'cbfvgvba'.replace(/[A-Z]/g, ''); + 'gbc'.replace(re27, ''); + 'gbc'.replace(re64, ''); + 'hy'.replace(re37, ''); + 'hy'.replace(re18, ''); + str26.replace(re37, ''); + str26.replace(re18, ''); + 'lbhghor_vtbbtyr/i2/lbhghor.kzy'.replace(re65, ''); + 'm-vaqrk'.replace(re27, ''); + /#([\w-]+)/.exec(str26); + re16.exec('urvtug'); + re16.exec('znetvaGbc'); + re16.exec('jvqgu'); + re19.exec('gno0 svefg ba'); + re19.exec('gno0 ba'); + re19.exec('gno4 ynfg'); + re19.exec('gno4'); + re19.exec('gno5'); + re19.exec('gno6'); + re19.exec('gno7'); + re19.exec('gno8'); + /NqborNVE\/([^\s]*)/.exec(s15[i]); + /NccyrJroXvg\/([^ ]*)/.exec(s15[i]); + /XUGZY/gi.exec(s15[i]); + /^(?:obql|ugzy)$/i.exec('YV'); + re38.exec('ohggba'); + re38.exec('vachg'); + re38.exec('hy'); + re38.exec(str26); + /^(\w+|\*)/.exec(str26); + /znp|jva|yvahk/i.exec('Jva32'); + /eton?\([\d\s,]+\)/.exec('fgngvp'); + } + for (var i = 0; i < 6; i++) { + ''.replace(/\r/g, ''); + '/'.replace(re40, ''); + '/'.replace(re10, ''); + '/'.replace(re51, ''); + '/'.replace(re52, ''); + '/'.replace(re53, ''); + '/'.replace(re39, ''); + '/'.replace(re54, ''); + 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/{0}?[NDO]&{1}&{2}&[NDR]'.replace(re63, ''); + str41.replace(re12, ''); + 'uggc://jjj.snprobbx.pbz/fepu.cuc'.replace(re23, ''); + 'freivpr'.replace(re40, ''); + 'freivpr'.replace(re41, ''); + 'freivpr'.replace(re42, ''); + 'freivpr'.replace(re43, ''); + 'freivpr'.replace(re44, ''); + 'freivpr'.replace(re45, ''); + 'freivpr'.replace(re46, ''); + 'freivpr'.replace(re47, ''); + 'freivpr'.replace(re48, ''); + /((ZFVR\s+([6-9]|\d\d)\.))/.exec(s15[i]); + re66.exec(''); + re50.exec('fryrpgrq'); + re8.exec('8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn'); + re8.exec('SbeprqRkcvengvba=633669340386893867'); + re8.exec('VC=74.125.75.17'); + re8.exec('FrffvbaQQS2=8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn'); + /Xbadhrebe|Fnsnev|XUGZY/.exec(s15[i]); + re13.exec(str41); + re49.exec('unfsbphf'); + } + } + var re67 = /zrah_byq/g; + var str42 = 'FrffvbaQQS2=473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29; ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669325184628362&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str43 = 'FrffvbaQQS2=473qq1rs0n2r70q9qo1pq48n021s9468ron90nps048p4p29; __hgzm=144631658.1231364380.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.3931862196947939300.1231364380.1231364380.1231364380.1; __hgzo=144631658.0.10.1231364380; __hgzp=144631658; ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669325184628362&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str44 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_vzntrf_wf&qg=1231364373088&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231364373088&punaary=svz_zlfcnpr_hfre-ivrj-pbzzragf%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Spbzzrag.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1158737789.1231364375&tn_fvq=1231364375&tn_uvq=415520832&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str45 = 'ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669325184628362&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str46 = 'ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669325184628362&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var re68 = /^([#.]?)((?:[\w\u0128-\uffff*_-]|\\.)*)/; + var re69 = /\{1\}/g; + var re70 = /\s+/; + var re71 = /(\$\{4\})|(\$4\b)/g; + var re72 = /(\$\{5\})|(\$5\b)/g; + var re73 = /\{2\}/g; + var re74 = /[^+>] [^+>]/; + var re75 = /\bucpyv\s*=\s*([^;]*)/i; + var re76 = /\bucuvqr\s*=\s*([^;]*)/i; + var re77 = /\bucfie\s*=\s*([^;]*)/i; + var re78 = /\bhfucjrn\s*=\s*([^;]*)/i; + var re79 = /\bmvc\s*=\s*([^;]*)/i; + var re80 = /^((?:[\w\u0128-\uffff*_-]|\\.)+)(#)((?:[\w\u0128-\uffff*_-]|\\.)+)/; + var re81 = /^([>+~])\s*(\w*)/i; + var re82 = /^>\s*((?:[\w\u0128-\uffff*_-]|\\.)+)/; + var re83 = /^[\s[]?shapgvba/; + var re84 = /v\/g.tvs#(.*)/i; + var str47 = '#Zbq-Vasb-Vasb-WninFpevcgUvag'; + var str48 = ',n.svryqOgaPnapry'; + var str49 = 'FrffvbaQQS2=p98s8o9q42nr21or1r61pqorn1n002nsss569635984s6qp7; ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669357391353591&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R=; AFP_zp_kkk-gdzogv_80=4413241q3660'; + var str50 = 'FrffvbaQQS2=p98s8o9q42nr21or1r61pqorn1n002nsss569635984s6qp7; AFP_zp_kkk-gdzogv_80=4413241q3660; AFP_zp_kkk-aowb_80=4413235p3660; __hgzm=144631658.1231367708.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.2770915348920628700.1231367708.1231367708.1231367708.1; __hgzo=144631658.0.10.1231367708; __hgzp=144631658; ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669357391353591&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str51 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231367691141&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231367691141&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Sjjj.zlfcnpr.pbz%2S&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=320757904.1231367694&tn_fvq=1231367694&tn_uvq=1758792003&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str52 = 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/f55332979829981?[NDO]&aqu=1&g=7%2S0%2S2009%2014%3N38%3N42%203%20480&af=zfacbegny&cntrAnzr=HF%20UCZFSGJ&t=uggc%3N%2S%2Sjjj.zfa.pbz%2S&f=1024k768&p=24&x=L&oj=994&ou=634&uc=A&{2}&[NDR]'; + var str53 = 'cnerag puebzr6 fvatyr1 gno fryrpgrq ovaq qbhoyr2 ps'; + var str54 = 'ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669357391353591&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str55 = 'ZFPhygher=VC=74.125.75.3&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669357391353591&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str56 = 'ne;ng;nh;or;oe;pn;pu;py;pa;qr;qx;rf;sv;se;to;ux;vq;vr;va;vg;wc;xe;zk;zl;ay;ab;am;cu;cy;cg;eh;fr;ft;gu;ge;gj;mn;'; + var str57 = 'ZP1=I=3&THVQ=6nnpr9q661804s33nnop45nosqp17q85; zu=ZFSG; PHYGHER=RA-HF; SyvtugTebhcVq=97; SyvtugVq=OnfrCntr; ucfie=Z:5|S:5|G:5|R:5|Q:oyh|J:S; ucpyv=J.U|Y.|F.|E.|H.Y|P.|U.; hfucjrn=jp:HFPN0746; ZHVQ=Q783SN9O14054831N4869R51P0SO8886&GHVQ=1'; + var str58 = 'ZP1=I=3&THVQ=6nnpr9q661804s33nnop45nosqp17q85; zu=ZFSG; PHYGHER=RA-HF; SyvtugTebhcVq=97; SyvtugVq=OnfrCntr; ucfie=Z:5|S:5|G:5|R:5|Q:oyh|J:S; ucpyv=J.U|Y.|F.|E.|H.Y|P.|U.; hfucjrn=jp:HFPN0746; ZHVQ=Q783SN9O14054831N4869R51P0SO8886'; + var str59 = 'ZP1=I=3&THVQ=6nnpr9q661804s33nnop45nosqp17q85; zu=ZFSG; PHYGHER=RA-HF; SyvtugTebhcVq=97; SyvtugVq=OnfrCntr; ucfie=Z:5|S:5|G:5|R:5|Q:oyh|J:S; ucpyv=J.U|Y.|F.|E.|H.Y|P.|U.; hfucjrn=jp:HFPN0746; ZHVQ=Q783SN9O14054831N4869R51P0SO8886; mvc=m:94043|yn:37.4154|yb:-122.0585|p:HF|ue:1'; + var str60 = 'ZP1=I=3&THVQ=6nnpr9q661804s33nnop45nosqp17q85; zu=ZFSG; PHYGHER=RA-HF; SyvtugTebhcVq=97; SyvtugVq=OnfrCntr; ucfie=Z:5|S:5|G:5|R:5|Q:oyh|J:S; ucpyv=J.U|Y.|F.|E.|H.Y|P.|U.; hfucjrn=jp:HFPN0746; ZHVQ=Q783SN9O14054831N4869R51P0SO8886; mvc=m:94043|yn:37.4154|yb:-122.0585|p:HF'; + var str61 = 'uggc://gx2.fgp.f-zfa.pbz/oe/uc/11/ra-hf/pff/v/g.tvs#uggc://gx2.fgo.f-zfa.pbz/v/29/4RQP4969777N048NPS4RRR3PO2S7S.wct'; + var str62 = 'uggc://gx2.fgp.f-zfa.pbz/oe/uc/11/ra-hf/pff/v/g.tvs#uggc://gx2.fgo.f-zfa.pbz/v/OQ/63NP9O94NS5OQP1249Q9S1ROP7NS3.wct'; + var str63 = 'zbmvyyn/5.0 (jvaqbjf; h; jvaqbjf ag 5.1; ra-hf) nccyrjroxvg/528.9 (xugzy, yvxr trpxb) puebzr/2.0.157.0 fnsnev/528.9'; + var s94 = computeInputVariants(str42, 5); + var s95 = computeInputVariants(str43, 5); + var s96 = computeInputVariants(str44, 5); + var s97 = computeInputVariants(str47, 5); + var s98 = computeInputVariants(str48, 5); + var s99 = computeInputVariants(str49, 5); + var s100 = computeInputVariants(str50, 5); + var s101 = computeInputVariants(str51, 5); + var s102 = computeInputVariants(str52, 5); + var s103 = computeInputVariants(str53, 5); + + function runBlock9() { + for (var i = 0; i < 5; i++) { + s94[i].split(re32); + s95[i].split(re32); + 'svz_zlfcnpr_hfre-ivrj-pbzzragf,svz_zlfcnpr_havgrq-fgngrf'.split(re20); + s96[i].replace(re33, ''); + 'zrah_arj zrah_arj_gbttyr zrah_gbttyr'.replace(re67, ''); + 'zrah_byq zrah_byq_gbttyr zrah_gbttyr'.replace(re67, ''); + re8.exec('102n9o0o9pq60132qn0337rr867p75953502q2s27s2s5r98'); + re8.exec('144631658.0.10.1231364380'); + re8.exec('144631658.1231364380.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.3931862196947939300.1231364380.1231364380.1231364380.1'); + re8.exec('441326q33660'); + re8.exec('SbeprqRkcvengvba=633669341278771470'); + re8.exec(str45); + re8.exec(str46); + re8.exec('AFP_zp_dfctwzssrwh-aowb_80=441326q33660'); + re8.exec('FrffvbaQQS2=102n9o0o9pq60132qn0337rr867p75953502q2s27s2s5r98'); + re8.exec('__hgzn=144631658.3931862196947939300.1231364380.1231364380.1231364380.1'); + re8.exec('__hgzo=144631658.0.10.1231364380'); + re8.exec('__hgzm=144631658.1231364380.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + } + for (var i = 0; i < 4; i++) { + ' yvfg1'.replace(re14, ''); + ' yvfg1'.replace(re15, ''); + ' yvfg2'.replace(re14, ''); + ' yvfg2'.replace(re15, ''); + ' frneputebhc1'.replace(re14, ''); + ' frneputebhc1'.replace(re15, ''); + s97[i].replace(re68, ''); + s97[i].replace(re18, ''); + ''.replace(/&/g, ''); + ''.replace(re35, ''); + '(..-{0})(\|(\d+)|)'.replace(re63, ''); + s98[i].replace(re18, ''); + '//vzt.jro.qr/vij/FC/${cngu}/${anzr}/${inyhr}?gf=${abj}'.replace(re56, ''); + '//vzt.jro.qr/vij/FC/tzk_uc/${anzr}/${inyhr}?gf=${abj}'.replace(/(\$\{anzr\})|(\$anzr\b)/g, ''); + '<fcna pynff="urnq"><o>Jvaqbjf Yvir Ubgznvy</o></fcna><fcna pynff="zft">{1}</fcna>'.replace(re69, ''); + '<fcna pynff="urnq"><o>{0}</o></fcna><fcna pynff="zft">{1}</fcna>'.replace(re63, ''); + '<fcna pynff="fvtahc"><n uers=uggc://jjj.ubgznvy.pbz><o>{1}</o></n></fcna>'.replace(re69, ''); + '<fcna pynff="fvtahc"><n uers={0}><o>{1}</o></n></fcna>'.replace(re63, ''); + 'Vzntrf'.replace(re15, ''); + 'ZFA'.replace(re15, ''); + 'Zncf'.replace(re15, ''); + 'Zbq-Vasb-Vasb-WninFpevcgUvag'.replace(re39, ''); + 'Arjf'.replace(re15, ''); + s99[i].split(re32); + s100[i].split(re32); + 'Ivqrb'.replace(re15, ''); + 'Jro'.replace(re15, ''); + 'n'.replace(re39, ''); + 'nwnkFgneg'.split(re70); + 'nwnkFgbc'.split(re70); + 'ovaq'.replace(re14, ''); + 'ovaq'.replace(re15, ''); + 'oevatf lbh zber. Zber fcnpr (5TO), zber frphevgl, fgvyy serr.'.replace(re63, ''); + 'puvyq p1 svefg qrpx'.replace(re14, ''); + 'puvyq p1 svefg qrpx'.replace(re15, ''); + 'puvyq p1 svefg qbhoyr2'.replace(re14, ''); + 'puvyq p1 svefg qbhoyr2'.replace(re15, ''); + 'puvyq p2 ynfg'.replace(re14, ''); + 'puvyq p2 ynfg'.replace(re15, ''); + 'puvyq p2'.replace(re14, ''); + 'puvyq p2'.replace(re15, ''); + 'puvyq p3'.replace(re14, ''); + 'puvyq p3'.replace(re15, ''); + 'puvyq p4 ynfg'.replace(re14, ''); + 'puvyq p4 ynfg'.replace(re15, ''); + 'pbclevtug'.replace(re14, ''); + 'pbclevtug'.replace(re15, ''); + 'qZFAZR_1'.replace(re14, ''); + 'qZFAZR_1'.replace(re15, ''); + 'qbhoyr2 ps'.replace(re14, ''); + 'qbhoyr2 ps'.replace(re15, ''); + 'qbhoyr2'.replace(re14, ''); + 'qbhoyr2'.replace(re15, ''); + 'uqy_arj'.replace(re14, ''); + 'uqy_arj'.replace(re15, ''); + 'uc_fubccvatobk'.replace(re30, ''); + 'ugzy%2Rvq'.replace(re29, ''); + 'ugzy%2Rvq'.replace(re30, ''); + s101[i].replace(re33, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/cebgbglcr.wf${4}${5}'.replace(re71, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/cebgbglcr.wf${5}'.replace(re72, ''); + s102[i].replace(re73, ''); + 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/f55332979829981?[NDO]&{1}&{2}&[NDR]'.replace(re69, ''); + 'vztZFSG'.replace(re14, ''); + 'vztZFSG'.replace(re15, ''); + 'zfasbbg1 ps'.replace(re14, ''); + 'zfasbbg1 ps'.replace(re15, ''); + s103[i].replace(re14, ''); + s103[i].replace(re15, ''); + 'cnerag puebzr6 fvatyr1 gno fryrpgrq ovaq'.replace(re14, ''); + 'cnerag puebzr6 fvatyr1 gno fryrpgrq ovaq'.replace(re15, ''); + 'cevznel'.replace(re14, ''); + 'cevznel'.replace(re15, ''); + 'erpgnatyr'.replace(re30, ''); + 'frpbaqnel'.replace(re14, ''); + 'frpbaqnel'.replace(re15, ''); + 'haybnq'.split(re70); + '{0}{1}1'.replace(re63, ''); + '|{1}1'.replace(re69, ''); + /(..-HF)(\|(\d+)|)/i.exec('xb-xe,ra-va,gu-gu'); + re4.exec('/ZlFcnprNccf/NccPnainf,45000012'); + re8.exec('144631658.0.10.1231367708'); + re8.exec('144631658.1231367708.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.2770915348920628700.1231367708.1231367708.1231367708.1'); + re8.exec('4413235p3660'); + re8.exec('441327q73660'); + re8.exec('9995p6rp12rrnr893334ro7nq70o7p64p69rqn844prs1473'); + re8.exec('SbeprqRkcvengvba=633669350559478880'); + re8.exec(str54); + re8.exec(str55); + re8.exec('AFP_zp_dfctwzs-aowb_80=441327q73660'); + re8.exec('AFP_zp_kkk-aowb_80=4413235p3660'); + re8.exec('FrffvbaQQS2=9995p6rp12rrnr893334ro7nq70o7p64p69rqn844prs1473'); + re8.exec('__hgzn=144631658.2770915348920628700.1231367708.1231367708.1231367708.1'); + re8.exec('__hgzo=144631658.0.10.1231367708'); + re8.exec('__hgzm=144631658.1231367708.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(s99[i]); + re34.exec(s100[i]); + /ZFVR\s+5[.]01/.exec(s15[i]); + /HF(?=;)/i.exec(str56); + re74.exec(s97[i]); + re28.exec('svefg npgvir svefgNpgvir'); + re28.exec('ynfg'); + /\bp:(..)/i.exec('m:94043|yn:37.4154|yb:-122.0585|p:HF'); + re75.exec(str57); + re75.exec(str58); + re76.exec(str57); + re76.exec(str58); + re77.exec(str57); + re77.exec(str58); + /\bhfucce\s*=\s*([^;]*)/i.exec(str59); + re78.exec(str57); + re78.exec(str58); + /\bjci\s*=\s*([^;]*)/i.exec(str59); + re79.exec(str58); + re79.exec(str60); + re79.exec(str59); + /\|p:([a-z]{2})/i.exec('m:94043|yn:37.4154|yb:-122.0585|p:HF|ue:1'); + re80.exec(s97[i]); + re61.exec('cebgbglcr.wf'); + re68.exec(s97[i]); + re81.exec(s97[i]); + re82.exec(s97[i]); + /^Fubpxjnir Synfu (\d)/.exec(s21[i]); + /^Fubpxjnir Synfu (\d+)/.exec(s21[i]); + re83.exec('[bowrpg tybony]'); + re62.exec(s97[i]); + re84.exec(str61); + re84.exec(str62); + /jroxvg/.exec(str63); + } + } + var re85 = /eaq_zbqobkva/; + var str64 = '1231365729213'; + var str65 = '74.125.75.3-1057165600.29978900'; + var str66 = '74.125.75.3-1057165600.29978900.1231365730214'; + var str67 = 'Frnepu%20Zvpebfbsg.pbz'; + var str68 = 'FrffvbaQQS2=8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn; ZFPhygher=VC=74.125.75.17&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669340386893867&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str69 = 'FrffvbaQQS2=8sqq78r9n442851q565599o401385sp3s04r92rnn7o19ssn; __hgzm=144631658.1231365779.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.1877536177953918500.1231365779.1231365779.1231365779.1; __hgzo=144631658.0.10.1231365779; __hgzp=144631658; ZFPhygher=VC=74.125.75.17&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669340386893867&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str70 = 'I=3%26THVQ=757q3ss871q44o7o805n8113n5p72q52'; + var str71 = 'I=3&THVQ=757q3ss871q44o7o805n8113n5p72q52'; + var str72 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231365765292&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231365765292&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Sohyyrgvaf.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1579793869.1231365768&tn_fvq=1231365768&tn_uvq=2056210897&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str73 = 'frnepu.zvpebfbsg.pbz'; + var str74 = 'frnepu.zvpebfbsg.pbz/'; + var str75 = 'ZFPhygher=VC=74.125.75.17&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669340386893867&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str76 = 'ZFPhygher=VC=74.125.75.17&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669340386893867&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + function runBlock10() { + for (var i = 0; i < 3; i++) { + '%3Szxg=ra-HF'.replace(re39, ''); + '-8'.replace(re40, ''); + '-8'.replace(re10, ''); + '-8'.replace(re51, ''); + '-8'.replace(re52, ''); + '-8'.replace(re53, ''); + '-8'.replace(re39, ''); + '-8'.replace(re54, ''); + '1.5'.replace(re40, ''); + '1.5'.replace(re10, ''); + '1.5'.replace(re51, ''); + '1.5'.replace(re52, ''); + '1.5'.replace(re53, ''); + '1.5'.replace(re39, ''); + '1.5'.replace(re54, ''); + '1024k768'.replace(re40, ''); + '1024k768'.replace(re10, ''); + '1024k768'.replace(re51, ''); + '1024k768'.replace(re52, ''); + '1024k768'.replace(re53, ''); + '1024k768'.replace(re39, ''); + '1024k768'.replace(re54, ''); + str64.replace(re40, ''); + str64.replace(re10, ''); + str64.replace(re51, ''); + str64.replace(re52, ''); + str64.replace(re53, ''); + str64.replace(re39, ''); + str64.replace(re54, ''); + '14'.replace(re40, ''); + '14'.replace(re10, ''); + '14'.replace(re51, ''); + '14'.replace(re52, ''); + '14'.replace(re53, ''); + '14'.replace(re39, ''); + '14'.replace(re54, ''); + '24'.replace(re40, ''); + '24'.replace(re10, ''); + '24'.replace(re51, ''); + '24'.replace(re52, ''); + '24'.replace(re53, ''); + '24'.replace(re39, ''); + '24'.replace(re54, ''); + str65.replace(re40, ''); + str65.replace(re10, ''); + str65.replace(re51, ''); + str65.replace(re52, ''); + str65.replace(re53, ''); + str65.replace(re39, ''); + str65.replace(re54, ''); + str66.replace(re40, ''); + str66.replace(re10, ''); + str66.replace(re51, ''); + str66.replace(re52, ''); + str66.replace(re53, ''); + str66.replace(re39, ''); + str66.replace(re54, ''); + '9.0'.replace(re40, ''); + '9.0'.replace(re10, ''); + '9.0'.replace(re51, ''); + '9.0'.replace(re52, ''); + '9.0'.replace(re53, ''); + '9.0'.replace(re39, ''); + '9.0'.replace(re54, ''); + '994k634'.replace(re40, ''); + '994k634'.replace(re10, ''); + '994k634'.replace(re51, ''); + '994k634'.replace(re52, ''); + '994k634'.replace(re53, ''); + '994k634'.replace(re39, ''); + '994k634'.replace(re54, ''); + '?zxg=ra-HF'.replace(re40, ''); + '?zxg=ra-HF'.replace(re10, ''); + '?zxg=ra-HF'.replace(re51, ''); + '?zxg=ra-HF'.replace(re52, ''); + '?zxg=ra-HF'.replace(re53, ''); + '?zxg=ra-HF'.replace(re54, ''); + 'PAA.pbz'.replace(re25, ''); + 'PAA.pbz'.replace(re12, ''); + 'PAA.pbz'.replace(re39, ''); + 'Qngr & Gvzr'.replace(re25, ''); + 'Qngr & Gvzr'.replace(re12, ''); + 'Qngr & Gvzr'.replace(re39, ''); + 'Frnepu Zvpebfbsg.pbz'.replace(re40, ''); + 'Frnepu Zvpebfbsg.pbz'.replace(re54, ''); + str67.replace(re10, ''); + str67.replace(re51, ''); + str67.replace(re52, ''); + str67.replace(re53, ''); + str67.replace(re39, ''); + str68.split(re32); + str69.split(re32); + str70.replace(re52, ''); + str70.replace(re53, ''); + str70.replace(re39, ''); + str71.replace(re40, ''); + str71.replace(re10, ''); + str71.replace(re51, ''); + str71.replace(re54, ''); + 'Jrngure'.replace(re25, ''); + 'Jrngure'.replace(re12, ''); + 'Jrngure'.replace(re39, ''); + 'LbhGhor'.replace(re25, ''); + 'LbhGhor'.replace(re12, ''); + 'LbhGhor'.replace(re39, ''); + str72.replace(re33, ''); + 'erzbgr_vsenzr_1'.replace(/^erzbgr_vsenzr_/, ''); + str73.replace(re40, ''); + str73.replace(re10, ''); + str73.replace(re51, ''); + str73.replace(re52, ''); + str73.replace(re53, ''); + str73.replace(re39, ''); + str73.replace(re54, ''); + str74.replace(re40, ''); + str74.replace(re10, ''); + str74.replace(re51, ''); + str74.replace(re52, ''); + str74.replace(re53, ''); + str74.replace(re39, ''); + str74.replace(re54, ''); + 'lhv-h'.replace(/\-/g, ''); + re9.exec('p'); + re9.exec('qz p'); + re9.exec('zbqynory'); + re9.exec('lhv-h svefg'); + re8.exec('144631658.0.10.1231365779'); + re8.exec('144631658.1231365779.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.1877536177953918500.1231365779.1231365779.1231365779.1'); + re8.exec(str75); + re8.exec(str76); + re8.exec('__hgzn=144631658.1877536177953918500.1231365779.1231365779.1231365779.1'); + re8.exec('__hgzo=144631658.0.10.1231365779'); + re8.exec('__hgzm=144631658.1231365779.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(str68); + re34.exec(str69); + /^$/.exec(''); + re31.exec('qr'); + /^znk\d+$/.exec(''); + /^zva\d+$/.exec(''); + /^erfgber$/.exec(''); + re85.exec('zbqobkva zbqobk_abcnqqvat '); + re85.exec('zbqgvgyr'); + re85.exec('eaq_zbqobkva '); + re85.exec('eaq_zbqgvgyr '); + /frpgvba\d+_pbagragf/.exec('obggbz_ani'); + } + } + var re86 = /;\s*/; + var re87 = /(\$\{inyhr\})|(\$inyhr\b)/g; + var re88 = /(\$\{abj\})|(\$abj\b)/g; + var re89 = /\s+$/; + var re90 = /^\s+/; + var re91 = /(\\\"|\x00-|\x1f|\x7f-|\x9f|\u00ad|\u0600-|\u0604|\u070f|\u17b4|\u17b5|\u200c-|\u200f|\u2028-|\u202f|\u2060-|\u206f|\ufeff|\ufff0-|\uffff)/g; + var re92 = /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/; + var re93 = /^([:.#]*)((?:[\w\u0128-\uffff*_-]|\\.)+)/; + var re94 = /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/; + var str77 = '#fubhgobk .pybfr'; + var str78 = 'FrffvbaQQS2=102n9o0o9pq60132qn0337rr867p75953502q2s27s2s5r98; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669341278771470&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R=; AFP_zp_dfctwzssrwh-aowb_80=441326q33660'; + var str79 = 'FrffvbaQQS2=102n9o0o9pq60132qn0337rr867p75953502q2s27s2s5r98; AFP_zp_dfctwzssrwh-aowb_80=441326q33660; __hgzm=144631658.1231365869.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.1670816052019209000.1231365869.1231365869.1231365869.1; __hgzo=144631658.0.10.1231365869; __hgzp=144631658; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669341278771470&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str80 = 'FrffvbaQQS2=9995p6rp12rrnr893334ro7nq70o7p64p69rqn844prs1473; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669350559478880&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R=; AFP_zp_dfctwzs-aowb_80=441327q73660'; + var str81 = 'FrffvbaQQS2=9995p6rp12rrnr893334ro7nq70o7p64p69rqn844prs1473; AFP_zp_dfctwzs-aowb_80=441327q73660; __hgzm=144631658.1231367054.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar); __hgzn=144631658.1796080716621419500.1231367054.1231367054.1231367054.1; __hgzo=144631658.0.10.1231367054; __hgzp=144631658; ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669350559478880&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str82 = '[glcr=fhozvg]'; + var str83 = 'n.svryqOga,n.svryqOgaPnapry'; + var str84 = 'n.svryqOgaPnapry'; + var str85 = 'oyvpxchaxg'; + var str86 = 'qvi.bow-nppbeqvba qg'; + var str87 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_nccf_wf&qg=1231367052227&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231367052227&punaary=svz_zlfcnpr_nccf-pnainf%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Scebsvyr.zlfcnpr.pbz%2SZbqhyrf%2SNccyvpngvbaf%2SCntrf%2SPnainf.nfck&nq_glcr=grkg&rvq=6083027&rn=0&sez=1&tn_ivq=716357910.1231367056&tn_fvq=1231367056&tn_uvq=1387206491&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str88 = 'uggc://tbbtyrnqf.t.qbhoyrpyvpx.arg/cntrnq/nqf?pyvrag=pn-svz_zlfcnpr_zlfcnpr-ubzrcntr_wf&qg=1231365851658&uy=ra&nqfnsr=uvtu&br=hgs8&ahz_nqf=4&bhgchg=wf&nqgrfg=bss&pbeeryngbe=1231365851658&punaary=svz_zlfcnpr_ubzrcntr_abgybttrqva%2Psvz_zlfcnpr_aba_HTP%2Psvz_zlfcnpr_havgrq-fgngrf&hey=uggc%3N%2S%2Scebsvyrrqvg.zlfcnpr.pbz%2Svaqrk.psz&nq_glcr=grkg&rvq=6083027&rn=0&sez=0&tn_ivq=1979828129.1231365855&tn_fvq=1231365855&tn_uvq=2085229649&synfu=9.0.115&h_u=768&h_j=1024&h_nu=738&h_nj=1024&h_pq=24&h_gm=-480&h_uvf=2&h_wnin=gehr&h_acyht=7&h_azvzr=22'; + var str89 = 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/f55023338617756?[NDO]&aqu=1&g=7%2S0%2S2009%2014%3N12%3N47%203%20480&af=zfacbegny&cntrAnzr=HF%20UCZFSGJ&t=uggc%3N%2S%2Sjjj.zfa.pbz%2S&f=0k0&p=43835816&x=A&oj=994&ou=634&uc=A&{2}&[NDR]'; + var str90 = 'zrgn[anzr=nwnkHey]'; + var str91 = 'anpuevpugra'; + var str92 = 'b oS={\'oT\':1.1};x $8n(B){z(B!=o9)};x $S(B){O(!$8n(B))z A;O(B.4L)z\'T\';b S=7t B;O(S==\'2P\'&&B.p4){23(B.7f){12 1:z\'T\';12 3:z/\S/.2g(B.8M)?\'ox\':\'oh\'}}O(S==\'2P\'||S==\'x\'){23(B.nE){12 2V:z\'1O\';12 7I:z\'5a\';12 18:z\'4B\'}O(7t B.I==\'4F\'){O(B.3u)z\'pG\';O(B.8e)z\'1p\'}}z S};x $2p(){b 4E={};Z(b v=0;v<1p.I;v++){Z(b X 1o 1p[v]){b nc=1p[v][X];b 6E=4E[X];O(6E&&$S(nc)==\'2P\'&&$S(6E)==\'2P\')4E[X]=$2p(6E,nc);17 4E[X]=nc}}z 4E};b $E=7p.E=x(){b 1d=1p;O(!1d[1])1d=[p,1d[0]];Z(b X 1o 1d[1])1d[0][X]=1d[1][X];z 1d[0]};b $4D=7p.pJ=x(){Z(b v=0,y=1p.I;v<y;v++){1p[v].E=x(1J){Z(b 1I 1o 1J){O(!p.1Y[1I])p.1Y[1I]=1J[1I];O(!p[1I])p[1I]=$4D.6C(1I)}}}};$4D.6C=x(1I){z x(L){z p.1Y[1I].3H(L,2V.1Y.nV.1F(1p,1))}};$4D(7F,2V,6J,nb);b 3l=x(B){B=B||{};B.E=$E;z B};b pK=Y 3l(H);b pZ=Y 3l(C);C.6f=C.35(\'6f\')[0];x $2O(B){z!!(B||B===0)};x $5S(B,n8){z $8n(B)?B:n8};x $7K(3c,1m){z 1q.na(1q.7K()*(1m-3c+1)+3c)};x $3N(){z Y 97().os()};x $4M(1U){pv(1U);pa(1U);z 1S};H.43=!!(C.5Z);O(H.nB)H.31=H[H.7q?\'py\':\'nL\']=1r;17 O(C.9N&&!C.om&&!oy.oZ)H.pF=H.4Z=H[H.43?\'pt\':\'65\']=1r;17 O(C.po!=1S)H.7J=1r;O(7t 5B==\'o9\'){b 5B=x(){};O(H.4Z)C.nd("pW");5B.1Y=(H.4Z)?H["[[oN.1Y]]"]:{}}5B.1Y.4L=1r;O(H.nL)5s{C.oX("pp",A,1r)}4K(r){};b 18=x(1X){b 63=x(){z(1p[0]!==1S&&p.1w&&$S(p.1w)==\'x\')?p.1w.3H(p,1p):p};$E(63,p);63.1Y=1X;63.nE=18;z 63};18.1z=x(){};18.1Y={E:x(1X){b 7x=Y p(1S);Z(b X 1o 1X){b nC=7x[X];7x[X]=18.nY(nC,1X[X])}z Y 18(7x)},3d:x(){Z(b v=0,y=1p.I;v<y;v++)$E(p.1Y,1p[v])}};18.nY=x(2b,2n){O(2b&&2b!=2n){b S=$S(2n);O(S!=$S(2b))z 2n;23(S){12\'x\':b 7R=x(){p.1e=1p.8e.1e;z 2n.3H(p,1p)};7R.1e=2b;z 7R;12\'2P\':z $2p(2b,2n)}}z 2n};b 8o=Y 18({oQ:x(J){p.4w=p.4w||[];p.4w.1x(J);z p},7g:x(){O(p.4w&&p.4w.I)p.4w.9J().2x(10,p)},oP:x(){p.4w=[]}});b 2d=Y 18({1V:x(S,J){O(J!=18.1z){p.$19=p.$19||{};p.$19[S]=p.$19[S]||[];p.$19[S].5j(J)}z p},1v:x(S,1d,2x){O(p.$19&&p.$19[S]){p.$19[S].1b(x(J){J.3n({\'L\':p,\'2x\':2x,\'1p\':1d})()},p)}z p},3M:x(S,J){O(p.$19&&p.$19[S])p.$19[S].2U(J);z p}});b 4v=Y 18({2H:x(){p.P=$2p.3H(1S,[p.P].E(1p));O(!p.1V)z p;Z(b 3O 1o p.P){O($S(p.P[3O]==\'x\')&&3O.2g(/^5P[N-M]/))p.1V(3O,p.P[3O])}z p}});2V.E({7y:x(J,L){Z(b v=0,w=p.I;v<w;v++)J.1F(L,p[v],v,p)},3s:x(J,L){b 54=[];Z(b v=0,w=p.I;v<w;v++){O(J.1F(L,p[v],v,p))54.1x(p[v])}z 54},2X:x(J,L){b 54=[];Z(b v=0,w=p.I;v<w;v++)54[v]=J.1F(L,p[v],v,p);z 54},4i:x(J,L){Z(b v=0,w=p.I;v<w;v++){O(!J.1F(L,p[v],v,p))z A}z 1r},ob:x(J,L){Z(b v=0,w=p.I;v<w;v++){O(J.1F(L,p[v],v,p))z 1r}z A},3F:x(3u,15){b 3A=p.I;Z(b v=(15<0)?1q.1m(0,3A+15):15||0;v<3A;v++){O(p[v]===3u)z v}z-1},8z:x(1u,I){1u=1u||0;O(1u<0)1u=p.I+1u;I=I||(p.I-1u);b 89=[];Z(b v=0;v<I;v++)89[v]=p[1u++];z 89},2U:x(3u){b v=0;b 3A=p.I;6L(v<3A){O(p[v]===3u){p.6l(v,1);3A--}17{v++}}z p},1y:x(3u,15){z p.3F(3u,15)!=-1},oz:x(1C){b B={},I=1q.3c(p.I,1C.I);Z(b v=0;v<I;v++)B[1C[v]]=p[v];z B},E:x(1O){Z(b v=0,w=1O.I;v<w;v++)p.1x(1O[v]);z p},2p:x(1O){Z(b v=0,y=1O.I;v<y;v++)p.5j(1O[v]);z p},5j:x(3u){O(!p.1y(3u))p.1x(3u);z p},oc:x(){z p[$7K(0,p.I-1)]||A},7L:x(){z p[p.I-1]||A}});2V.1Y.1b=2V.1Y.7y;2V.1Y.2g=2V.1Y.1y;x $N(1O){z 2V.8z(1O)};x $1b(3J,J,L){O(3J&&7t 3J.I==\'4F\'&&$S(3J)!=\'2P\')2V.7y(3J,J,L);17 Z(b 1j 1o 3J)J.1F(L||3J,3J[1j],1j)};6J.E({2g:x(6b,2F){z(($S(6b)==\'2R\')?Y 7I(6b,2F):6b).2g(p)},3p:x(){z 5K(p,10)},o4:x(){z 69(p)},7A:x(){z p.3y(/-\D/t,x(2G){z 2G.7G(1).nW()})},9b:x(){z p.3y(/\w[N-M]/t,x(2G){z(2G.7G(0)+\'-\'+2G.7G(1).5O())})},8V:x(){z p.3y(/\b[n-m]/t,x(2G){z 2G.nW()})},5L:x(){z p.3y(/^\s+|\s+$/t,\'\')},7j:x(){z p.3y(/\s{2,}/t,\' \').5L()},5V:x(1O){b 1i=p.2G(/\d{1,3}/t);z(1i)?1i.5V(1O):A},5U:x(1O){b 3P=p.2G(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);z(3P)?3P.nV(1).5U(1O):A},1y:x(2R,f){z(f)?(f+p+f).3F(f+2R+f)>-1:p.3F(2R)>-1},nX:x(){z p.3y(/([.*+?^${}()|[\]\/\\])/t,\'\\$1\')}});2V.E({5V:x(1O){O(p.I<3)z A;O(p.I==4&&p[3]==0&&!1O)z\'p5\';b 3P=[];Z(b v=0;v<3;v++){b 52=(p[v]-0).4h(16);3P.1x((52.I==1)?\'0\'+52:52)}z 1O?3P:\'#\'+3P.2u(\'\')},5U:x(1O){O(p.I!=3)z A;b 1i=[];Z(b v=0;v<3;v++){1i.1x(5K((p[v].I==1)?p[v]+p[v]:p[v],16))}z 1O?1i:\'1i(\'+1i.2u(\',\')+\')\'}});7F.E({3n:x(P){b J=p;P=$2p({\'L\':J,\'V\':A,\'1p\':1S,\'2x\':A,\'4s\':A,\'6W\':A},P);O($2O(P.1p)&&$S(P.1p)!=\'1O\')P.1p=[P.1p];z x(V){b 1d;O(P.V){V=V||H.V;1d=[(P.V===1r)?V:Y P.V(V)];O(P.1p)1d.E(P.1p)}17 1d=P.1p||1p;b 3C=x(){z J.3H($5S(P'; + var str93 = 'hagreunyghat'; + var str94 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669341278771470&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str95 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&Pbhagel=IIZ%3Q&SbeprqRkcvengvba=633669350559478880&gvzrMbar=-8&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R%3Q'; + var str96 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669341278771470&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str97 = 'ZFPhygher=VC=74.125.75.1&VCPhygher=ra-HF&CersreerqPhygher=ra-HF&CersreerqPhygherCraqvat=&Pbhagel=IIZ=&SbeprqRkcvengvba=633669350559478880&gvzrMbar=0&HFEYBP=DKWyLHAiMTH9AwHjWxAcqUx9GJ91oaEunJ4tIzyyqlMQo3IhqUW5D29xMG1IHlMQo3IhqUW5GzSgMG1Iozy0MJDtH3EuqTImWxEgLHAiMTH9BQN3WxkuqTy0qJEyCGZ3YwDkBGVzGT9hM2y0qJEyCF0kZwVhZQH3APMDo3A0LJkQo2EyCGx0ZQDmWyWyM2yiox5uoJH9D0R='; + var str98 = 'shapgvba (){Cuk.Nccyvpngvba.Frghc.Pber();Cuk.Nccyvpngvba.Frghc.Nwnk();Cuk.Nccyvpngvba.Frghc.Synfu();Cuk.Nccyvpngvba.Frghc.Zbqhyrf()}'; + function runBlock11() { + for (var i = 0; i < 2; i++) { + ' .pybfr'.replace(re18, ''); + ' n.svryqOgaPnapry'.replace(re18, ''); + ' qg'.replace(re18, ''); + str77.replace(re68, ''); + str77.replace(re18, ''); + ''.replace(re39, ''); + ''.replace(/^/, ''); + ''.split(re86); + '*'.replace(re39, ''); + '*'.replace(re68, ''); + '*'.replace(re18, ''); + '.pybfr'.replace(re68, ''); + '.pybfr'.replace(re18, ''); + '//vzt.jro.qr/vij/FC/tzk_uc/fperra/${inyhr}?gf=${abj}'.replace(re87, ''); + '//vzt.jro.qr/vij/FC/tzk_uc/fperra/1024?gf=${abj}'.replace(re88, ''); + '//vzt.jro.qr/vij/FC/tzk_uc/jvafvmr/${inyhr}?gf=${abj}'.replace(re87, ''); + '//vzt.jro.qr/vij/FC/tzk_uc/jvafvmr/992/608?gf=${abj}'.replace(re88, ''); + '300k120'.replace(re30, ''); + '300k250'.replace(re30, ''); + '310k120'.replace(re30, ''); + '310k170'.replace(re30, ''); + '310k250'.replace(re30, ''); + '9.0 e115'.replace(/^.*\.(.*)\s.*$/, ''); + 'Nppbeqvba'.replace(re2, ''); + 'Nxghryy\x0a'.replace(re89, ''); + 'Nxghryy\x0a'.replace(re90, ''); + 'Nccyvpngvba'.replace(re2, ''); + 'Oyvpxchaxg\x0a'.replace(re89, ''); + 'Oyvpxchaxg\x0a'.replace(re90, ''); + 'Svanamra\x0a'.replace(re89, ''); + 'Svanamra\x0a'.replace(re90, ''); + 'Tnzrf\x0a'.replace(re89, ''); + 'Tnzrf\x0a'.replace(re90, ''); + 'Ubebfxbc\x0a'.replace(re89, ''); + 'Ubebfxbc\x0a'.replace(re90, ''); + 'Xvab\x0a'.replace(re89, ''); + 'Xvab\x0a'.replace(re90, ''); + 'Zbqhyrf'.replace(re2, ''); + 'Zhfvx\x0a'.replace(re89, ''); + 'Zhfvx\x0a'.replace(re90, ''); + 'Anpuevpugra\x0a'.replace(re89, ''); + 'Anpuevpugra\x0a'.replace(re90, ''); + 'Cuk'.replace(re2, ''); + 'ErdhrfgSvavfu'.split(re70); + 'ErdhrfgSvavfu.NWNK.Cuk'.split(re70); + 'Ebhgr\x0a'.replace(re89, ''); + 'Ebhgr\x0a'.replace(re90, ''); + str78.split(re32); + str79.split(re32); + str80.split(re32); + str81.split(re32); + 'Fcbeg\x0a'.replace(re89, ''); + 'Fcbeg\x0a'.replace(re90, ''); + 'GI-Fcbg\x0a'.replace(re89, ''); + 'GI-Fcbg\x0a'.replace(re90, ''); + 'Gbhe\x0a'.replace(re89, ''); + 'Gbhe\x0a'.replace(re90, ''); + 'Hagreunyghat\x0a'.replace(re89, ''); + 'Hagreunyghat\x0a'.replace(re90, ''); + 'Ivqrb\x0a'.replace(re89, ''); + 'Ivqrb\x0a'.replace(re90, ''); + 'Jrggre\x0a'.replace(re89, ''); + 'Jrggre\x0a'.replace(re90, ''); + str82.replace(re68, ''); + str82.replace(re18, ''); + str83.replace(re68, ''); + str83.replace(re18, ''); + str84.replace(re68, ''); + str84.replace(re18, ''); + 'nqiFreivprObk'.replace(re30, ''); + 'nqiFubccvatObk'.replace(re30, ''); + 'nwnk'.replace(re39, ''); + 'nxghryy'.replace(re40, ''); + 'nxghryy'.replace(re41, ''); + 'nxghryy'.replace(re42, ''); + 'nxghryy'.replace(re43, ''); + 'nxghryy'.replace(re44, ''); + 'nxghryy'.replace(re45, ''); + 'nxghryy'.replace(re46, ''); + 'nxghryy'.replace(re47, ''); + 'nxghryy'.replace(re48, ''); + str85.replace(re40, ''); + str85.replace(re41, ''); + str85.replace(re42, ''); + str85.replace(re43, ''); + str85.replace(re44, ''); + str85.replace(re45, ''); + str85.replace(re46, ''); + str85.replace(re47, ''); + str85.replace(re48, ''); + 'pngrtbel'.replace(re29, ''); + 'pngrtbel'.replace(re30, ''); + 'pybfr'.replace(re39, ''); + 'qvi'.replace(re39, ''); + str86.replace(re68, ''); + str86.replace(re18, ''); + 'qg'.replace(re39, ''); + 'qg'.replace(re68, ''); + 'qg'.replace(re18, ''); + 'rzorq'.replace(re39, ''); + 'rzorq'.replace(re68, ''); + 'rzorq'.replace(re18, ''); + 'svryqOga'.replace(re39, ''); + 'svryqOgaPnapry'.replace(re39, ''); + 'svz_zlfcnpr_nccf-pnainf,svz_zlfcnpr_havgrq-fgngrf'.split(re20); + 'svanamra'.replace(re40, ''); + 'svanamra'.replace(re41, ''); + 'svanamra'.replace(re42, ''); + 'svanamra'.replace(re43, ''); + 'svanamra'.replace(re44, ''); + 'svanamra'.replace(re45, ''); + 'svanamra'.replace(re46, ''); + 'svanamra'.replace(re47, ''); + 'svanamra'.replace(re48, ''); + 'sbphf'.split(re70); + 'sbphf.gno sbphfva.gno'.split(re70); + 'sbphfva'.split(re70); + 'sbez'.replace(re39, ''); + 'sbez.nwnk'.replace(re68, ''); + 'sbez.nwnk'.replace(re18, ''); + 'tnzrf'.replace(re40, ''); + 'tnzrf'.replace(re41, ''); + 'tnzrf'.replace(re42, ''); + 'tnzrf'.replace(re43, ''); + 'tnzrf'.replace(re44, ''); + 'tnzrf'.replace(re45, ''); + 'tnzrf'.replace(re46, ''); + 'tnzrf'.replace(re47, ''); + 'tnzrf'.replace(re48, ''); + 'ubzrcntr'.replace(re30, ''); + 'ubebfxbc'.replace(re40, ''); + 'ubebfxbc'.replace(re41, ''); + 'ubebfxbc'.replace(re42, ''); + 'ubebfxbc'.replace(re43, ''); + 'ubebfxbc'.replace(re44, ''); + 'ubebfxbc'.replace(re45, ''); + 'ubebfxbc'.replace(re46, ''); + 'ubebfxbc'.replace(re47, ''); + 'ubebfxbc'.replace(re48, ''); + 'uc_cebzbobk_ugzy%2Puc_cebzbobk_vzt'.replace(re30, ''); + 'uc_erpgnatyr'.replace(re30, ''); + str87.replace(re33, ''); + str88.replace(re33, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/onfr.wf${4}${5}'.replace(re71, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/onfr.wf${5}'.replace(re72, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/qlaYvo.wf${4}${5}'.replace(re71, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/qlaYvo.wf${5}'.replace(re72, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/rssrpgYvo.wf${4}${5}'.replace(re71, ''); + 'uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/rssrpgYvo.wf${5}'.replace(re72, ''); + str89.replace(re73, ''); + 'uggc://zfacbegny.112.2b7.arg/o/ff/zfacbegnyubzr/1/U.7-cqi-2/f55023338617756?[NDO]&{1}&{2}&[NDR]'.replace(re69, ''); + str6.replace(re23, ''); + 'xvab'.replace(re40, ''); + 'xvab'.replace(re41, ''); + 'xvab'.replace(re42, ''); + 'xvab'.replace(re43, ''); + 'xvab'.replace(re44, ''); + 'xvab'.replace(re45, ''); + 'xvab'.replace(re46, ''); + 'xvab'.replace(re47, ''); + 'xvab'.replace(re48, ''); + 'ybnq'.split(re70); + 'zrqvnzbqgno lhv-anifrg lhv-anifrg-gbc'.replace(re18, ''); + 'zrgn'.replace(re39, ''); + str90.replace(re68, ''); + str90.replace(re18, ''); + 'zbhfrzbir'.split(re70); + 'zbhfrzbir.gno'.split(re70); + str63.replace(/^.*jroxvg\/(\d+(\.\d+)?).*$/, ''); + 'zhfvx'.replace(re40, ''); + 'zhfvx'.replace(re41, ''); + 'zhfvx'.replace(re42, ''); + 'zhfvx'.replace(re43, ''); + 'zhfvx'.replace(re44, ''); + 'zhfvx'.replace(re45, ''); + 'zhfvx'.replace(re46, ''); + 'zhfvx'.replace(re47, ''); + 'zhfvx'.replace(re48, ''); + 'zlfcnpr_nccf_pnainf'.replace(re52, ''); + str91.replace(re40, ''); + str91.replace(re41, ''); + str91.replace(re42, ''); + str91.replace(re43, ''); + str91.replace(re44, ''); + str91.replace(re45, ''); + str91.replace(re46, ''); + str91.replace(re47, ''); + str91.replace(re48, ''); + 'anzr'.replace(re39, ''); + str92.replace(/\b\w+\b/g, ''); + 'bow-nppbeqvba'.replace(re39, ''); + 'bowrpg'.replace(re39, ''); + 'bowrpg'.replace(re68, ''); + 'bowrpg'.replace(re18, ''); + 'cnenzf%2Rfglyrf'.replace(re29, ''); + 'cnenzf%2Rfglyrf'.replace(re30, ''); + 'cbchc'.replace(re30, ''); + 'ebhgr'.replace(re40, ''); + 'ebhgr'.replace(re41, ''); + 'ebhgr'.replace(re42, ''); + 'ebhgr'.replace(re43, ''); + 'ebhgr'.replace(re44, ''); + 'ebhgr'.replace(re45, ''); + 'ebhgr'.replace(re46, ''); + 'ebhgr'.replace(re47, ''); + 'ebhgr'.replace(re48, ''); + 'freivprobk_uc'.replace(re30, ''); + 'fubccvatobk_uc'.replace(re30, ''); + 'fubhgobk'.replace(re39, ''); + 'fcbeg'.replace(re40, ''); + 'fcbeg'.replace(re41, ''); + 'fcbeg'.replace(re42, ''); + 'fcbeg'.replace(re43, ''); + 'fcbeg'.replace(re44, ''); + 'fcbeg'.replace(re45, ''); + 'fcbeg'.replace(re46, ''); + 'fcbeg'.replace(re47, ''); + 'fcbeg'.replace(re48, ''); + 'gbhe'.replace(re40, ''); + 'gbhe'.replace(re41, ''); + 'gbhe'.replace(re42, ''); + 'gbhe'.replace(re43, ''); + 'gbhe'.replace(re44, ''); + 'gbhe'.replace(re45, ''); + 'gbhe'.replace(re46, ''); + 'gbhe'.replace(re47, ''); + 'gbhe'.replace(re48, ''); + 'gi-fcbg'.replace(re40, ''); + 'gi-fcbg'.replace(re41, ''); + 'gi-fcbg'.replace(re42, ''); + 'gi-fcbg'.replace(re43, ''); + 'gi-fcbg'.replace(re44, ''); + 'gi-fcbg'.replace(re45, ''); + 'gi-fcbg'.replace(re46, ''); + 'gi-fcbg'.replace(re47, ''); + 'gi-fcbg'.replace(re48, ''); + 'glcr'.replace(re39, ''); + 'haqrsvarq'.replace(/\//g, ''); + str93.replace(re40, ''); + str93.replace(re41, ''); + str93.replace(re42, ''); + str93.replace(re43, ''); + str93.replace(re44, ''); + str93.replace(re45, ''); + str93.replace(re46, ''); + str93.replace(re47, ''); + str93.replace(re48, ''); + 'ivqrb'.replace(re40, ''); + 'ivqrb'.replace(re41, ''); + 'ivqrb'.replace(re42, ''); + 'ivqrb'.replace(re43, ''); + 'ivqrb'.replace(re44, ''); + 'ivqrb'.replace(re45, ''); + 'ivqrb'.replace(re46, ''); + 'ivqrb'.replace(re47, ''); + 'ivqrb'.replace(re48, ''); + 'ivfvgf=1'.split(re86); + 'jrggre'.replace(re40, ''); + 'jrggre'.replace(re41, ''); + 'jrggre'.replace(re42, ''); + 'jrggre'.replace(re43, ''); + 'jrggre'.replace(re44, ''); + 'jrggre'.replace(re45, ''); + 'jrggre'.replace(re46, ''); + 'jrggre'.replace(re47, ''); + 'jrggre'.replace(re48, ''); + /#[a-z0-9]+$/i.exec('uggc://jjj.fpuhryreim.arg/Qrsnhyg'); + re66.exec('fryrpgrq'); + /(?:^|\s+)lhv-ani(?:\s+|$)/.exec('sff lhv-ani'); + /(?:^|\s+)lhv-anifrg(?:\s+|$)/.exec('zrqvnzbqgno lhv-anifrg'); + /(?:^|\s+)lhv-anifrg-gbc(?:\s+|$)/.exec('zrqvnzbqgno lhv-anifrg'); + re91.exec('GnoThvq'); + re91.exec('thvq'); + /(pbzcngvoyr|jroxvg)/.exec(str63); + /.+(?:ei|vg|en|vr)[\/: ]([\d.]+)/.exec(str63); + re8.exec('144631658.0.10.1231365869'); + re8.exec('144631658.0.10.1231367054'); + re8.exec('144631658.1231365869.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.1231367054.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('144631658.1670816052019209000.1231365869.1231365869.1231365869.1'); + re8.exec('144631658.1796080716621419500.1231367054.1231367054.1231367054.1'); + re8.exec(str94); + re8.exec(str95); + re8.exec(str96); + re8.exec(str97); + re8.exec('__hgzn=144631658.1670816052019209000.1231365869.1231365869.1231365869.1'); + re8.exec('__hgzn=144631658.1796080716621419500.1231367054.1231367054.1231367054.1'); + re8.exec('__hgzo=144631658.0.10.1231365869'); + re8.exec('__hgzo=144631658.0.10.1231367054'); + re8.exec('__hgzm=144631658.1231365869.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re8.exec('__hgzm=144631658.1231367054.1.1.hgzpfe=(qverpg)|hgzppa=(qverpg)|hgzpzq=(abar)'); + re34.exec(str78); + re34.exec(str79); + re34.exec(str81); + re74.exec(str77); + re74.exec('*'); + re74.exec(str82); + re74.exec(str83); + re74.exec(str86); + re74.exec('rzorq'); + re74.exec('sbez.nwnk'); + re74.exec(str90); + re74.exec('bowrpg'); + /\/onfr.wf(\?.+)?$/.exec('/uggc://wf.hv-cbegny.qr/tzk/ubzr/wf/20080602/onfr.wf'); + re28.exec('uvag ynfgUvag ynfg'); + re75.exec(''); + re76.exec(''); + re77.exec(''); + re78.exec(''); + re80.exec(str77); + re80.exec('*'); + re80.exec('.pybfr'); + re80.exec(str82); + re80.exec(str83); + re80.exec(str84); + re80.exec(str86); + re80.exec('qg'); + re80.exec('rzorq'); + re80.exec('sbez.nwnk'); + re80.exec(str90); + re80.exec('bowrpg'); + re61.exec('qlaYvo.wf'); + re61.exec('rssrpgYvo.wf'); + re61.exec('uggc://jjj.tzk.arg/qr/?fgnghf=uvajrvf'); + re92.exec(' .pybfr'); + re92.exec(' n.svryqOgaPnapry'); + re92.exec(' qg'); + re92.exec(str48); + re92.exec('.nwnk'); + re92.exec('.svryqOga,n.svryqOgaPnapry'); + re92.exec('.svryqOgaPnapry'); + re92.exec('.bow-nppbeqvba qg'); + re68.exec(str77); + re68.exec('*'); + re68.exec('.pybfr'); + re68.exec(str82); + re68.exec(str83); + re68.exec(str84); + re68.exec(str86); + re68.exec('qg'); + re68.exec('rzorq'); + re68.exec('sbez.nwnk'); + re68.exec(str90); + re68.exec('bowrpg'); + re93.exec(' .pybfr'); + re93.exec(' n.svryqOgaPnapry'); + re93.exec(' qg'); + re93.exec(str48); + re93.exec('.nwnk'); + re93.exec('.svryqOga,n.svryqOgaPnapry'); + re93.exec('.svryqOgaPnapry'); + re93.exec('.bow-nppbeqvba qg'); + re81.exec(str77); + re81.exec('*'); + re81.exec(str48); + re81.exec('.pybfr'); + re81.exec(str82); + re81.exec(str83); + re81.exec(str84); + re81.exec(str86); + re81.exec('qg'); + re81.exec('rzorq'); + re81.exec('sbez.nwnk'); + re81.exec(str90); + re81.exec('bowrpg'); + re94.exec(' .pybfr'); + re94.exec(' n.svryqOgaPnapry'); + re94.exec(' qg'); + re94.exec(str48); + re94.exec('.nwnk'); + re94.exec('.svryqOga,n.svryqOgaPnapry'); + re94.exec('.svryqOgaPnapry'); + re94.exec('.bow-nppbeqvba qg'); + re94.exec('[anzr=nwnkHey]'); + re94.exec(str82); + re31.exec('rf'); + re31.exec('wn'); + re82.exec(str77); + re82.exec('*'); + re82.exec(str48); + re82.exec('.pybfr'); + re82.exec(str82); + re82.exec(str83); + re82.exec(str84); + re82.exec(str86); + re82.exec('qg'); + re82.exec('rzorq'); + re82.exec('sbez.nwnk'); + re82.exec(str90); + re82.exec('bowrpg'); + re83.exec(str98); + re83.exec('shapgvba sbphf() { [angvir pbqr] }'); + re62.exec('#Ybtva'); + re62.exec('#Ybtva_cnffjbeq'); + re62.exec(str77); + re62.exec('#fubhgobkWf'); + re62.exec('#fubhgobkWfReebe'); + re62.exec('#fubhgobkWfFhpprff'); + re62.exec('*'); + re62.exec(str82); + re62.exec(str83); + re62.exec(str86); + re62.exec('rzorq'); + re62.exec('sbez.nwnk'); + re62.exec(str90); + re62.exec('bowrpg'); + re49.exec('pbagrag'); + re24.exec(str6); + /xbadhrebe/.exec(str63); + /znp/.exec('jva32'); + /zbmvyyn/.exec(str63); + /zfvr/.exec(str63); + /ag\s5\.1/.exec(str63); + /bcren/.exec(str63); + /fnsnev/.exec(str63); + /jva/.exec('jva32'); + /jvaqbjf/.exec(str63); + } + } + + function run() { + for (var i = 0; i < 5; i++) { + runBlock0(); + runBlock1(); + runBlock2(); + runBlock3(); + runBlock4(); + runBlock5(); + runBlock6(); + runBlock7(); + runBlock8(); + runBlock9(); + runBlock10(); + runBlock11(); + } + } + + this.run = run; +} +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This benchmark is based on a JavaScript log processing module used +// by the V8 profiler to generate execution time profiles for runs of +// JavaScript applications, and it effectively measures how fast the +// JavaScript engine is at allocating nodes and reclaiming the memory +// used for old nodes. Because of the way splay trees work, the engine +// also has to deal with a lot of changes to the large tree object +// graph. + +var Splay = new BenchmarkSuite('Splay', 81491, [ + new Benchmark("Splay", SplayRun, SplaySetup, SplayTearDown) +]); + + +// Configuration. +var kSplayTreeSize = 8000; +var kSplayTreeModifications = 80; +var kSplayTreePayloadDepth = 5; + +var splayTree = null; + + +function GeneratePayloadTree(depth, tag) { + if (depth == 0) { + return { + array : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], + string : 'String for key ' + tag + ' in leaf node' + }; + } else { + return { + left: GeneratePayloadTree(depth - 1, tag), + right: GeneratePayloadTree(depth - 1, tag) + }; + } +} + + +function GenerateKey() { + // The benchmark framework guarantees that Math.random is + // deterministic; see base.js. + return Math.random(); +} + + +function InsertNewNode() { + // Insert new node with a unique key. + var key; + do { + key = GenerateKey(); + } while (splayTree.find(key) != null); + var payload = GeneratePayloadTree(kSplayTreePayloadDepth, String(key)); + splayTree.insert(key, payload); + return key; +} + + + +function SplaySetup() { + splayTree = new SplayTree(); + for (var i = 0; i < kSplayTreeSize; i++) InsertNewNode(); +} + + +function SplayTearDown() { + // Allow the garbage collector to reclaim the memory + // used by the splay tree no matter how we exit the + // tear down function. + var keys = splayTree.exportKeys(); + splayTree = null; + + // Verify that the splay tree has the right size. + var length = keys.length; + if (length != kSplayTreeSize) { + throw new Error("Splay tree has wrong size"); + } + + // Verify that the splay tree has sorted, unique keys. + for (var i = 0; i < length - 1; i++) { + if (keys[i] >= keys[i + 1]) { + throw new Error("Splay tree not sorted"); + } + } +} + + +function SplayRun() { + // Replace a few nodes in the splay tree. + for (var i = 0; i < kSplayTreeModifications; i++) { + var key = InsertNewNode(); + var greatest = splayTree.findGreatestLessThan(key); + if (greatest == null) splayTree.remove(key); + else splayTree.remove(greatest.key); + } +} + + +/** + * Constructs a Splay tree. A splay tree is a self-balancing binary + * search tree with the additional property that recently accessed + * elements are quick to access again. It performs basic operations + * such as insertion, look-up and removal in O(log(n)) amortized time. + * + * @constructor + */ +function SplayTree() { +}; + + +/** + * Pointer to the root node of the tree. + * + * @type {SplayTree.Node} + * @private + */ +SplayTree.prototype.root_ = null; + + +/** + * @return {boolean} Whether the tree is empty. + */ +SplayTree.prototype.isEmpty = function() { + return !this.root_; +}; + + +/** + * Inserts a node into the tree with the specified key and value if + * the tree does not already contain a node with the specified key. If + * the value is inserted, it becomes the root of the tree. + * + * @param {number} key Key to insert into the tree. + * @param {*} value Value to insert into the tree. + */ +SplayTree.prototype.insert = function(key, value) { + if (this.isEmpty()) { + this.root_ = new SplayTree.Node(key, value); + return; + } + // Splay on the key to move the last node on the search path for + // the key to the root of the tree. + this.splay_(key); + if (this.root_.key == key) { + return; + } + var node = new SplayTree.Node(key, value); + if (key > this.root_.key) { + node.left = this.root_; + node.right = this.root_.right; + this.root_.right = null; + } else { + node.right = this.root_; + node.left = this.root_.left; + this.root_.left = null; + } + this.root_ = node; +}; + + +/** + * Removes a node with the specified key from the tree if the tree + * contains a node with this key. The removed node is returned. If the + * key is not found, an exception is thrown. + * + * @param {number} key Key to find and remove from the tree. + * @return {SplayTree.Node} The removed node. + */ +SplayTree.prototype.remove = function(key) { + if (this.isEmpty()) { + throw Error('Key not found: ' + key); + } + this.splay_(key); + if (this.root_.key != key) { + throw Error('Key not found: ' + key); + } + var removed = this.root_; + if (!this.root_.left) { + this.root_ = this.root_.right; + } else { + var right = this.root_.right; + this.root_ = this.root_.left; + // Splay to make sure that the new root has an empty right child. + this.splay_(key); + // Insert the original right child as the right child of the new + // root. + this.root_.right = right; + } + return removed; +}; + + +/** + * Returns the node having the specified key or null if the tree doesn't contain + * a node with the specified key. + * + * @param {number} key Key to find in the tree. + * @return {SplayTree.Node} Node having the specified key. + */ +SplayTree.prototype.find = function(key) { + if (this.isEmpty()) { + return null; + } + this.splay_(key); + return this.root_.key == key ? this.root_ : null; +}; + + +/** + * @return {SplayTree.Node} Node having the maximum key value. + */ +SplayTree.prototype.findMax = function(opt_startNode) { + if (this.isEmpty()) { + return null; + } + var current = opt_startNode || this.root_; + while (current.right) { + current = current.right; + } + return current; +}; + + +/** + * @return {SplayTree.Node} Node having the maximum key value that + * is less than the specified key value. + */ +SplayTree.prototype.findGreatestLessThan = function(key) { + if (this.isEmpty()) { + return null; + } + // Splay on the key to move the node with the given key or the last + // node on the search path to the top of the tree. + this.splay_(key); + // Now the result is either the root node or the greatest node in + // the left subtree. + if (this.root_.key < key) { + return this.root_; + } else if (this.root_.left) { + return this.findMax(this.root_.left); + } else { + return null; + } +}; + + +/** + * @return {Array<*>} An array containing all the keys of tree's nodes. + */ +SplayTree.prototype.exportKeys = function() { + var result = []; + if (!this.isEmpty()) { + this.root_.traverse_(function(node) { result.push(node.key); }); + } + return result; +}; + + +/** + * Perform the splay operation for the given key. Moves the node with + * the given key to the top of the tree. If no node has the given + * key, the last node on the search path is moved to the top of the + * tree. This is the simplified top-down splaying algorithm from: + * "Self-adjusting Binary Search Trees" by Sleator and Tarjan + * + * @param {number} key Key to splay the tree on. + * @private + */ +SplayTree.prototype.splay_ = function(key) { + if (this.isEmpty()) { + return; + } + // Create a dummy node. The use of the dummy node is a bit + // counter-intuitive: The right child of the dummy node will hold + // the L tree of the algorithm. The left child of the dummy node + // will hold the R tree of the algorithm. Using a dummy node, left + // and right will always be nodes and we avoid special cases. + var dummy, left, right; + dummy = left = right = new SplayTree.Node(null, null); + var current = this.root_; + while (true) { + if (key < current.key) { + if (!current.left) { + break; + } + if (key < current.left.key) { + // Rotate right. + var tmp = current.left; + current.left = tmp.right; + tmp.right = current; + current = tmp; + if (!current.left) { + break; + } + } + // Link right. + right.left = current; + right = current; + current = current.left; + } else if (key > current.key) { + if (!current.right) { + break; + } + if (key > current.right.key) { + // Rotate left. + var tmp = current.right; + current.right = tmp.left; + tmp.left = current; + current = tmp; + if (!current.right) { + break; + } + } + // Link left. + left.right = current; + left = current; + current = current.right; + } else { + break; + } + } + // Assemble. + left.right = current.left; + right.left = current.right; + current.left = dummy.right; + current.right = dummy.left; + this.root_ = current; +}; + + +/** + * Constructs a Splay tree node. + * + * @param {number} key Key. + * @param {*} value Value. + */ +SplayTree.Node = function(key, value) { + this.key = key; + this.value = value; +}; + + +/** + * @type {SplayTree.Node} + */ +SplayTree.Node.prototype.left = null; + + +/** + * @type {SplayTree.Node} + */ +SplayTree.Node.prototype.right = null; + + +/** + * Performs an ordered traversal of the subtree starting at + * this SplayTree.Node. + * + * @param {function(SplayTree.Node)} f Visitor function. + * @private + */ +SplayTree.Node.prototype.traverse_ = function(f) { + var current = this; + while (current) { + var left = current.left; + if (left) left.traverse_(f); + f(current); + current = current.right; + } +}; +/** + * Copyright 2012 the V8 project authors. All rights reserved. + * Copyright 2009 Oliver Hunt <http://nerget.com> + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +var NavierStokes = new BenchmarkSuite('NavierStokes', 1484000, + [new Benchmark('NavierStokes', + runNavierStokes, + setupNavierStokes, + tearDownNavierStokes)]); + +var solver = null; + +function runNavierStokes() +{ + solver.update(); +} + +function setupNavierStokes() +{ + solver = new FluidField(null); + solver.setResolution(128, 128); + solver.setIterations(20); + solver.setDisplayFunction(function(){}); + solver.setUICallback(prepareFrame); + solver.reset(); +} + +function tearDownNavierStokes() +{ + solver = null; +} + +function addPoints(field) { + var n = 64; + for (var i = 1; i <= n; i++) { + field.setVelocity(i, i, n, n); + field.setDensity(i, i, 5); + field.setVelocity(i, n - i, -n, -n); + field.setDensity(i, n - i, 20); + field.setVelocity(128 - i, n + i, -n, -n); + field.setDensity(128 - i, n + i, 30); + } +} + +var framesTillAddingPoints = 0; +var framesBetweenAddingPoints = 5; + +function prepareFrame(field) +{ + if (framesTillAddingPoints == 0) { + addPoints(field); + framesTillAddingPoints = framesBetweenAddingPoints; + framesBetweenAddingPoints++; + } else { + framesTillAddingPoints--; + } +} + +// Code from Oliver Hunt (http://nerget.com/fluidSim/pressure.js) starts here. +function FluidField(canvas) { + function addFields(x, s, dt) + { + for (var i=0; i<size ; i++ ) x[i] += dt*s[i]; + } + + function set_bnd(b, x) + { + if (b===1) { + for (var i = 1; i <= width; i++) { + x[i] = x[i + rowSize]; + x[i + (height+1) *rowSize] = x[i + height * rowSize]; + } + + for (var j = 1; i <= height; i++) { + x[j * rowSize] = -x[1 + j * rowSize]; + x[(width + 1) + j * rowSize] = -x[width + j * rowSize]; + } + } else if (b === 2) { + for (var i = 1; i <= width; i++) { + x[i] = -x[i + rowSize]; + x[i + (height + 1) * rowSize] = -x[i + height * rowSize]; + } + + for (var j = 1; j <= height; j++) { + x[j * rowSize] = x[1 + j * rowSize]; + x[(width + 1) + j * rowSize] = x[width + j * rowSize]; + } + } else { + for (var i = 1; i <= width; i++) { + x[i] = x[i + rowSize]; + x[i + (height + 1) * rowSize] = x[i + height * rowSize]; + } + + for (var j = 1; j <= height; j++) { + x[j * rowSize] = x[1 + j * rowSize]; + x[(width + 1) + j * rowSize] = x[width + j * rowSize]; + } + } + var maxEdge = (height + 1) * rowSize; + x[0] = 0.5 * (x[1] + x[rowSize]); + x[maxEdge] = 0.5 * (x[1 + maxEdge] + x[height * rowSize]); + x[(width+1)] = 0.5 * (x[width] + x[(width + 1) + rowSize]); + x[(width+1)+maxEdge] = 0.5 * (x[width + maxEdge] + x[(width + 1) + height * rowSize]); + } + + function lin_solve(b, x, x0, a, c) + { + if (a === 0 && c === 1) { + for (var j=1 ; j<=height; j++) { + var currentRow = j * rowSize; + ++currentRow; + for (var i = 0; i < width; i++) { + x[currentRow] = x0[currentRow]; + ++currentRow; + } + } + set_bnd(b, x); + } else { + var invC = 1 / c; + for (var k=0 ; k<iterations; k++) { + for (var j=1 ; j<=height; j++) { + var lastRow = (j - 1) * rowSize; + var currentRow = j * rowSize; + var nextRow = (j + 1) * rowSize; + var lastX = x[currentRow]; + ++currentRow; + for (var i=1; i<=width; i++) + lastX = x[currentRow] = (x0[currentRow] + a*(lastX+x[++currentRow]+x[++lastRow]+x[++nextRow])) * invC; + } + set_bnd(b, x); + } + } + } + + function diffuse(b, x, x0, dt) + { + var a = 0; + lin_solve(b, x, x0, a, 1 + 4*a); + } + + function lin_solve2(x, x0, y, y0, a, c) + { + if (a === 0 && c === 1) { + for (var j=1 ; j <= height; j++) { + var currentRow = j * rowSize; + ++currentRow; + for (var i = 0; i < width; i++) { + x[currentRow] = x0[currentRow]; + y[currentRow] = y0[currentRow]; + ++currentRow; + } + } + set_bnd(1, x); + set_bnd(2, y); + } else { + var invC = 1/c; + for (var k=0 ; k<iterations; k++) { + for (var j=1 ; j <= height; j++) { + var lastRow = (j - 1) * rowSize; + var currentRow = j * rowSize; + var nextRow = (j + 1) * rowSize; + var lastX = x[currentRow]; + var lastY = y[currentRow]; + ++currentRow; + for (var i = 1; i <= width; i++) { + lastX = x[currentRow] = (x0[currentRow] + a * (lastX + x[currentRow] + x[lastRow] + x[nextRow])) * invC; + lastY = y[currentRow] = (y0[currentRow] + a * (lastY + y[++currentRow] + y[++lastRow] + y[++nextRow])) * invC; + } + } + set_bnd(1, x); + set_bnd(2, y); + } + } + } + + function diffuse2(x, x0, y, y0, dt) + { + var a = 0; + lin_solve2(x, x0, y, y0, a, 1 + 4 * a); + } + + function advect(b, d, d0, u, v, dt) + { + var Wdt0 = dt * width; + var Hdt0 = dt * height; + var Wp5 = width + 0.5; + var Hp5 = height + 0.5; + for (var j = 1; j<= height; j++) { + var pos = j * rowSize; + for (var i = 1; i <= width; i++) { + var x = i - Wdt0 * u[++pos]; + var y = j - Hdt0 * v[pos]; + if (x < 0.5) + x = 0.5; + else if (x > Wp5) + x = Wp5; + var i0 = x | 0; + var i1 = i0 + 1; + if (y < 0.5) + y = 0.5; + else if (y > Hp5) + y = Hp5; + var j0 = y | 0; + var j1 = j0 + 1; + var s1 = x - i0; + var s0 = 1 - s1; + var t1 = y - j0; + var t0 = 1 - t1; + var row1 = j0 * rowSize; + var row2 = j1 * rowSize; + d[pos] = s0 * (t0 * d0[i0 + row1] + t1 * d0[i0 + row2]) + s1 * (t0 * d0[i1 + row1] + t1 * d0[i1 + row2]); + } + } + set_bnd(b, d); + } + + function project(u, v, p, div) + { + var h = -0.5 / Math.sqrt(width * height); + for (var j = 1 ; j <= height; j++ ) { + var row = j * rowSize; + var previousRow = (j - 1) * rowSize; + var prevValue = row - 1; + var currentRow = row; + var nextValue = row + 1; + var nextRow = (j + 1) * rowSize; + for (var i = 1; i <= width; i++ ) { + div[++currentRow] = h * (u[++nextValue] - u[++prevValue] + v[++nextRow] - v[++previousRow]); + p[currentRow] = 0; + } + } + set_bnd(0, div); + set_bnd(0, p); + + lin_solve(0, p, div, 1, 4 ); + var wScale = 0.5 * width; + var hScale = 0.5 * height; + for (var j = 1; j<= height; j++ ) { + var prevPos = j * rowSize - 1; + var currentPos = j * rowSize; + var nextPos = j * rowSize + 1; + var prevRow = (j - 1) * rowSize; + var currentRow = j * rowSize; + var nextRow = (j + 1) * rowSize; + + for (var i = 1; i<= width; i++) { + u[++currentPos] -= wScale * (p[++nextPos] - p[++prevPos]); + v[currentPos] -= hScale * (p[++nextRow] - p[++prevRow]); + } + } + set_bnd(1, u); + set_bnd(2, v); + } + + function dens_step(x, x0, u, v, dt) + { + addFields(x, x0, dt); + diffuse(0, x0, x, dt ); + advect(0, x, x0, u, v, dt ); + } + + function vel_step(u, v, u0, v0, dt) + { + addFields(u, u0, dt ); + addFields(v, v0, dt ); + var temp = u0; u0 = u; u = temp; + var temp = v0; v0 = v; v = temp; + diffuse2(u,u0,v,v0, dt); + project(u, v, u0, v0); + var temp = u0; u0 = u; u = temp; + var temp = v0; v0 = v; v = temp; + advect(1, u, u0, u0, v0, dt); + advect(2, v, v0, u0, v0, dt); + project(u, v, u0, v0 ); + } + var uiCallback = function(d,u,v) {}; + + function Field(dens, u, v) { + // Just exposing the fields here rather than using accessors is a measurable win during display (maybe 5%) + // but makes the code ugly. + this.setDensity = function(x, y, d) { + dens[(x + 1) + (y + 1) * rowSize] = d; + } + this.getDensity = function(x, y) { + return dens[(x + 1) + (y + 1) * rowSize]; + } + this.setVelocity = function(x, y, xv, yv) { + u[(x + 1) + (y + 1) * rowSize] = xv; + v[(x + 1) + (y + 1) * rowSize] = yv; + } + this.getXVelocity = function(x, y) { + return u[(x + 1) + (y + 1) * rowSize]; + } + this.getYVelocity = function(x, y) { + return v[(x + 1) + (y + 1) * rowSize]; + } + this.width = function() { return width; } + this.height = function() { return height; } + } + function queryUI(d, u, v) + { + for (var i = 0; i < size; i++) + u[i] = v[i] = d[i] = 0.0; + uiCallback(new Field(d, u, v)); + } + + this.update = function () { + queryUI(dens_prev, u_prev, v_prev); + vel_step(u, v, u_prev, v_prev, dt); + dens_step(dens, dens_prev, u, v, dt); + displayFunc(new Field(dens, u, v)); + } + this.setDisplayFunction = function(func) { + displayFunc = func; + } + + this.iterations = function() { return iterations; } + this.setIterations = function(iters) { + if (iters > 0 && iters <= 100) + iterations = iters; + } + this.setUICallback = function(callback) { + uiCallback = callback; + } + var iterations = 10; + var visc = 0.5; + var dt = 0.1; + var dens; + var dens_prev; + var u; + var u_prev; + var v; + var v_prev; + var width; + var height; + var rowSize; + var size; + var displayFunc; + function reset() + { + rowSize = width + 2; + size = (width+2)*(height+2); + dens = new Array(size); + dens_prev = new Array(size); + u = new Array(size); + u_prev = new Array(size); + v = new Array(size); + v_prev = new Array(size); + for (var i = 0; i < size; i++) + dens_prev[i] = u_prev[i] = v_prev[i] = dens[i] = u[i] = v[i] = 0; + } + this.reset = reset; + this.setResolution = function (hRes, wRes) + { + var res = wRes * hRes; + if (res > 0 && res < 1000000 && (wRes != width || hRes != height)) { + width = wRes; + height = hRes; + reset(); + return true; + } + return false; + } + this.setResolution(64, 64); +} +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +var success = true; + +function PrintResult(name, result) { + print(name + ': ' + result); +} + + +function PrintError(name, error) { + PrintResult(name, error); + success = false; +} + + +function PrintScore(score) { + if (success) { + print('----'); + print('Score (version ' + BenchmarkSuite.version + '): ' + score); + } +} + + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError, + NotifyScore: PrintScore }); diff --git a/tests/manual/v4/with.js b/tests/manual/v4/with.js new file mode 100644 index 0000000000..91ab5a0cdc --- /dev/null +++ b/tests/manual/v4/with.js @@ -0,0 +1,43 @@ +var o = { "x": 1 } +var x = 0; +with(o) { + with( { "x": 2 } ) { + print(x) + } + print(x) +} +print(x) + + +function foo() { + var x = 0; + with(o) { + with( { "x": 2 } ) { + print(x) + } + print(x) + } + print(x) +} + +print("\n") +foo(); + + +function bar() { + var x = 0; + try { + with(o) { + with( { "x": 2 } ) { + print(x) + throw 0; + } + print(x) + } + } + catch(e) {} + print(x) +} + +print("\n") +bar(); |