diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml index 870540240e..058a2ad574 100644 --- a/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml +++ b/tests/auto/qml/qmlcppcodegen/data/javaScriptArgument.qml @@ -31,4 +31,86 @@ QtObject { property string c: stringMinusOne(-5) property string d: stringMinusOne(10) + + function printAmount(amount: real) : string { + var sign; + if (amount < 0) { + sign = "-"; + amount = -amount; + } else { + sign = ""; + } + return sign + amount; + } + + property string e: printAmount(10); + property string f: printAmount(-10); + + readonly property string units: " kMGT" + + function roundTo3Digits(number: real) : real { + var factor; + + if (number < 10) + factor = 100; + else if (number < 100) + factor = 10; + else + factor = 1; + + return Math.round(number * factor) / factor; + } + + function prettyPrintScale(amount: real) : string { + var sign; + if (amount < 0) { + sign = "-"; + amount = -amount; + } else { + sign = ""; + } + var unitOffset = 0; + var unitAmount = 1; + for (unitOffset = 0; amount > unitAmount * 1024; ++unitOffset, unitAmount *= 1024) {} + var result = amount / unitAmount; + return sign + roundTo3Digits(result) + units[unitOffset]; + } + + property list<string> scales: [ + prettyPrintScale(0), + + prettyPrintScale(1), + prettyPrintScale(10), + prettyPrintScale(100), + prettyPrintScale(1000), + prettyPrintScale(10000), + prettyPrintScale(100000), + prettyPrintScale(1000000), + prettyPrintScale(10000000), + prettyPrintScale(100000000), + prettyPrintScale(1000000000), + prettyPrintScale(10000000000), + prettyPrintScale(100000000000), + prettyPrintScale(1000000000000), + prettyPrintScale(10000000000000), + + prettyPrintScale(-1), + prettyPrintScale(-10), + prettyPrintScale(-100), + prettyPrintScale(-1000), + prettyPrintScale(-10000), + prettyPrintScale(-100000), + prettyPrintScale(-1000000), + prettyPrintScale(-10000000), + prettyPrintScale(-100000000), + prettyPrintScale(-1000000000), + prettyPrintScale(-10000000000), + prettyPrintScale(-100000000000), + prettyPrintScale(-1000000000000), + prettyPrintScale(-10000000000000), + ] + + function forwardArg(a: real) : string { + return prettyPrintScale(a); + } } |
