abstract 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +3 -0
- data/README.txt +57 -0
- data/abstract.gemspec +48 -0
- data/lib/abstract.rb +75 -0
- data/setup.rb +1331 -0
- data/test/test.rb +91 -0
- metadata +50 -0
data/test/test.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
##
|
2
|
+
## $Rev: 1 $
|
3
|
+
## $Release: 1.0.0 $
|
4
|
+
## copyright(c) 2006 kuwata-lab.com all rights reserved.
|
5
|
+
##
|
6
|
+
|
7
|
+
testdir = File.dirname(File.expand_path(__FILE__))
|
8
|
+
libdir = File.dirname(testdir) + "/lib"
|
9
|
+
$: << libdir
|
10
|
+
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
require 'abstract'
|
14
|
+
|
15
|
+
|
16
|
+
class Foo
|
17
|
+
abstract_method "arg1, arg2=''", :m1, :m2, :m3
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
class Bar
|
22
|
+
def m1(arg1, arg2='')
|
23
|
+
not_implemented
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
class AbstractTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
|
32
|
+
def _test(obj)
|
33
|
+
assert_raise(NotImplementedError) do
|
34
|
+
begin
|
35
|
+
obj = Foo.new
|
36
|
+
obj.m1 'a'
|
37
|
+
rescue => ex
|
38
|
+
linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1
|
39
|
+
raise ex
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def test_abstract_method1
|
46
|
+
obj = Foo.new
|
47
|
+
assert_raise(NotImplementedError) { obj.m1 'a' }
|
48
|
+
assert_raise(NotImplementedError) { obj.m2 'a', 'b' }
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_abstract_method2
|
53
|
+
begin
|
54
|
+
obj = Foo.new
|
55
|
+
linenum = __LINE__; obj.m1 'a'
|
56
|
+
rescue NotImplementedError => ex
|
57
|
+
actual_linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1.to_i
|
58
|
+
end
|
59
|
+
assert_equal linenum, actual_linenum
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_not_implemented1
|
64
|
+
obj = Bar.new
|
65
|
+
assert_raise(NotImplementedError) { obj.m1 123 }
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def test_not_implemented2
|
70
|
+
begin
|
71
|
+
obj = Bar.new
|
72
|
+
linenum = __LINE__; obj.m1 'a'
|
73
|
+
rescue NotImplementedError => ex
|
74
|
+
actual_linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1.to_i
|
75
|
+
end
|
76
|
+
assert_equal linenum, actual_linenum
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def test_not_implemented3
|
81
|
+
begin
|
82
|
+
obj = Bar.new
|
83
|
+
obj.not_implemented
|
84
|
+
rescue Exception => ex
|
85
|
+
assert_instance_of(NoMethodError, ex)
|
86
|
+
assert_match(/private method/, ex.message)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: abstract
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2006-03-13 00:00:00 +09:00
|
8
|
+
summary: a library which enable you to define abstract method in Ruby
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
homepage: http://rubyforge.org/projects/abstract
|
13
|
+
rubyforge_project:
|
14
|
+
description: "'abstract.rb' is a library which enable you to define abstract method in Ruby."
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- makoto kuwata
|
30
|
+
files:
|
31
|
+
- lib/abstract.rb
|
32
|
+
- test/test.rb
|
33
|
+
- README.txt
|
34
|
+
- ChangeLog
|
35
|
+
- setup.rb
|
36
|
+
- abstract.gemspec
|
37
|
+
test_files:
|
38
|
+
- test/test.rb
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
executables: []
|
44
|
+
|
45
|
+
extensions: []
|
46
|
+
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
dependencies: []
|
50
|
+
|