faultinjection 0.0.2 → 0.0.3

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/Manifest.txt CHANGED
@@ -1,8 +1,3 @@
1
- #*scratch*#18552Tu2#
2
- #*scratch*#20064OwE#
3
- #*scratch*#20109z1E#
4
- #*scratch*#20389vPF#
5
- #*scratch*#20789Z7F#
6
1
  History.txt
7
2
  License.txt
8
3
  Manifest.txt
@@ -5,20 +5,45 @@
5
5
  module FaultInjection
6
6
  class Parser
7
7
  def self.compile src
8
- method_pat = '([A-Z][A-Za-z0-9_]*)(?:#|::)([a-z_][a-zA-Z0-9_]*)'
8
+ method_pat = /
9
+ ([A-Z][A-Za-z0-9_]*) # class name
10
+ (?: \#|:: ) # '#' or '::', they are treated as same now.
11
+ ([a-z_][a-zA-Z0-9_]*) # method name
12
+ /x
13
+ method_lineno_pat = /
14
+ ([A-Z][A-Za-z0-9_]*) # class name
15
+ (?: \#|:: ) # '#' or '::', they are treated as same.
16
+ ([a-z_][a-zA-Z0-9_]*) # method name
17
+ (?: :(\d+) ) # line number in method
18
+ /x
19
+
20
+ file_line_pat = /^([A-Za-z0-9_.~-]+):(\d+)$/
9
21
  src.gsub!(/\s/,'')
10
22
 
11
- if src =~ /([A-Za-z0-9_.~-]+):(\d+)/
12
- return FaultConditionLine.new($1,$2.to_i)
13
-
23
+ if src =~ file_line_pat
24
+ return FaultConditionLine.new($~[1],$~[2].to_i)
25
+
26
+ elsif src =~ method_lineno_pat
27
+ #STDERR.puts("Class=#{$~[1]},method='#{$~[2]}',line='#{$~[3]}'")
28
+ klass = eval($~[1]) rescue raise(NameError,"No such class:'#{$~[1]}'")
29
+ method = $~[2]
30
+ line_in_meth = $~[3].to_i
31
+
32
+ # Proc#to_s contains file name & line number in which
33
+ # the method is defined.
34
+ method_info = klass.new.method(method).to_proc.to_s
35
+ method_info =~ /@([^:]+):(\d+)>$/
36
+ #STDERR.puts("file=#{$~[1]},line=#{$~[2]}")
37
+ return FaultConditionLine.new($~[1], $~[2].to_i + line_in_meth)
38
+
14
39
  else
15
40
  methods = src.split(">")
16
41
  methods.map! do |e|
17
- unless e =~ Regexp.new(method_pat)
42
+ unless e =~ method_pat
18
43
  raise ArgumentError,"Invalid method name:'#{e}'"
19
44
  end
20
-
21
- [$1.to_sym,$2.to_sym]
45
+
46
+ [$~[1].to_sym, $~[2].to_sym]
22
47
  end
23
48
 
24
49
  c = FaultConditionCall.new
@@ -2,7 +2,7 @@ module FaultInjection #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -76,6 +76,20 @@ describe "Method tracing fault-injection" do
76
76
  end
77
77
  end
78
78
 
79
+ describe "'Line number in method' style fault injection" do
80
+ require 'target_03.rb'
81
+
82
+ it "should inject faults properly with Class#method:line format." do
83
+ Proc.new { T3.new.foo }.should_not raise_error
84
+
85
+ pending "not yet implemented" do
86
+ FaultInjection.inject("T3#foo:2",IOError)
87
+
88
+ Proc.new { T3.new.foo }.should raise_error(IOError)
89
+ end
90
+ end
91
+ end
92
+
79
93
  describe "Specifying Exception class" do
80
94
  require 'target_01.rb'
81
95
 
data/website/index.html CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  <h1>fault_injection.rb</h1>
18
18
  <div style="text-align:right;">
19
- Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.2</a>
19
+ Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.3</a>
20
20
  </div>
21
21
  <h2>Overview</h2>
22
22
 
@@ -128,7 +128,7 @@ it makes a script much slower.</p>
128
128
 
129
129
  <p>(Please remove &#8221;.spam&#8221; from the address for anti-spam, and include &#8216;ruby&#8217; or &#8216;fault_injection&#8217; in the title)</p>
130
130
  <p class="coda">
131
- <a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>, 12th January 2008<br>
131
+ <a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>, 13th January 2008<br>
132
132
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
133
133
  </p>
134
134
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faultinjection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ""
6
6
  authors:
7
7
  - FIXME full name
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-12 00:00:00 +09:00
12
+ date: 2008-03-12 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,11 +26,6 @@ extra_rdoc_files:
26
26
  - README.txt
27
27
  - website/index.txt
28
28
  files:
29
- - "#*scratch*#18552Tu2#"
30
- - "#*scratch*#20064OwE#"
31
- - "#*scratch*#20109z1E#"
32
- - "#*scratch*#20389vPF#"
33
- - "#*scratch*#20789Z7F#"
34
29
  - History.txt
35
30
  - License.txt
36
31
  - Manifest.txt
data/#*scratch*#18552Tu2# DELETED
File without changes
data/#*scratch*#20064OwE# DELETED
File without changes
data/#*scratch*#20109z1E# DELETED
File without changes
data/#*scratch*#20389vPF# DELETED
File without changes
data/#*scratch*#20789Z7F# DELETED
File without changes