@@ -236,7 +236,7 @@ let (:)(a,b) = (i for i in Base.:(:)(1,10) if i%2==0)
236
236
@test Int8[ i for i = 1 : 2 ] == [2 ,4 ,6 ,8 ,10 ]
237
237
end
238
238
239
- @testset " Basic tests of Fix1, Fix2, and FixN " begin
239
+ @testset " Basic tests of Fix1, Fix2, and Fix " begin
240
240
function test_fix1 (Fix1= Base. Fix1)
241
241
increment = Fix1 (+ , 1 )
242
242
@test increment (5 ) == 6
@@ -278,49 +278,49 @@ end
278
278
test_fix2 ()
279
279
280
280
# Now, repeat the Fix1 and Fix2 tests, but
281
- # with a FixN lambda function used in their place
282
- test_fix1 ((op, arg) -> Base. FixN (op, Val (1 ), arg))
283
- test_fix2 ((op, arg) -> Base. FixN (op, Val (2 ), arg))
281
+ # with a Fix lambda function used in their place
282
+ test_fix1 ((op, arg) -> Base. Fix (op, Val (1 ), arg))
283
+ test_fix2 ((op, arg) -> Base. Fix (op, Val (2 ), arg))
284
284
285
- # Now, we do more complex tests of FixN :
286
- let FixN = Base. FixN
285
+ # Now, we do more complex tests of Fix :
286
+ let Fix = Base. Fix
287
287
@testset " Argument Fixation" begin
288
288
f = (x, y, z) -> x + y * z
289
- fixed_f1 = FixN (f, Val (1 ), 10 )
289
+ fixed_f1 = Fix (f, Val (1 ), 10 )
290
290
@test fixed_f1 (2 , 3 ) == 10 + 2 * 3
291
291
292
- fixed_f2 = FixN (f, Val (2 ), 5 )
292
+ fixed_f2 = Fix (f, Val (2 ), 5 )
293
293
@test fixed_f2 (1 , 4 ) == 1 + 5 * 4
294
294
295
- fixed_f3 = FixN (f, Val (3 ), 3 )
295
+ fixed_f3 = Fix (f, Val (3 ), 3 )
296
296
@test fixed_f3 (1 , 2 ) == 1 + 2 * 3
297
297
end
298
298
@testset " Helpful errors" begin
299
299
g = (x, y) -> x - y
300
300
# Test minimum N
301
- fixed_g1 = FixN (g, Val (1 ), 100 )
301
+ fixed_g1 = Fix (g, Val (1 ), 100 )
302
302
@test fixed_g1 (40 ) == 100 - 40
303
303
304
304
# Test maximum N
305
- fixed_g2 = FixN (g, Val (2 ), 100 )
305
+ fixed_g2 = Fix (g, Val (2 ), 100 )
306
306
@test fixed_g2 (150 ) == 150 - 100
307
307
308
308
# One over
309
- fixed_g3 = FixN (g, Val (3 ), 100 )
309
+ fixed_g3 = Fix (g, Val (3 ), 100 )
310
310
@test_throws ArgumentError fixed_g3 (1 )
311
311
@test_throws (
312
- " expected at least 2 arguments to a `FixN ` function with `N=3`" ,
312
+ " expected at least 2 arguments to a `Fix ` function with `N=3`" ,
313
313
fixed_g3 (1 )
314
314
)
315
315
end
316
316
@testset " Type Stability and Inference" begin
317
317
h = (x, y) -> x / y
318
- fixed_h = FixN (h, Val (2 ), 2.0 )
318
+ fixed_h = Fix (h, Val (2 ), 2.0 )
319
319
@test @inferred (fixed_h (4.0 )) == 2.0
320
320
end
321
321
@testset " Interaction with varargs" begin
322
322
vararg_f = (x, y, z... ) -> x + 10 * y + sum (z; init= zero (x))
323
- fixed_vararg_f = FixN (vararg_f, Val (2 ), 6 )
323
+ fixed_vararg_f = Fix (vararg_f, Val (2 ), 6 )
324
324
325
325
# Can call with variable number of arguments:
326
326
@test fixed_vararg_f (1 , 2 , 3 , 4 ) == 1 + 10 * 6 + sum ((2 , 3 , 4 ))
@@ -330,31 +330,31 @@ end
330
330
end
331
331
@testset " Errors should propagate normally" begin
332
332
error_f = (x, y) -> sin (x * y)
333
- fixed_error_f = FixN (error_f, Val (2 ), Inf )
333
+ fixed_error_f = Fix (error_f, Val (2 ), Inf )
334
334
@test_throws DomainError fixed_error_f (10 )
335
335
end
336
- @testset " Chaining FixN together" begin
337
- f1 = FixN (* , Val (1 ), " 1" )
338
- f2 = FixN (f1, Val (1 ), " 2" )
339
- f3 = FixN (f2, Val (1 ), " 3" )
336
+ @testset " Chaining Fix together" begin
337
+ f1 = Fix (* , Val (1 ), " 1" )
338
+ f2 = Fix (f1, Val (1 ), " 2" )
339
+ f3 = Fix (f2, Val (1 ), " 3" )
340
340
@test f3 () == " 123"
341
341
342
- g1 = FixN (* , Val (2 ), " 1" )
343
- g2 = FixN (g1, Val (2 ), " 2" )
344
- g3 = FixN (g2, Val (2 ), " 3" )
342
+ g1 = Fix (* , Val (2 ), " 1" )
343
+ g2 = Fix (g1, Val (2 ), " 2" )
344
+ g3 = Fix (g2, Val (2 ), " 3" )
345
345
@test g3 (" " ) == " 123"
346
346
347
347
# Equivalent to:
348
- h = FixN (* , Val (1 ), " 1" , " 2" , " 3" )
348
+ h = Fix (* , Val (1 ), " 1" , " 2" , " 3" )
349
349
@test h () == " 123"
350
350
end
351
351
352
- @testset " varargs inside FixN " begin
353
- lazy_sum = FixN (+ , Val (1 ), 1 , 2 , 3 , 4 , 5 )
352
+ @testset " varargs inside Fix " begin
353
+ lazy_sum = Fix (+ , Val (1 ), 1 , 2 , 3 , 4 , 5 )
354
354
@test lazy_sum () == sum ((1 , 2 , 3 , 4 , 5 ))
355
355
356
356
joiner (t... ) = join (t, " " )
357
- string_inside = FixN (joiner, Val (3 ), " third" , " fourth" , " fifth" )
357
+ string_inside = Fix (joiner, Val (3 ), " third" , " fourth" , " fifth" )
358
358
@test string_inside (" first" , " second" , " sixth" ) == " first second third fourth fifth sixth"
359
359
# Still type stable:
360
360
@inferred string_inside (" first" , " second" , " sixth" )
0 commit comments