File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -338,16 +338,17 @@ file.
338
338
"""
339
339
atreplinit (f:: Function ) = (unshift! (repl_hooks, f); nothing )
340
340
341
- function _atreplinit (repl)
341
+ function __atreplinit (repl)
342
342
for f in repl_hooks
343
343
try
344
344
f (repl)
345
345
catch err
346
- show (STDERR, err)
346
+ showerror (STDERR, err)
347
347
println (STDERR)
348
348
end
349
349
end
350
350
end
351
+ _atreplinit (repl) = eval (Main, :($ __atreplinit ($ repl)))
351
352
352
353
function _start ()
353
354
empty! (ARGS )
Original file line number Diff line number Diff line change @@ -548,3 +548,19 @@ let io = IOBuffer()
548
548
end , [])
549
549
@test length (String (take! (io))) < 1500
550
550
end
551
+
552
+ function test_replinit ()
553
+ stdin_write, stdout_read, stdout_read, repl = fake_repl ()
554
+ # Relies on implementation detail to make sure we only have the single
555
+ # replinit callback we want to test.
556
+ saved_replinit = copy (Base. repl_hooks)
557
+ slot = Ref (false )
558
+ # Create a closure from a newer world to check if `_atreplinit`
559
+ # can run it correctly
560
+ atreplinit (eval (:(repl:: Base.REPL.LineEditREPL -> ($ slot[] = true ))))
561
+ Base. _atreplinit (repl)
562
+ @test slot[]
563
+ @test_throws MethodError Base. repl_hooks[1 ](repl)
564
+ copy! (Base. repl_hooks, saved_replinit)
565
+ end
566
+ test_replinit ()
You can’t perform that action at this time.
0 commit comments