Coverage and ensure

coverage e$B$G!"e(Bensure [email protected]$NJ8$,?t$($i$l$J$$5$$,$7$^$9!#e(B

% cat z.rb
begin
p 1
ensure
p 2
end
% ./ruby -rcoverage -ve ’
Coverage.start
load “z.rb”
p Coverage.result

ruby 1.9.2dev (2009-09-10 trunk 24826) [i686-linux]
1
2
{“z.rb”=>[1, 1, nil, 0, nil]}

e$B$3$3$G!“e(B2 e$B$HI=<($5$l$F$$$k$h$&$Ke(B z.rb e$BFb$Ne(B p 2
e$B$,<B9T$5$l$Fe(B
e$B$$$^$9$,!”$=$l$KBP1~$9$ke(B Coverage.result[“z.rb”][3] e$B$Oe(B 0
e$B$Ke(B
e$B$J$C$F$$$^$9!#e(B

e$B1sF#$G$9!#e(B

2009e$BG/e(B9e$B7ne(B11e$BF|e(B1:51 Tanaka A. [email protected]:

load “z.rb”
p Coverage.result

ruby 1.9.2dev (2009-09-10 trunk 24826) [i686-linux]
1
2
{“z.rb”=>[1, 1, nil, 0, nil]}

e$B$b$N$9$4$/CY$/$J$C$F$9$_$^$;$s!#e(B

p “foo”; p “bar”
e$B$N$h$&$JJ#J8$N$"$k9T$KBP$7$F<B9T2s?t$r=EJ#$7$F?t$($ke(B
e$B$N$rHr$1$k$?$a$K!"F1$89T$KBP$9$k%+%P%l%C%8$N%$%Y%s%H$re(B 1
e$B2s$7$+A^F~e(B
e$B$7$J$$$h$&$K$7$F$$$?$N$G$9$,!"e(Bensure
e$B$NCf?H$ONc30$,5/$-$?>l9g$HDL>oe(B
e$B=*N;$7$?>l9g$K%3!<%I$,%3%T!<$5$l$k$?$a!“J#?t8D$N%+%P%l%C%8%$%Y%s%H$re(B
e$BA^F~$9$kI,MW$,$”$j$^$7$?!#e(B

e$B$I$&$9$k$+G:[email protected]$N$G$9$,!"F1$89T$r!VO"B3$7$F!W%3%s%Q%$%k$9$k>l9g$K!“e(B
1 [email protected]$1%+%P%l%C%8%$%Y%s%H$rH/@8$9$k$h$&$K$7$F$_$^$7$?!#e(B
e$B$H$j$”$($:$3$NJ}K!$GBP=h$7$F!"LdBj$,8+$D$+$C$?$i9M$($h$&$H;W$$$^$9!#e(B

Index: iseq.c

— iseq.c (revision 25260)
+++ iseq.c (working copy)
@@ -249,6 +249,7 @@
iseq->compile_data->storage_head->buff =
(char *)(&iseq->compile_data->storage_head->buff + 1);
iseq->compile_data->option = option;

  • iseq->compile_data->last_coverable_line = -1;

    set_relation(iseq, parent);

Index: iseq.h

— iseq.h (revision 25260)
+++ iseq.h (working copy)
@@ -82,6 +82,7 @@
struct iseq_compile_data_storage *storage_head;
struct iseq_compile_data_storage *storage_current;
int last_line;

  • int last_coverable_line;
    int flip_cnt;
    int label_no;
    int node_level;
    Index: compile.c
    ===================================================================
    — compile.c (revision 25260)
    +++ compile.c (working copy)
    @@ -223,8 +223,9 @@
    #define ADD_TRACE(seq, line, event)
    do {
    if ((event) == RUBY_EVENT_LINE && iseq->coverage && \
  • RARRAY_PTR(iseq->coverage)[(line) - 1] == Qnil) { \
  • (line) != iseq->compile_data->last_coverable_line) {
    RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \
  • iseq->compile_data->last_coverable_line = (line);
    ADD_INSN1(seq, line, trace, INT2FIX(RUBY_EVENT_COVERAGE));
    }
    if (iseq->compile_data->option->trace_instruction) { \

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs