mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
20 lines
439 B
Swift
20 lines
439 B
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import DifferentiationUnittest
|
|
|
|
var RepeatedCallsTests = TestSuite("RepeatedCalls")
|
|
|
|
RepeatedCallsTests.testWithLeakChecking("Repeat") {
|
|
func mul2(_ x: Tracked<Float>) -> Tracked<Float> {
|
|
return 2 * x
|
|
}
|
|
func mul4(_ x: Tracked<Float>) -> Tracked<Float> {
|
|
return mul2(mul2(x))
|
|
}
|
|
expectEqual(4, gradient(at: 0, of: mul4))
|
|
}
|
|
|
|
runAllTests()
|