From a74ab0c2daf1855b968ef8498b9161eadb04a386 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Tue, 12 Jun 2012 23:39:54 +0900 Subject: Kernel.eval to raise NotImplementedError --- mrblib/error.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mrblib/error.rb') diff --git a/mrblib/error.rb b/mrblib/error.rb index 5660d8235..3fa7f21e3 100644 --- a/mrblib/error.rb +++ b/mrblib/error.rb @@ -12,3 +12,10 @@ class Exception self.new(*args, &block) end end + +# ISO 15.2.37 +class ScriptError < Exception +end + +class NotImplementedError < ScriptError +end -- cgit v1.2.3 From cfd5f5157d06f9c62a04660843c3c02014d8a3a5 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Fri, 15 Jun 2012 13:06:43 +0900 Subject: Move Subclasses of ScriptError to mrblib. --- mrblib/error.rb | 8 ++++++++ src/error.c | 3 --- test/t/exception.rb | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) (limited to 'mrblib/error.rb') diff --git a/mrblib/error.rb b/mrblib/error.rb index 3fa7f21e3..1cb2b1150 100644 --- a/mrblib/error.rb +++ b/mrblib/error.rb @@ -17,5 +17,13 @@ end class ScriptError < Exception end +# ISO 15.2.38 +class SyntaxError < ScriptError +end + +# ISO 15.2.39 +class LoadError < ScriptError +end + class NotImplementedError < ScriptError end diff --git a/src/error.c b/src/error.c index 548527f07..590fad5a5 100644 --- a/src/error.c +++ b/src/error.c @@ -385,9 +385,6 @@ mrb_init_exception(mrb_state *mrb) eNameError = mrb_define_class(mrb, "NameError", mrb->eStandardError_class); /* 15.2.31 */ mrb_define_class(mrb, "NoMethodError", eNameError); /* 15.2.32 */ - // eScriptError = mrb_define_class(mrb, "ScriptError", mrb->eException_class); /* 15.2.37 */ - // mrb_define_class(mrb, "SyntaxError", eScriptError); /* 15.2.38 */ - // mrb_define_class(mrb, "LoadError", eScriptError); /* 15.2.39 */ // mrb_define_class(mrb, "SystemCallError", mrb->eStandardError_class); /* 15.2.36 */ mrb_define_class(mrb, "LocalJumpError", mrb->eStandardError_class); /* 15.2.25 */ diff --git a/test/t/exception.rb b/test/t/exception.rb index 22795161f..d7226a368 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -41,6 +41,36 @@ assert('Exception.exception', '15.2.22.4.1') do e.message == 'a' end +assert('ScriptError', '15.2.37') do + begin + raise ScriptError.new + rescue ScriptError + true + else + false + end +end + +assert('SyntaxError', '15.2.38') do + begin + raise SyntaxError.new + rescue SyntaxError + true + else + false + end +end + +assert('LoadError', '15.2.39') do + begin + raise LoadError.new + rescue LoadError + true + else + false + end +end + # Not ISO specified assert('Exception 1') do -- cgit v1.2.3 From 39f47c191557ca401b6aaceb04b395227431b62f Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Fri, 15 Jun 2012 13:55:27 +0900 Subject: remove LoadError --- mrblib/error.rb | 4 ---- test/t/exception.rb | 12 +----------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'mrblib/error.rb') diff --git a/mrblib/error.rb b/mrblib/error.rb index 1cb2b1150..5d49ec1e4 100644 --- a/mrblib/error.rb +++ b/mrblib/error.rb @@ -21,9 +21,5 @@ end class SyntaxError < ScriptError end -# ISO 15.2.39 -class LoadError < ScriptError -end - class NotImplementedError < ScriptError end diff --git a/test/t/exception.rb b/test/t/exception.rb index d7226a368..0aed0e2e6 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -24,7 +24,7 @@ end assert('Exception#message', '15.2.22.5.2') do e = Exception.exception('a') - + e.message == 'a' end @@ -61,16 +61,6 @@ assert('SyntaxError', '15.2.38') do end end -assert('LoadError', '15.2.39') do - begin - raise LoadError.new - rescue LoadError - true - else - false - end -end - # Not ISO specified assert('Exception 1') do -- cgit v1.2.3 From 955a48d964a2bbe175617880c868ca8b862da74e Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Mon, 18 Jun 2012 10:30:17 +0900 Subject: move exception definiton to mrblib --- mrblib/error.rb | 39 +++++++++++++++++++++++++++++++++++++++ src/error.c | 25 ------------------------- 2 files changed, 39 insertions(+), 25 deletions(-) (limited to 'mrblib/error.rb') diff --git a/mrblib/error.rb b/mrblib/error.rb index 5d49ec1e4..16e88eefb 100644 --- a/mrblib/error.rb +++ b/mrblib/error.rb @@ -13,6 +13,44 @@ class Exception end end +# ISO 15.2.24 +class ArgumentError < StandardError +end + +# ISO 15.2.25 +class LocalJumpError < StandardError +end + +# ISO 15.2.26 +class RangeError < StandardError +end + +class FloatDomainError < RangeError +end + +# ISO 15.2.26 +class RegexpError < StandardError +end + +# ISO 15.2.29 +class TypeError < StandardError +end + +# ISO 15.2.31 +class NameError < StandardError +end + +# ISO 15.2.32 +class NoMethodError < NameError +end + +# ISO 15.2.33 +class IndexError < StandardError +end + +class KeyError < IndexError +end + # ISO 15.2.37 class ScriptError < Exception end @@ -23,3 +61,4 @@ end class NotImplementedError < ScriptError end + diff --git a/src/error.c b/src/error.c index 1d8d2ddeb..981b2abab 100644 --- a/src/error.c +++ b/src/error.c @@ -359,9 +359,6 @@ void mrb_init_exception(mrb_state *mrb) { struct RClass *e; - struct RClass *eIndexError; - struct RClass *eRangeError; - struct RClass *eNameError; mrb->eException_class = e = mrb_define_class(mrb, "Exception", mrb->object_class); /* 15.2.22 */ mrb_define_class_method(mrb, e, "exception", mrb_instance_new, ARGS_ANY()); @@ -374,26 +371,4 @@ mrb_init_exception(mrb_state *mrb) mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */ mrb->eRuntimeError_class = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */ - - mrb_define_class(mrb, "TypeError", mrb->eStandardError_class); /* 15.2.29 */ - mrb_define_class(mrb, "ArgumentError", mrb->eStandardError_class); /* 15.2.24 */ - eIndexError = mrb_define_class(mrb, "IndexError", mrb->eStandardError_class); /* 15.2.33 */ - eRangeError = mrb_define_class(mrb, "RangeError", mrb->eStandardError_class); /* 15.2.26 */ - eNameError = mrb_define_class(mrb, "NameError", mrb->eStandardError_class); /* 15.2.31 */ - - mrb_define_class(mrb, "NoMethodError", eNameError); /* 15.2.32 */ - // mrb_define_class(mrb, "SystemCallError", mrb->eStandardError_class); /* 15.2.36 */ - mrb_define_class(mrb, "LocalJumpError", mrb->eStandardError_class); /* 15.2.25 */ - -#ifdef INCLUDE_REGEX - mrb_define_class(mrb, "RegexpError", mrb->eStandardError_class); /* 15.2.27 */ -#endif - -#ifdef INCLUDE_ENCODING - mrb_define_class(mrb, "EncodingError", mrb->eStandardError_class); -#endif - // mrb_define_class(mrb, "ZeroDivisionError", mrb->eStandardError_class); /* 15.2.30 */ - - mrb_define_class(mrb, "FloatDomainError", eRangeError); - mrb_define_class(mrb, "KeyError", eIndexError); } -- cgit v1.2.3