File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -338,16 +338,17 @@ file.
338338"""
339339atreplinit (f:: Function ) = (unshift! (repl_hooks, f); nothing )
340340
341- function _atreplinit (repl)
341+ function __atreplinit (repl)
342342 for f in repl_hooks
343343 try
344344 f (repl)
345345 catch err
346- show (STDERR, err)
346+ showerror (STDERR, err)
347347 println (STDERR)
348348 end
349349 end
350350end
351+ _atreplinit (repl) = eval (Main, :($ __atreplinit ($ repl)))
351352
352353function _start ()
353354 empty! (ARGS )
Original file line number Diff line number Diff line change @@ -548,3 +548,19 @@ let io = IOBuffer()
548548 end , [])
549549 @test length (String (take! (io))) < 1500
550550end
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