Skip to content

Commit ad80334

Browse files
viuginick1valich
authored andcommitted
tests reworked to work on 1.8.7
1 parent 4c60264 commit ad80334

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

test-base/inspect_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def test_inspect_expr_with_timeout
6969
end
7070

7171
def test_inspect_failing_expr_with_timeout
72+
if RUBY_VERSION < "1.9"
73+
@process_finished = true
74+
return
75+
end
7276
create_socket ["require 'timeout'", "puts 'test'"]
7377
run_to_line(2)
7478
send_ruby("v inspect (Timeout::timeout(0.1) { sleep 0.2 })")

test-base/test_base.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ def TestBase.find_free_port(port = 1098)
132132
end
133133

134134
def create_file(script_name, lines)
135-
script_path = File.realdirpath(File.join(TMP_DIR, script_name))
136-
135+
file = File.join(TMP_DIR, script_name)
136+
script_path = RUBY_VERSION >= "1.9" ? File.realdirpath(file) : file.to_s
137+
137138
File.open(script_path, "w") do |script|
138139
script.printf(lines.join("\n"))
139140
end
@@ -142,7 +143,9 @@ def create_file(script_name, lines)
142143

143144
def create_test2(lines)
144145
@test2_name = "test2.rb"
145-
@test2_path = create_file(@test2_name, lines).force_encoding(Encoding::UTF_8)
146+
@test2_path = create_file(@test2_name, lines)
147+
148+
@test2_path = @test2_path.force_encoding(Encoding::UTF_8) if RUBY_VERSION >= "1.9"
146149
end
147150

148151
# Creates test.rb with the given lines, set up @test_name and @test_path

test-base/variables_test.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def test_variable_local
100100
end
101101

102102
def test_variable_instance
103-
create_socket ["require_relative 'test2.rb'", "custom_object=Test2.new", "puts custom_object"]
103+
require_string = RUBY_VERSION < "1.9" ? "require" : "require_relative"
104+
105+
create_socket ["#{require_string} 'test2.rb'", "custom_object=Test2.new", "puts custom_object"]
104106
create_test2 ["class Test2", "def initialize", "@y=5", "end", "def to_s", "'test'", "end", "end"]
105107
run_to("test2.rb", 6)
106108
frame_number = 3
@@ -130,8 +132,9 @@ def test_variable_hash_with_string_keys
130132
assert_variables(read_variables, 1,
131133
{:name => "hash", :hasChildren => true})
132134
send_ruby("v i hash")
135+
expected_name = CGI::escapeHTML("'a'")
133136
assert_variables(read_variables, 2,
134-
{:name => CGI.escape_html("'a'"), :value => "z", :type => "String"})
137+
{:name => expected_name, :value => "z", :type => "String"})
135138
send_cont
136139
end
137140

@@ -228,7 +231,13 @@ def test_new_hash_presentation
228231

229232
send_ruby("v i b")
230233

231-
assert_variables(read_variables, 6,
234+
variables = []
235+
236+
read_variables.each_slice(2) do |var|
237+
variables << var
238+
end
239+
240+
assert_variables(variables.sort_by{|a| a[0].value}.flatten, 6,
232241
{:name => "key", :value => "1"},
233242
{:name => "value", :value => "A instance", :type => "A"},
234243

@@ -241,6 +250,11 @@ def test_new_hash_presentation
241250
end
242251

243252
def test_to_s_timelimit
253+
#no TracePointApi for old versions
254+
if RUBY_VERSION <= "1.9"
255+
@process_finished = true
256+
return
257+
end
244258
create_socket ['class A',
245259
'def to_s',
246260
'a = 1',

0 commit comments

Comments
 (0)