aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v4
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-08-21 12:44:42 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-23 08:16:24 +0200
commit9ee6bb0e14d968647350683eafbe80eed7a27058 (patch)
tree6218951a0de9e1f47ea2f76a2673d26bac85097f /src/qml/qml/v4
parent540092608b26c469d4905d3c673374542cc32940 (diff)
Increase test coverage for V4
Add test for integer operations, Math functions and exercise some previously uncovered code. Change-Id: Idff3f3672498775ac117ca98bf34b0fe96cbf760 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
index 0088741170..169e60ec41 100644
--- a/src/qml/qml/v4/qv4bindings.cpp
+++ b/src/qml/qml/v4/qv4bindings.cpp
@@ -649,6 +649,7 @@ static void testBindingResult(const QString &binding, quint16 line, quint16 colu
qtscriptResult = "exception";
} else if ((value.userType() != resultType) &&
(resultType != QMetaType::QVariant) &&
+ (resultType != qMetaTypeId<QJSValue>()) &&
(resultType != handleType)) {
// Override the QMetaType conversions to make them more JS friendly.
if (value.userType() == QMetaType::Double && (resultType == QMetaType::QString ||
@@ -708,6 +709,8 @@ static void testBindingResult(const QString &binding, quint16 line, quint16 colu
default:
if (resultType == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
v4value = QVariant(QQmlMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr());
+ } else if (resultType == qMetaTypeId<QJSValue>()) {
+ v4value = result.getjsvalueptr()->toVariant();
} else if (resultType == handleType) {
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine);
v4value = ep->v8engine()->toVariant(*result.gethandleptr(), resultType);
@@ -1834,8 +1837,19 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
{
const Register &src = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
- if (src.isUndefined()) output.setUndefined();
- else output.setint(qFloor(src.getnumber()));
+ if (src.isUndefined())
+ output.setUndefined();
+ else if (src.isNaN())
+ // output should be an int, but still NaN
+ output.setNaNType();
+ else if (src.isInf())
+ // output should be an int, but still Inf
+ output.setInfType(signBitSet(src.getnumber()));
+ else if (src.isNegativeZero())
+ // output should be an int, but still -0
+ output.setNegativeZeroType();
+ else
+ output.setint(qFloor(src.getnumber()));
}
QML_V4_END_INSTR(MathFloorNumber, unaryop)
@@ -1854,8 +1868,16 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
else if (src.isNegativeZero())
// output should be an int, but still -0
output.setNegativeZeroType();
- else
- output.setint(qCeil(src.getnumber()));
+ else {
+ // Ensure that we preserve the sign bit (Math.ceil(-0) -> -0)
+ const double input = src.getnumber();
+ const int ceiled = qCeil(input);
+ if (ceiled == 0 && signBitSet(input)) {
+ output.setNegativeZeroType();
+ } else {
+ output.setint(ceiled);
+ }
+ }
}
QML_V4_END_INSTR(MathCeilNumber, unaryop)