nf-test icon indicating copy to clipboard operation
nf-test copied to clipboard

Behaviour of `with` block

Open Midnighter opened this issue 1 year ago • 0 comments

I couldn't quite figure it out, but I see some surprising behaviour using the with block. As an example, the following code works

            def items = process.out.report
            assert items.size() == 2 : 'The number of output reports does not correspond to the number of inputs.'
            assert items.collect { meta, report -> file(model).name == "${meta.id}.txt" }.inject(true) { a, b -> a && b } : 'The reports are named unexpectedly.'

but the following code fails with a groovy.lang.MissingMethodException

            with(process.out.report) {
                assert size() == 2 : 'The number of output reports does not correspond to the number of inputs.'
                assert collect { meta, report -> file(model).name == "${meta.id}.txt" }.inject(true) { a, b -> a && b } : 'The reports are named unexpectedly.'
            }

so it seems that method dispatch works differently somehow?

Midnighter avatar Nov 28 '23 13:11 Midnighter