Add a test to verify .with() applies to sinks (#3071)
This commit is contained in:
parent
f94708d202
commit
99f32a45e5
@ -302,6 +302,7 @@
|
||||
// Apply positional arguments.
|
||||
#let add(x, y) = x + y
|
||||
#test(add.with(2)(3), 5)
|
||||
#test(add.with(2, 3)(), 5)
|
||||
#test(add.with(2).with(3)(), 5)
|
||||
#test((add.with(2))(4), 6)
|
||||
#test((add.with(2).with(3))(), 5)
|
||||
@ -313,3 +314,14 @@
|
||||
#let inc2 = inc.with(y: 2)
|
||||
#test(inc2(2), 4)
|
||||
#test(inc2(2, y: 4), 6)
|
||||
|
||||
// Apply arguments to an argument sink.
|
||||
#let times(..sink) = {
|
||||
let res = sink.pos().product()
|
||||
if sink.named().at("negate", default: false) { res *= -1 }
|
||||
res
|
||||
}
|
||||
#test((times.with(2, negate: true).with(5))(), -10)
|
||||
#test((times.with(2).with(5).with(negate: true))(), -10)
|
||||
#test((times.with(2).with(5, negate: true))(), -10)
|
||||
#test((times.with(2).with(negate: true))(5), -10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user