From 18718e065a53fd9725208e1b61c50a1a5e2e231d Mon Sep 17 00:00:00 2001 From: take_cheeze Date: Tue, 22 Apr 2014 19:19:08 +0900 Subject: Add test of $0 value in bin/mruby related to #2103 . --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mrbgems/mruby-bin-mruby') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index 22872c389..a453400fc 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -14,3 +14,19 @@ assert('regression for #1572') do o = `bin/mruby -b #{bin.path}`.strip assert_equal o, '"ok"' end + +assert '$0 value' do + script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb') + + # .rb script + script.write "p $0\n" + script.flush + assert_equal "\"#{script.path}\"", `./bin/mruby "#{script.path}"`.chomp + + # .mrb file + `./bin/mrbc -o "#{bin.path}" "#{script.path}"` + assert_equal "\"#{bin.path}\"", `./bin/mruby -b "#{bin.path}"`.chomp + + # one liner + assert_equal '"-e"', `./bin/mruby -e 'p $0'`.chomp +end -- cgit v1.2.3