diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-02 17:25:34 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-02 17:25:34 +0900 |
| commit | f78d2fad31a2e524da6d9975872240c695f7c124 (patch) | |
| tree | 1d67b97cfcedeba4dfc3941701d49c3fc6d38d24 /test/t/module.rb | |
| parent | e65d4938f373132f2ab5c75533e0bd18e188f9bc (diff) | |
| parent | 7752d2ab43088aeb5e43d1dab764cba7428cd40c (diff) | |
| download | mruby-f78d2fad31a2e524da6d9975872240c695f7c124.tar.gz mruby-f78d2fad31a2e524da6d9975872240c695f7c124.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'test/t/module.rb')
| -rw-r--r-- | test/t/module.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/t/module.rb b/test/t/module.rb index 854be75a5..a5331e96d 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -5,6 +5,53 @@ assert('Module', '15.2.2') do Module.class == Class end +assert('Module#const_defined?', '15.2.2.4.20') do + module Test4ConstDefined + Const4Test4ConstDefined = true + end + + Test4ConstDefined.const_defined?(:Const4Test4ConstDefined) and + not Test4ConstDefined.const_defined?(:NotExisting) +end + +assert('Module#const_get', '15.2.2.4.21') do + module Test4ConstGet + Const4Test4ConstGet = 42 + end + + Test4ConstGet.const_get(:Const4Test4ConstGet) == 42 +end + +assert('Module.const_missing', '15.2.2.4.22') do + e1 = nil + + module Test4ConstMissing + def const_missing(sym) + # ATM this redirect doesn't work + puts "PLEASE GO TO TEST CASE Module.const_missing!" + puts "IT IS WORKING NOW!! PLEASE FINALIZE." + puts "Thanks :)" + end + end + + begin + Test4ConstMissing.const_get(:ConstDoesntExist) + rescue => e2 + e1 = e2 + end + + e1.class == NameError +end + +assert('Module#const_get', '15.2.2.4.23') do + module Test4ConstSet + Const4Test4ConstSet = 42 + end + + Test4ConstSet.const_set(:Const4Test4ConstSet, 23) + Test4ConstSet.const_get(:Const4Test4ConstSet) == 23 +end + # TODO not implemented ATM assert('Module.constants', '15.2.2') do # TODO not implemented ATM assert('Module.nesting', '15.2.2') do |
