Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adding test

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

0 comments on commit f758844

Please sign in to comment.
Something went wrong with that request. Please try again.