Add a test to verify .with() applies to sinks (#3071)

This commit is contained in:
Leedehai 2023-12-28 08:32:51 -05:00 committed by GitHub
parent f94708d202
commit 99f32a45e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)