diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml new file mode 100644 index 0000000000..870540240e --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml @@ -0,0 +1,34 @@ +pragma Strict +import QtQml + +QtObject { + function absMinusOne(amount: real) : real { + // Access it before the condition below, to make sure we still get the original + var minusOne = amount !== 0 ? -1 : 0; + + // The condition causes the original arguemnt to be overwritten rather than a new + // register to be allocated + if (amount < 0) + amount = -amount; + + return amount + minusOne; + } + + property real a: absMinusOne(-5) + property real b: absMinusOne(10) + + function stringMinusOne(amount: real) : string { + // Access it before the condition below, to make sure we still get the original + var minusOne = amount !== 0 ? -1 : 0; + + // The condition causes the original arguemnt to be overwritten rather than a new + // register to be allocated + if (amount < 0) + amount = -amount + "t"; + + return amount + minusOne; + } + + property string c: stringMinusOne(-5) + property string d: stringMinusOne(10) +} |
