Home | History | Annotate | Download | only in qscriptengine

Lines Matching defs:eng

65 static QScriptValue myFunction(QScriptContext*, QScriptEngine* eng)
67 return eng->nullValue();
70 static QScriptValue myFunctionWithArg(QScriptContext*, QScriptEngine* eng, void* arg)
73 return QScriptValue(eng, *result);
76 static QScriptValue myFunctionThatReturns(QScriptContext*, QScriptEngine* eng)
78 return QScriptValue(eng, 42);
94 QScriptEngine eng;
96 QScriptValue fun = eng.newFunction(myFunction);
114 QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true);
122 QScriptValue fun = eng.newFunction(myFunctionWithArg, reinterpret_cast<void*>(&expectedResult));
138 QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true);
146 QScriptValue proto = eng.newObject();
147 QScriptValue fun = eng.newFunction(myFunction, proto);
154 QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true);
168 QScriptValue fun = eng.newFunction(myFunctionThatReturns);
179 QScriptValue fun = eng.newFunction(myFunctionThatReturnsWithoutEngine);
185 QCOMPARE(result.engine(), &eng);
193 QScriptValue fun = eng.newFunction(myFunctionThatReturnsWrongEngine, reinterpret_cast<void*>(&wrongEngine));
241 QScriptEngine eng;
243 eng.reportAdditionalMemoryCost(0);
244 eng.reportAdditionalMemoryCost(10);
245 eng.reportAdditionalMemoryCost(1000);
246 eng.reportAdditionalMemoryCost(10000);
247 eng.reportAdditionalMemoryCost(100000);
248 eng.reportAdditionalMemoryCost(1000000);
249 eng.reportAdditionalMemoryCost(10000000);
250 eng.reportAdditionalMemoryCost(-1);
251 eng.reportAdditionalMemoryCost(-1000);
252 QScriptValue obj = eng.evaluate("new Object");
253 eng.collectGarbage();
275 QScriptEngine eng;
286 QScriptValue expected = eng.evaluate(code);
288 QScriptValue ret = eng.evaluate(program);
295 QVERIFY(eng.evaluate(sameProgram).equals(expected));
300 QVERIFY(eng.evaluate(sameProgram2).equals(expected));
304 QVERIFY(!eng.evaluate(differentProgram).equals(expected));
312 QScriptValue ret = eng.evaluate(program);
317 QScriptValue ret = eng.evaluate(program);
320 eng.evaluate("a = 456");
322 QScriptValue ret = eng.evaluate(program);
332 QScriptValue createCounter = eng.evaluate(program);
354 double expected = eng.evaluate(program).toNumber();
368 QScriptValue ret = eng.evaluate(program);
467 QScriptEngine eng;
468 QVERIFY(!eng.toObject(eng.undefinedValue()).isValid());
469 QVERIFY(!eng.toObject(eng.nullValue()).isValid());
470 QVERIFY(!eng.toObject(QScriptValue()).isValid());
474 QScriptValue tmp = eng.toObject(falskt);
483 QScriptValue tmp = eng.toObject(sant);
492 QScriptValue tmp = eng.toObject(number);
499 QScriptValue str = QScriptValue(&eng, QString("ciao"));
501 QScriptValue tmp = eng.toObject(str);
507 QScriptValue object = eng.evaluate("new Object");
509 QScriptValue tmp = eng.toObject(object);
559 QScriptEngine eng;
560 QScriptValue array = eng.newArray();
570 QCOMPARE(array.prototype().strictlyEquals(eng.evaluate("Array.prototype")), true);
572 QScriptValue arrayWithSize = eng.newArray(42);
580 QScriptValue ret = eng.evaluate("[].splice(0, 0, 'a')");
585 QScriptValue ret = eng.evaluate("['a'].splice(0, 1, 'b')");
590 QScriptValue ret = eng.evaluate("['a', 'b'].splice(0, 1, 'c')");
595 QScriptValue ret = eng.evaluate("['a', 'b', 'c'].splice(0, 2, 'd')");
600 QScriptValue ret = eng.evaluate("['a', 'b', 'c'].splice(1, 2, 'd', 'e', 'f')");
608 QScriptEngine eng;
609 QScriptValue fun = eng.evaluate("(function foo () { return null; });");
610 QVERIFY(!eng.uncaughtException().isValid());
612 QScriptValue throwFun = eng.evaluate("( function() { throw new Error('Pong'); });");
615 eng.evaluate("a = 10");
616 QVERIFY(!eng.hasUncaughtException());
617 QVERIFY(!eng.uncaughtException().isValid());
620 eng.evaluate("1 = 2");
621 QVERIFY(eng.hasUncaughtException());
622 eng.clearExceptions();
623 QVERIFY(!eng.hasUncaughtException());
628 QVERIFY(eng.hasUncaughtException());
629 QScriptValue exception = eng.uncaughtException();
632 QVERIFY(eng.hasUncaughtException());
633 QVERIFY(eng.uncaughtException().strictlyEquals(exception));
635 eng.clearExceptions();
639 QVERIFY(eng.hasUncaughtException());
640 QScriptValue exception = eng.uncaughtException();
642 QVERIFY(eng.hasUncaughtException());
643 QVERIFY(!exception.strictlyEquals(eng.uncaughtException()));
646 eng.evaluate("throwFun = (function foo () { throw new Error('bla') });");
647 eng.evaluate("1;\nthrowFun();");
648 QVERIFY(eng.hasUncaughtException());
649 QCOMPARE(eng.uncaughtExceptionLineNumber(), 1);
650 eng.clearExceptions();
651 QVERIFY(!eng.hasUncaughtException());
654 QScriptValue ret = eng.evaluate("a = 10;\nb = 20;\n0 = 0;\n",
657 QVERIFY(eng.hasUncaughtException());
658 QCOMPARE(eng.uncaughtExceptionLineNumber(), x + 2);
659 QVERIFY(eng.uncaughtException().strictlyEquals(ret));
660 QVERIFY(eng.hasUncaughtException());
661 QVERIFY(eng.uncaughtException().strictlyEquals(ret));
663 QCOMPARE(eng.uncaughtExceptionBacktrace().join(""), backtrace);
665 QVERIFY(eng.hasUncaughtException());
666 QCOMPARE(eng.uncaughtExceptionLineNumber(), x + 2);
667 QVERIFY(eng.uncaughtException().strictlyEquals(ret));
668 eng.clearExceptions();
669 QVERIFY(!eng.hasUncaughtException());
670 QCOMPARE(eng.uncaughtExceptionLineNumber(), -1);
671 QVERIFY(!eng.uncaughtException().isValid());
672 eng.evaluate("2 = 3");
673 QVERIFY(eng.hasUncaughtException());
676 QVERIFY(eng.hasUncaughtException());
677 QVERIFY(eng.uncaughtException().strictlyEquals(ret2));
678 QCOMPARE(eng.uncaughtExceptionLineNumber(), 1);
679 eng.clearExceptions();
680 QVERIFY(!eng.hasUncaughtException());
681 eng.evaluate("1 + 2");
682 QVERIFY(!eng.hasUncaughtException());
688 QScriptEngine eng;
690 QScriptValue date = eng.newDate(0);
698 QCOMPARE(date.prototype().strictlyEquals(eng.evaluate("Date.prototype")), true);
702 QScriptValue date = eng.newDate(dt);
709 QCOMPARE(date.prototype().strictlyEquals(eng.evaluate("Date.prototype")), true);
715 QScriptValue date = eng.newDate(dt);
721 QScriptValue ret = eng.evaluate("Date.parse()");
727 QScriptValue ret = eng.evaluate("var x = new Date(); var s = x.toString(); s == new Date(Date.parse(s)).toString()");