Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug that guard catch all exceptions, otherwise else was not s…

…pecified.
  • Loading branch information...
commit 4fa0dcad44447052379d3e1632d7c9a19dd605d0 1 parent 4f19f0a
@kiyoka kiyoka authored
View
3  lib/nendo/experimental.nnd
@@ -142,7 +142,8 @@
(syntax-rules (=> ...)
((%guard-clause (var clauses ...))
(cond
- clauses ...))))
+ clauses ...
+ (#t (raise var))))))
(define-syntax guard
(syntax-rules ()
View
104 lib/nendo/experimental.nndc
@@ -2450,24 +2450,82 @@ trampCall(
))
end ,
begin
- embedBacktraceInfo( "./lib/nendo/experimental.nnd", 91 );
- trampCall( self._map_METHOD( 'map',
+ embedBacktraceInfo( "", 1 );
+ trampCall( self._append_METHOD( 'append',
begin
- if @global_lisp_binding.has_key?('_map') then
- trampCall(@_map)
- else raise NameError.new( "Error: undefined variable _map", "_map" ) end
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:91"] + __e.backtrace ) ; raise __e
+ if @global_lisp_binding.has_key?('_append') then
+ trampCall(@_append)
+ else raise NameError.new( "Error: undefined variable _append", "_append" ) end
+ rescue => __e ; __e.set_backtrace( [":1"] + __e.backtrace ) ; raise __e
end ,
[
- Proc.new { |_clauses|
- begin
- trampCall(_clauses)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:145"] + __e.backtrace ) ; raise __e
- end
- } ,
begin
- trampCall(_clauses)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:145"] + __e.backtrace ) ; raise __e
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 91 );
+ trampCall( self._map_METHOD( 'map',
+ begin
+ if @global_lisp_binding.has_key?('_map') then
+ trampCall(@_map)
+ else raise NameError.new( "Error: undefined variable _map", "_map" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:91"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ Proc.new { |_clauses|
+ begin
+ trampCall(_clauses)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:145"] + __e.backtrace ) ; raise __e
+ end
+ } ,
+ begin
+ trampCall(_clauses)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:145"] + __e.backtrace ) ; raise __e
+ end
+ ]
+ ))
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
+ _cons(
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
+ _cons(
+ true ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
+ _cons(
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
+ _cons(
+ begin
+ embedBacktraceInfo( "dynamic S-expression ( no source )", 1 );
+ trampCall( callProcedure( '__rename__gensym__29d1958308f04161c7005d22e2e7d31864eae2bc_30155', '_rename__gensym__29d1958308f04161c7005d22e2e7d31864eae2bc_30155',
+ begin
+ trampCall(__rename__gensym__29d1958308f04161c7005d22e2e7d31864eae2bc_30155)
+ rescue => __e ; __e.set_backtrace( ["dynamic S-expression ( no source ):1"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ :"raise"
+ ]
+ ))
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
+ _cons(
+ begin
+ trampCall(_var)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:146"] + __e.backtrace ) ; raise __e
+ end ,
+ Cell.new()
+ )
+ end
+ )
+ end ,
+ Cell.new()
+ )
+ end
+ )
+ end ,
+ Cell.new()
+ )
end
]
))
@@ -2641,7 +2699,7 @@ trampCall(
end
)
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:152"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:153"] + __e.backtrace )
raise __e
end
)
@@ -2742,7 +2800,7 @@ trampCall(
_cons(
begin
trampCall(_var_MIMARKclauses)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:158"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:159"] + __e.backtrace ) ; raise __e
end ,
Cell.new()
)
@@ -2772,7 +2830,7 @@ trampCall(
_cons(
begin
trampCall(_var_MIMARKclauses)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:158"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:159"] + __e.backtrace ) ; raise __e
end ,
Cell.new()
)
@@ -2792,12 +2850,12 @@ trampCall(
Proc.new { |_body|
begin
trampCall(_body)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:159"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:160"] + __e.backtrace ) ; raise __e
end
} ,
begin
trampCall(_body)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:159"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:160"] + __e.backtrace ) ; raise __e
end
]
))
@@ -3123,7 +3181,7 @@ trampCall(
end
)
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
)
@@ -3301,7 +3359,7 @@ trampCall(
_cons(
begin
trampCall(_cleanup)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:176"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:177"] + __e.backtrace ) ; raise __e
end ,
begin
embedBacktraceInfo( "./lib/nendo/experimental.nnd", 71 );
@@ -3391,7 +3449,7 @@ trampCall(
_cons(
begin
trampCall(_body)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:175"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:176"] + __e.backtrace ) ; raise __e
end ,
Cell.new()
)
@@ -3405,7 +3463,7 @@ trampCall(
_cons(
begin
trampCall(_cleanup)
- rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:176"] + __e.backtrace ) ; raise __e
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:177"] + __e.backtrace ) ; raise __e
end ,
Cell.new()
)
View
120 lib/nendo/test.nndc
@@ -59,13 +59,13 @@ trampCall(
end
} ; ___lambda.call(
begin
- ___lambda = lambda { |___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30112|
+ ___lambda = lambda { |___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30113|
if (
begin
embedBacktraceInfo( "./lib/nendo/test.nnd", 175 );
_null_QUMARK(
begin
- trampCall(___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30112)
+ trampCall(___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30113)
rescue => __e ; __e.set_backtrace( [":1"] + __e.backtrace ) ; raise __e
end
)
@@ -84,7 +84,7 @@ trampCall(
end ,
[
begin
- trampCall(___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30112)
+ trampCall(___gensym__da296d116d489ba951dcd8991bd44f36a977a621_30113)
rescue => __e ; __e.set_backtrace( [":1"] + __e.backtrace ) ; raise __e
end
]
@@ -1384,7 +1384,119 @@ trampCall(
end
end
else
- Cell.new()
+ if (
+ true
+ ) then
+ begin
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 132 );
+ trampCall( self.__PAMARKraise_METHOD( '%raise',
+ begin
+ if @global_lisp_binding.has_key?('__PAMARKraise') then
+ trampCall(@__PAMARKraise)
+ else raise NameError.new( "Error: undefined variable __PAMARKraise", "__PAMARKraise" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:132"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ begin
+ trampCall(_exc)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/test.nnd:133"] + __e.backtrace ) ; raise __e
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/test.nnd", 76 );
+ trampCall( self._sprintf_METHOD( 'sprintf',
+ begin
+ if @global_lisp_binding.has_key?('_sprintf') then
+ trampCall(@_sprintf)
+ else raise NameError.new( "Error: undefined variable _sprintf", "_sprintf" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/test.nnd:76"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ "%s:%s raised %s" ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 130 );
+ trampCall( self.__ASMARKFILE_ASMARK_METHOD( '*FILE*',
+ begin
+ if @global_lisp_binding.has_key?('__ASMARKFILE_ASMARK') then
+ trampCall(@__ASMARKFILE_ASMARK)
+ else raise NameError.new( "Error: undefined variable __ASMARKFILE_ASMARK", "__ASMARKFILE_ASMARK" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:130"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ ]
+ ))
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 130 );
+ trampCall( self.__ASMARKLINE_ASMARK_METHOD( '*LINE*',
+ begin
+ if @global_lisp_binding.has_key?('__ASMARKLINE_ASMARK') then
+ trampCall(@__ASMARKLINE_ASMARK)
+ else raise NameError.new( "Error: undefined variable __ASMARKLINE_ASMARK", "__ASMARKLINE_ASMARK" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:130"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ ]
+ ))
+ end ,
+ begin
+ trampCall(_exc)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/test.nnd:133"] + __e.backtrace ) ; raise __e
+ end
+ ]
+ ))
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/test.nnd", 76 );
+ trampCall( self._sprintf_METHOD( 'sprintf',
+ begin
+ if @global_lisp_binding.has_key?('_sprintf') then
+ trampCall(@_sprintf)
+ else raise NameError.new( "Error: undefined variable _sprintf", "_sprintf" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/test.nnd:76"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ "%s:%s raised %s" ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 130 );
+ trampCall( self.__ASMARKFILE_ASMARK_METHOD( '*FILE*',
+ begin
+ if @global_lisp_binding.has_key?('__ASMARKFILE_ASMARK') then
+ trampCall(@__ASMARKFILE_ASMARK)
+ else raise NameError.new( "Error: undefined variable __ASMARKFILE_ASMARK", "__ASMARKFILE_ASMARK" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:130"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ ]
+ ))
+ end ,
+ begin
+ embedBacktraceInfo( "./lib/nendo/experimental.nnd", 130 );
+ trampCall( self.__ASMARKLINE_ASMARK_METHOD( '*LINE*',
+ begin
+ if @global_lisp_binding.has_key?('__ASMARKLINE_ASMARK') then
+ trampCall(@__ASMARKLINE_ASMARK)
+ else raise NameError.new( "Error: undefined variable __ASMARKLINE_ASMARK", "__ASMARKLINE_ASMARK" ) end
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/experimental.nnd:130"] + __e.backtrace ) ; raise __e
+ end ,
+ [
+ ]
+ ))
+ end ,
+ begin
+ trampCall(_exc)
+ rescue => __e ; __e.set_backtrace( ["./lib/nendo/test.nnd:133"] + __e.backtrace ) ; raise __e
+ end
+ ]
+ ))
+ end
+ ]
+ ))
+ end
+ end
+ else
+ Cell.new()
+ end
end
end
} ,
View
2  lib/srfi-2.nndc
@@ -94,7 +94,7 @@ trampCall(
end
)
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
)
View
8 lib/util/combinations.nndc
@@ -1310,7 +1310,7 @@ trampCall(
begin raise RuntimeError,
"Error: match: no matching pattern"
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
}
@@ -2032,7 +2032,7 @@ trampCall(
begin raise RuntimeError,
"Error: match: no matching pattern"
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
}
@@ -3561,7 +3561,7 @@ trampCall(
begin raise RuntimeError,
"Error: match: no matching pattern"
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
}
@@ -4251,7 +4251,7 @@ trampCall(
begin raise RuntimeError,
"Error: match: no matching pattern"
rescue => __e
- __e.set_backtrace( ["./lib/nendo/experimental.nnd:168"] + __e.backtrace )
+ __e.set_backtrace( ["./lib/nendo/experimental.nnd:169"] + __e.backtrace )
raise __e
end
}
View
38 test/syntax_spec.rb
@@ -751,7 +751,7 @@
(%guard-clause (exc
(else (print "ELSE"))))))
EOS
- ).should == '(cond (else (print "ELSE")))'
+ ).should match( /^[(]cond.+else.+print.+ELSE.+[(]#t [(]raise.+exc[)][)][)]$/ )
@nendo.evalStr( <<EOS
@@ -762,7 +762,23 @@
(print "<<RuntimeError>>"))
(else (print "ELSE"))))))
EOS
- ).should == '(cond ((exc.is_a? RuntimeError) (print "<<RuntimeError>>")) (else (print "ELSE")))'
+ ).should match( /^[(]cond.+exc.is_a.+RuntimeError.+<<RuntimeError>>.+else.+print.+ELSE.+[(]#t [(]raise.+exc[)][)][)]$/ )
+
+ @nendo.evalStr( <<EOS
+(macroexpand-1
+ (quote
+ (%guard-clause (exc
+ ((exc.is_a? RuntimeError)
+ (print "<<RuntimeError>>"))))))
+EOS
+ ).should match( /^[(]cond.+exc.is_a.+RuntimeError.+<<RuntimeError>>.+[(]#t [(]raise.+exc[)][)][)]$/ )
+
+ @nendo.evalStr( <<EOS
+(macroexpand-1
+ (quote
+ (%guard-clause (exc))))
+EOS
+ ).should match( /^[(]cond.+[(]#t [(]raise.+exc[)][)][)]$/ )
@nendo.evalStr( <<EOS
(macroexpand-1
@@ -772,9 +788,10 @@
(print "<<RuntimeError>>"))
(else
=> (lambda (e)
- (printf "Type is [%s]\n" e.class)))))))
+ (sprintf "Type is [%s]" e.class)))))))
EOS
- ).should == "(cond ((exc.is_a? RuntimeError) (print \"<<RuntimeError>>\")) (else feedto (lambda (e) (printf \"Type is [%s]\n\" e.class))))"
+ ).should match( /^[(]cond.+exc.is_a.+RuntimeError.+print.+RuntimeError.+else.+feedto.+[(]#t [(]raise exc[)][)][)]$/ )
+
end
end
@@ -783,6 +800,7 @@
describe Nendo, "When use guard special form" do
before do
@nendo = Nendo::Core.new()
+ @nendo.setDisplayErrors( false )
@nendo.loadInitFile
end
it "should" do
@@ -858,7 +876,14 @@
EOS
).should == '"Type is [RuntimeError]"'
- @nendo.evalStr( <<EOS
+ lambda { @nendo.evalStr( <<EOS
+(guard
+ (exc)
+ (error "This is RuntimeError"))
+EOS
+ ) }.should raise_error( RuntimeError )
+
+ lambda { @nendo.evalStr( <<EOS
(begin
(guard
(exc ((exc.is_a? RuntimeError)
@@ -866,7 +891,7 @@
(+ (Array.new) 1))
\"-END-\")
EOS
- ).should == '"-END-"'
+ ) }.should raise_error( TypeError )
end
end
@@ -1032,4 +1057,3 @@
end
end
-
Please sign in to comment.
Something went wrong with that request. Please try again.