11module TestCoreFunctionUtils
22
3- import Test
3+ using Test : Test
44import CTBase. Core
55
66const VERBOSE = isdefined (Main, :TestOptions ) ? Main. TestOptions. VERBOSE : true
77const SHOWTIMING = isdefined (Main, :TestOptions ) ? Main. TestOptions. SHOWTIMING : true
88
99function test_function_utils ()
1010 Test. @testset verbose = VERBOSE showtiming = SHOWTIMING " to_out_of_place" begin
11-
1211 Test. @testset " to_out_of_place - basic conversion" begin
13- f! (r, x) = (r[1 ] = sin (x); r[2 ] = cos (x))
12+ f! (r, x) = (r[1 ]= sin (x); r[2 ]= cos (x))
1413 f = Core. to_out_of_place (f!, 2 )
1514 result = f (π / 4 )
1615 Test. @test result isa Vector
@@ -28,7 +27,7 @@ function test_function_utils()
2827 end
2928
3029 Test. @testset " to_out_of_place - with kwargs" begin
31- h! (r, x; scale= 1.0 ) = (r[1 ] = x * scale; r[2 ] = x^ 2 * scale)
30+ h! (r, x; scale= 1.0 ) = (r[1 ]= x * scale; r[2 ]= x^ 2 * scale)
3231 h = Core. to_out_of_place (h!, 2 )
3332 Test. @test h (2.0 )[1 ] ≈ 2.0
3433 Test. @test h (2.0 )[2 ] ≈ 4.0
@@ -37,15 +36,15 @@ function test_function_utils()
3736 end
3837
3938 Test. @testset " to_out_of_place - multiple arguments" begin
40- k! (r, x, y) = (r[1 ] = x + y; r[2 ] = x * y)
39+ k! (r, x, y) = (r[1 ]= x + y; r[2 ]= x * y)
4140 k = Core. to_out_of_place (k!, 2 )
4241 result = k (3.0 , 4.0 )
4342 Test. @test result[1 ] ≈ 7.0
4443 Test. @test result[2 ] ≈ 12.0
4544 end
4645
4746 Test. @testset " to_out_of_place - custom type" begin
48- m! (r, x) = (r[1 ] = x + 1 ; r[2 ] = x + 2 )
47+ m! (r, x) = (r[1 ]= x + 1 ; r[2 ]= x + 2 )
4948 m = Core. to_out_of_place (m!, 2 ; T= Int)
5049 result = m (5 )
5150 Test. @test result isa Vector{Int}
@@ -58,13 +57,17 @@ function test_function_utils()
5857 end
5958
6059 Test. @testset " to_out_of_place - larger output" begin
61- big! (r, x) = (for i in 1 : 5 ; r[i] = x * i; end )
60+ big! (r, x) = (
61+ for i in 1 : 5
62+ ;
63+ r[i] = x * i;
64+ end
65+ )
6266 big = Core. to_out_of_place (big!, 5 )
6367 result = big (2.0 )
6468 Test. @test length (result) == 5
6569 Test. @test result == [2.0 , 4.0 , 6.0 , 8.0 , 10.0 ]
6670 end
67-
6871 end
6972 return nothing
7073end
0 commit comments