summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-04-23 07:05:48 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-04-23 07:05:48 +0900
commitf2204ee524810f3598d97b7b8c184af98d2f94d9 (patch)
tree3dd8efaeb2bb703d4947d2dbd9482f2359f77aa4
parent68027317b0401f621de9d89676160522b3238b07 (diff)
parent18718e065a53fd9725208e1b61c50a1a5e2e231d (diff)
downloadmruby-f2204ee524810f3598d97b7b8c184af98d2f94d9.tar.gz
mruby-f2204ee524810f3598d97b7b8c184af98d2f94d9.zip
Merge pull request #2105 from take-cheeze/issue_2103_test
Add test of $0 value in bin/mruby related to #2103 .
-rw-r--r--mrbgems/mruby-bin-mruby/bintest/mruby.rb16
1 files changed, 16 insertions, 0 deletions
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