summaryrefslogtreecommitdiffhomepage
path: root/test/t/syntax.rb
diff options
context:
space:
mode:
authortake_cheeze <[email protected]>2014-03-28 13:02:52 +0900
committertake_cheeze <[email protected]>2014-03-28 13:02:52 +0900
commit22393503487163f9fbffe1f2169d156ba2b8c0fa (patch)
treec01036b6e1081765e6def07c533fed29e52c6cba /test/t/syntax.rb
parentbe58f1c9ab7db9451f9096f717ce650b9700c076 (diff)
downloadmruby-22393503487163f9fbffe1f2169d156ba2b8c0fa.tar.gz
mruby-22393503487163f9fbffe1f2169d156ba2b8c0fa.zip
Add test for backquote.
* Implement code generation of NODE_DXSTR. * Fix NOVAL NODE_XSTR.
Diffstat (limited to 'test/t/syntax.rb')
-rw-r--r--test/t/syntax.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index 3569193bc..fac73aa7b 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -226,3 +226,31 @@ assert('splat in case statement') do
assert_equal [5], resultb
assert_equal [3,8], resultc
end
+
+assert('External command execution.') do
+ class << Kernel
+ sym = '`'.to_sym
+ alias_method :old_cmd, sym
+
+ results = []
+ define_method(sym) do |str|
+ results.push str
+ str
+ end
+
+ `test` # NOVAL NODE_XSTR
+ `test dynamic #{sym}` # NOVAL NODE_DXSTR
+ assert_equal ['test', 'test dynamic `'], results
+
+ t = `test` # VAL NODE_XSTR
+ assert_equal 'test', t
+ assert_equal ['test', 'test dynamic `', 'test'], results
+
+ t = `test dynamic #{sym}` # VAL NODE_DXSTR
+ assert_equal 'test dynamic `', t
+ assert_equal ['test', 'test dynamic `', 'test', 'test dynamic `'], results
+
+ alias_method sym, :old_cmd
+ end
+ true
+end