Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding test

  • Loading branch information...
commit f758844caf30040edc7ba30cb862902def533127 1 parent 743a094
@tenderlove authored
View
10 Manifest.txt
@@ -1,7 +1,11 @@
-History.txt
+.autotest
+CHANGELOG.rdoc
Manifest.txt
-README.txt
+README.rdoc
Rakefile
bin/never_say_die
-lib/never_say_die.rb
+ext/neversaydie/extconf.rb
+ext/neversaydie/neversaydie.c
+lib/neversaydie.rb
+lib/neversaydie/neversaydie.bundle
test/test_never_say_die.rb
View
9 Rakefile
@@ -2,12 +2,19 @@
require 'rubygems'
require 'hoe'
+gem 'rake-compiler', '>= 0.4.1'
+require "rake/extensiontask"
-Hoe.spec 'neversaydie' do
+name = 'neversaydie'
+HOE = Hoe.spec name do
developer('Aaron Patterson', 'aaronp@rubyforge.org')
self.readme_file = 'README.rdoc'
self.history_file = 'CHANGELOG.rdoc'
self.extra_rdoc_files = FileList['*.rdoc']
end
+RET = Rake::ExtensionTask.new(name, HOE.spec) do |ext|
+ ext.lib_dir = File.join('lib', name)
+end
+
# vim: syntax=ruby
View
2  ext/neversaydie/extconf.rb
@@ -51,6 +51,6 @@
abort "sigsegv is missing. please install it."
end
-create_makefile('sigsegv/sigsegv')
+create_makefile('neversaydie/neversaydie')
# :startdoc:
View
17 ext/neversaydie/neversaydie.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <sigsegv.h>
+#include <ruby.h>
+
+static VALUE segv(VALUE self)
+{
+ int *ptr = NULL;
+ *ptr = 1;
+
+ return self;
+}
+
+void Init_neversaydie()
+{
+ VALUE klass = rb_define_class("NeverSayDie", rb_eRuntimeError);
+ rb_define_singleton_method(klass, "segv", segv, 0);
+}
View
5 lib/neversaydie.rb
@@ -0,0 +1,5 @@
+require 'neversaydie/neversaydie'
+
+class NeverSayDie
+ VERSION = '1.0.0'
+end
View
8 test/test_never_say_die.rb
@@ -1,8 +1,10 @@
require "test/unit"
-require "never_say_die"
+require "neversaydie"
class TestNeverSayDie < Test::Unit::TestCase
- def test_sanity
- flunk "write tests or I will kneecap you"
+ def test_called
+ assert_raises NeverSayDie do
+ NeverSayDie.segv
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.