diff options
| author | Nobuyoshi Nakada <[email protected]> | 2014-04-21 10:48:00 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <[email protected]> | 2014-04-21 10:48:00 +0900 |
| commit | 367118b1b678b83869a9106191cb85197c9ef525 (patch) | |
| tree | 32fc73abb5956ecfcac97f8256f90181b529f0b3 /test/t | |
| parent | 4654db4fdc3c83c6feb7d6e49afa61d341a74af7 (diff) | |
| download | mruby-367118b1b678b83869a9106191cb85197c9ef525.tar.gz mruby-367118b1b678b83869a9106191cb85197c9ef525.zip | |
fix optional arguments in rhs
define optional arguments as argument variables in the rhs default
expressions, as same as mere assignment expressions.
Import ruby/ruby@01740f0c273c89f7bcff3d5014d73c8ff6fb1986
Diffstat (limited to 'test/t')
| -rw-r--r-- | test/t/syntax.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb index 2adfbc8ab..245c5c099 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -272,3 +272,20 @@ assert('method definition in cmdarg') do end true end + +assert('optional argument in the rhs default expressions') do + class OptArgInRHS + def foo + "method called" + end + def t(foo = foo) + foo + end + def t2(foo = foo()) + foo + end + end + o = OptArgInRHS.new + assert_nil(o.t) + assert_equal("method called", o.t2) +end |
