diff options
| author | Daniel Bovensiepen <[email protected]> | 2013-06-09 04:04:19 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2013-06-09 04:04:19 +0800 |
| commit | 39b6d087c7fdcc5d02d42ec0de7fca5b23b4fb77 (patch) | |
| tree | 2e0de3520b1e443f02e5cec3fe25b07939d46d0c /test/t/methods.rb | |
| parent | 83d04a539e3e765b2e82d02cfbcde4a77808eb29 (diff) | |
| download | mruby-39b6d087c7fdcc5d02d42ec0de7fca5b23b4fb77.tar.gz mruby-39b6d087c7fdcc5d02d42ec0de7fca5b23b4fb77.zip | |
Improve alias tests
Diffstat (limited to 'test/t/methods.rb')
| -rw-r--r-- | test/t/methods.rb | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/test/t/methods.rb b/test/t/methods.rb index 701ebe326..bbd8ee09d 100644 --- a/test/t/methods.rb +++ b/test/t/methods.rb @@ -1,5 +1,49 @@ ## -# Chapter 13 "Class and modules" ISO Test +# Chapter 13.3 "Methods" ISO Test + +assert('The alias statement', '13.3.6 a) 4)') do + # check aliasing in all possible ways + + def alias_test_method_original; true; end + + alias alias_test_method_a alias_test_method_original + alias :alias_test_method_b :alias_test_method_original + + assert_true(alias_test_method_original) + assert_true(alias_test_method_a) + assert_true(alias_test_method_b) +end + +assert('The alias statement (overwrite original)', '13.3.6 a) 4)') do + # check that an aliased method can be overwritten + # without side effect + + def alias_test_method_original; true; end + + alias alias_test_method_a alias_test_method_original + alias :alias_test_method_b :alias_test_method_original + + assert_true(alias_test_method_original) + + def alias_test_method_original; false; end + + assert_false(alias_test_method_original) + assert_true(alias_test_method_a) + assert_true(alias_test_method_b) +end + +assert('The alias statement', '13.3.6 a) 5)') do + # check that alias is raising NameError if + # non-existing method should be undefined + + assert_raise(NameError) do + alias new_name_a non_existing_method + end + + assert_raise(NameError) do + alias :new_name_b :non_existing_method + end +end assert('The undef statement', '13.3.7 a) 4)') do # check that undef is undefining method |
