summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-proc-ext/test
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-06-11 18:55:39 +0900
committerKOBAYASHI Shuji <[email protected]>2019-06-11 20:33:07 +0900
commit3b9b326d3ccd21e45f498272c8bb8d3f338ccd60 (patch)
tree8ba21ff4a6dc4db791c9995ebcac8ae58acfaa66 /mrbgems/mruby-proc-ext/test
parent313059d08ca95f9fee4e2b00f218cb21ea83418c (diff)
downloadmruby-3b9b326d3ccd21e45f498272c8bb8d3f338ccd60.tar.gz
mruby-3b9b326d3ccd21e45f498272c8bb8d3f338ccd60.zip
Remove redundant colon in `Proc#inspect` (`mruby-proc-ext`)
Before this patch: $ bin/mruby -e 'p proc{}' #=> #<Proc:0x7fd5eb8206d0@-e::1> After this patch: $ bin/mruby -e 'p proc{}' #=> #<Proc:0x7fd5eb8206d0@-e:1>
Diffstat (limited to 'mrbgems/mruby-proc-ext/test')
-rw-r--r--mrbgems/mruby-proc-ext/test/proc.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/mrbgems/mruby-proc-ext/test/proc.rb b/mrbgems/mruby-proc-ext/test/proc.rb
index 1220841c8..a6321d371 100644
--- a/mrbgems/mruby-proc-ext/test/proc.rb
+++ b/mrbgems/mruby-proc-ext/test/proc.rb
@@ -1,16 +1,32 @@
##
# Proc(Ext) Test
+def enable_debug_info?
+ return @enable_debug_info unless @enable_debug_info == nil
+ begin
+ raise
+ rescue => e
+ @enable_debug_info = !e.backtrace.empty?
+ end
+end
+
assert('Proc#source_location') do
- loc = Proc.new {}.source_location
- next true if loc.nil?
- assert_equal loc[0][-7, 7], 'proc.rb'
- assert_equal loc[1], 5
+ skip unless enable_debug_info?
+ file, line = Proc.new{}.source_location
+ assert_equal __FILE__, file
+ assert_equal __LINE__ - 2, line
end
assert('Proc#inspect') do
ins = Proc.new{}.inspect
- assert_kind_of String, ins
+ if enable_debug_info?
+ metas = %w(\\ * ? [ ] { })
+ file = __FILE__.split("").map{|c| metas.include?(c) ? "\\#{c}" : c}.join
+ line = __LINE__ - 4
+ else
+ file = line = "-"
+ end
+ assert_match "#<Proc:0x*@#{file}:#{line}>", ins
end
assert('Proc#parameters') do