From ef639a2fafc82734e7be52dce69257f7c5bdaf35 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sat, 10 Dec 2022 10:58:36 +0000 Subject: [PATCH] Add tests for prelude.rb --- test/console/debugger_method_test.rb | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/console/debugger_method_test.rb b/test/console/debugger_method_test.rb index 8cc32198f..1a7ce5406 100644 --- a/test/console/debugger_method_test.rb +++ b/test/console/debugger_method_test.rb @@ -177,4 +177,36 @@ def test_step_in_stops_the_program end end end + + class PreludeTest < ConsoleTestCase + def program + <<~RUBY + 1| require "debug/prelude" + 2| debugger_source = Kernel.method(:debugger).source_location + 3| a = 100 + 4| b = 20 + 5| debugger + 6| + 7| __END__ + RUBY + end + + def test_prelude_defines_debugger_statements + run_ruby(program, options: "-Ilib") do + assert_line_num(5) + type "a + b" + assert_line_text(/120/) + type "c" + end + end + + def test_prelude_doesnt_override_debugger + run_ruby(program, options: "-Ilib -rdebug") do + assert_line_num(5) + type "debugger_source" + assert_line_text(/debug\/session\.rb/) + type "c" + end + end + end end