Skip to content

Commit

Permalink
Fix a TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rodríguez committed Mar 25, 2015
1 parent 863923f commit 5f86a3d
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 78 deletions.
35 changes: 33 additions & 2 deletions test/commands/set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def program
2: byebug
3:
4: z = 4
5: z + 1
6: end
5: z += 1
6: z + 1
7: end
EOC
end

Expand Down Expand Up @@ -127,6 +128,36 @@ def test_verbose_prints_tracepoint_api_event_information
Byebug.verbose = false
end

def test_set_linetrace_enables_tracing_program_execution
with_setting :linetrace, false do
enter 'set linetrace', 'cont 5'
debug_code(program)

check_output_includes \
'linetrace is on', "Tracing: #{example_path}:5 z += 1"
end
end

def test_set_nolinetrace_stops_tracing_program_execution
with_setting :linetrace, true do
enter 'cont 5', 'set nolinetrace'
debug_code(program)

check_output_includes "Tracing: #{example_path}:5 z += 1"
check_output_doesnt_include "Tracing: #{example_path}:6 z + 1"
end
end

def test_basename_setting_affects_tracing_output
with_setting :basename, true do
enter 'set linetrace', 'cont 5', 'set nolinetrace'
debug_code(program)

check_output_includes \
"Tracing: #{File.basename(example_path)}:5 z += 1"
end
end

def test_set_without_arguments_shows_help_for_set_command
enter 'set'
debug_code(program)
Expand Down
76 changes: 0 additions & 76 deletions test/commands/trace_test.rb

This file was deleted.

65 changes: 65 additions & 0 deletions test/commands/tracevar_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module Byebug
#
# Tests gloabal variable tracing functionality.
#
class TracevarTest < TestCase
def program
strip_line_numbers <<-EOC
1: module Byebug
2: #
3: # Toy class to test global variable tracing
4: #
5: class #{example_class}
6: def with_verbose(value)
7: previous = $VERBOSE
8: $VERBOSE = value
9: yield
10: ensure
11: $VERBOSE = previous
12: end
13: end
14:
15: #{example_class}.new.with_verbose(true) do
16: byebug
17: $VERBOSE = false
18: $VERBOSE ||= true
19: $VERBOSE &&= false
20: end
21: end
EOC
end

def test_tracevar_tracks_global_variables
enter 'tracevar $VERBOSE', 'cont 19', 'untracevar $VERBOSE'
debug_code(program)

check_output_includes \
"traced global variable '$VERBOSE' has value 'false'",
"traced global variable '$VERBOSE' has value 'true'"
end

def test_tracevar_stop_makes_program_stop_when_global_var_changes
enter 'tracevar $VERBOSE stop', 'cont 19', 'untracevar $VERBOSE'

debug_code(program) { assert_equal 18, state.line }
end

def test_tracevar_nostop_does_not_stop_when_global_var_changes
enter 'tracevar $VERBOSE nostop', 'cont 19', 'untracevar $VERBOSE'

debug_code(program) { assert_equal 19, state.line }
end

def test_tracevar_shows_an_error_message_if_no_global_variable_is_specified
enter 'tracevar'
debug_code(program)
check_error_includes('tracevar needs a global variable name')
end

def test_tracevar_shows_an_error_message_if_there_is_no_such_global_var
enter 'tracevar $FOO'
debug_code(program)
check_error_includes "'$FOO' is not a global variable."
end
end
end

0 comments on commit 5f86a3d

Please sign in to comment.