feat(utils.spec.qml): add tests on times

This commit is contained in:
Ronan Abhamon 2016-10-19 15:08:08 +02:00
parent 5d65384b97
commit 0f48d2047d

View file

@ -95,6 +95,33 @@ TestCase {
// -----------------------------------------------------------------
function test_times1_data () {
return [
{
cb: function (n) { return n * 2 },
n: 10,
output: [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 ]
},
{
cb: function (n) { return n % 2 ? 1 : 0 },
n: 10,
output: [ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ]
}
]
}
function test_times1 (data) {
compare(Utils.times(data.n, data.cb), data.output)
}
function test_times2 () {
var sum = 0
Utils.times(5, function (i) { sum += (i + 1) })
compare(sum, 15)
}
// -----------------------------------------------------------------
function test_isString_data () {
return [
{ input: 'foo', output: true },