1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Replace unpack with unpack1

This commit is contained in:
Nobuyoshi Nakada 2021-10-17 00:46:25 +09:00
parent cc8ff8b50d
commit 5de6e25144
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
3 changed files with 10 additions and 10 deletions

View file

@ -574,9 +574,9 @@ module Test
jobs_status(worker) jobs_status(worker)
when /^done (.+?)$/ when /^done (.+?)$/
begin begin
r = Marshal.load($1.unpack("m")[0]) r = Marshal.load($1.unpack1("m"))
rescue rescue
print "unknown object: #{$1.unpack("m")[0].dump}" print "unknown object: #{$1.unpack1("m").dump}"
return true return true
end end
result << r[0..1] unless r[0..1] == [nil,nil] result << r[0..1] unless r[0..1] == [nil,nil]
@ -587,7 +587,7 @@ module Test
return true return true
when /^record (.+?)$/ when /^record (.+?)$/
begin begin
r = Marshal.load($1.unpack("m")[0]) r = Marshal.load($1.unpack1("m"))
suite = r.first suite = r.first
key = [worker.name, suite] key = [worker.name, suite]
@ -597,18 +597,18 @@ module Test
@records[key] = [worker.start_time, Time.now] @records[key] = [worker.start_time, Time.now]
end end
rescue => e rescue => e
print "unknown record: #{e.message} #{$1.unpack("m")[0].dump}" print "unknown record: #{e.message} #{$1.unpack1("m").dump}"
return true return true
end end
record(fake_class(r[0]), *r[1..-1]) record(fake_class(r[0]), *r[1..-1])
when /^p (.+?)$/ when /^p (.+?)$/
del_jobs_status del_jobs_status
print $1.unpack("m")[0] print $1.unpack1("m")
jobs_status(worker) if @options[:job_status] == :replace jobs_status(worker) if @options[:job_status] == :replace
when /^after (.+?)$/ when /^after (.+?)$/
@warnings << Marshal.load($1.unpack("m")[0]) @warnings << Marshal.load($1.unpack1("m"))
when /^bye (.+?)$/ when /^bye (.+?)$/
after_worker_down worker, Marshal.load($1.unpack("m")[0]) after_worker_down worker, Marshal.load($1.unpack1("m"))
when /^bye$/, nil when /^bye$/, nil
if shutting_down || worker.quit_called if shutting_down || worker.quit_called
after_worker_quit worker after_worker_quit worker

View file

@ -107,7 +107,7 @@ module Test
case buf.chomp case buf.chomp
when /^loadpath (.+?)$/ when /^loadpath (.+?)$/
@old_loadpath = $:.dup @old_loadpath = $:.dup
$:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq! $:.push(*Marshal.load($1.unpack1("m").force_encoding("ASCII-8BIT"))).uniq!
when /^run (.+?) (.+?)$/ when /^run (.+?) (.+?)$/
_report "okay" _report "okay"

View file

@ -99,7 +99,7 @@ module TestParallel
break if /^p (.+?)$/ =~ buf break if /^p (.+?)$/ =~ buf
end end
assert_not_nil($1, "'p' was not found") assert_not_nil($1, "'p' was not found")
assert_match(/TestA#test_nothing_test = \d+\.\d+ s = \.\n/, $1.chomp.unpack("m")[0]) assert_match(/TestA#test_nothing_test = \d+\.\d+ s = \.\n/, $1.chomp.unpack1("m"))
end end
end end
@ -111,7 +111,7 @@ module TestParallel
end end
assert_not_nil($1, "'done' was not found") assert_not_nil($1, "'done' was not found")
result = Marshal.load($1.chomp.unpack("m")[0]) result = Marshal.load($1.chomp.unpack1("m"))
assert_equal(5, result[0]) assert_equal(5, result[0])
pend "TODO: result[1] returns 17. We should investigate it" do pend "TODO: result[1] returns 17. We should investigate it" do
assert_equal(12, result[1]) assert_equal(12, result[1])