Are these "tuple splat" parameterized tests legit?


This is one of the use cases of forEach.

let array = [
  (1, 2, 3),
  (4, 5, 6),
  (7, 8, 9)
]
func f1(_: (x: Int, y: Int, z: Int)) { }
func f2(x: Int, y: Int, z: Int) { }
array.forEach(f1)
array.forEach(f2)

The first form, which takes a tuple, will yield a usage warning for mismatched labels. Tests do not care about labels.

@Test(
  arguments: [
    (a: 1, b: 2, c: 3),
    (a: 4, b: 5, c: 6),
    (a: 7, b: 8, c: 9)
  ]
) func t1(x: Int, y: Int, z: Int) { }

@Test(
  arguments: [
    (1, 2, 3),
    (4, 5, 6),
    (7, 8, 9)
  ]
) func t2(x: Int, y: Int, z: Int) { }
1 Like