summaryrefslogtreecommitdiff
path: root/ext/coverage/coverage.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 14:27:43 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 14:27:43 +0000
commitae3a03eb07e1f6c5a008ec9d9fe2a81e21205026 (patch)
tree9ca9f1566288f59708f2458555752c924b28266a /ext/coverage/coverage.c
parentda1263d2ac7063ddd6b68ac460a9f9a45ab8993b (diff)
* include/ruby/intern.h: remove prototypes about coverage.
* iseq.c (prepare_iseq_build): add prototype. * parse.y (coverage): ditto. * thread.c (clear_coverage): ditto. * thread.c (update_coverage): use rb_sourceline. * thread.c (rb_get_coverages): rename and move to vm.c. * vm.c (rb_vm_get_coverages): ditto. * ext/coverage/coverage.c: add rdoc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/coverage/coverage.c')
-rw-r--r--ext/coverage/coverage.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index a56a408..b40b28b 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -1,11 +1,47 @@
+/************************************************
+
+ coverage.c -
+
+ $Author: $
+
+ Copyright (c) 2008 Yusuke Endoh
+
+************************************************/
+
#include "ruby.h"
-VALUE rb_mCoverage;
+extern void rb_enable_coverages(void);
+/* Coverage provides coverage measurement feature for Ruby.
+ *
+ * = Usage
+ *
+ * (1) require "coverage.so"
+ * (2) require or load Ruby source file
+ * (3) Coverage.result will return a hash that contains filename as key and
+ * coverage array as value.
+ *
+ * = Example
+ *
+ * [foo.rb]
+ * s = 0
+ * 10.times do |x|
+ * s += x
+ * end
+ *
+ * if s == 45
+ * p :ok
+ * else
+ * p :ng
+ * end
+ * [EOF]
+ *
+ * require "coverage.so"
+ * require "foo.rb"
+ * p COVERAGE__ #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
+ */
void
Init_coverage(void)
{
rb_enable_coverages();
- rb_mCoverage = rb_define_module("Coverage");
- rb_define_module_function(rb_mCoverage, "result", rb_get_coverages, 0);
}