-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Rodríguez
committed
Mar 25, 2015
1 parent
863923f
commit 5f86a3d
Showing
3 changed files
with
98 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |