test/eval_test.rb in byebug-2.1.1 vs test/eval_test.rb in byebug-2.2.0
- old
+ new
@@ -1,9 +1,18 @@
require_relative 'test_helper'
-class TestEval < TestDsl::TestCase
+class EvalTest
+ def sum(a,b)
+ a + b
+ end
+ def inspect
+ raise "Broken"
+ end
+end
+
+class TestEval < TestDsl::TestCase
it 'must evaluate an expression' do
enter 'eval 3 + 2'
debug_file 'eval'
check_output_includes '5'
end
@@ -19,12 +28,12 @@
debug_file 'eval'
check_output_includes '5'
end
it 'must work when inspect raises an exception' do
- enter 'c 14', 'p @foo'
- debug_file('eval') { $state.line.must_equal 14 }
+ enter 'c 4', 'p @foo'
+ debug_file('eval') { $state.line.must_equal 4 }
check_output_includes 'RuntimeError Exception: Broken'
end
describe 'autoeval' do
it 'must be set by default' do
@@ -47,11 +56,11 @@
temporary_change_hash Byebug.settings, :stack_trace_on_error, true
it 'must show a stack trace' do
enter 'eval 2 / 0'
debug_file 'eval'
- check_output_includes /\s*from \S+:in \`eval\'/
+ check_output_includes(/\s*from \S+:in \`eval\'/)
check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
end
end
describe 'when disabled' do
@@ -59,10 +68,10 @@
it 'must only show exception' do
enter 'eval 2 / 0'
debug_file 'eval'
check_output_includes 'ZeroDivisionError Exception: divided by 0'
- check_output_doesnt_include /\S+:\d+:in `eval':divided by 0/
+ check_output_doesnt_include(/\S+:\d+:in `eval':divided by 0/)
end
end
end
describe 'pp' do