rdoba 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,200 +0,0 @@
1
- When /appl(y|ied) Rdoba (Log|Debug) module(?: with set([\w\s,:]+ keywords?| a file name) for :(io|as|in|functions|prefix) options?| with an (invalid) :io option value)?(?: inside a (class))?(?:, and :as option pointing to (self|log))?/ do |var, kind, subs, opt, invalid, cls, as |
2
- if var == 'ied'
3
- rdoba_sim kind.downcase.to_sym, :init, subs, cls
4
- end
5
- rdoba_sim kind.downcase.to_sym, :apply, opt, subs, as
6
- end
7
-
8
- When /issue a call to the function/ do
9
- rdoba_sim :log, :call
10
- end
11
-
12
- When /issue a creation of the class/ do
13
- rdoba_sim :log, :create
14
- end
15
-
16
- When /declare the (Cls) class/ do| cls |
17
- rdoba_sim :log, :declare, cls
18
- end
19
-
20
- When /(issue|define) an output of an? (variable|number|string|array)(?: inside an? (initializer|singleton function))?(?: using (?:the|an?) (keyword|invalid keyword|class))?/ do |issue, subject, inside, cond|
21
-
22
- case inside
23
- when 'initializer'
24
- rdoba_sim :log, :def, :init
25
- when 'singleton function'
26
- rdoba_sim :log, :def, :single
27
- else
28
- rdoba_sim :log, :def ; end
29
-
30
- func = :func
31
- case subject
32
- when 'variable'
33
- rdoba_sim :log, func, cond, :>, { variable: 'value' }
34
- when 'number'
35
- rdoba_sim :log, func, cond, :>, 1
36
- when 'string'
37
- rdoba_sim :log, func, cond, :>, "string"
38
- when 'array'
39
- rdoba_sim :log, func, cond, :>, [ 'array value1', 'array value2' ] ; end
40
-
41
- if issue == 'issue'
42
- rdoba_sim :log, :close ; end ; end
43
-
44
- When /issue an? :(extended|info|warn|enter|leave|compat) output of a variable?/ do |key|
45
- case key
46
- when 'extended'
47
- rdoba_sim :log, :func, :log, :>>, { variable: 'value' }
48
- when 'info'
49
- rdoba_sim :log, :func, :log, :*, { variable: 'value' }
50
- when 'warn'
51
- rdoba_sim :log, :func, :log, :%, { variable: 'value' }
52
- when 'enter'
53
- rdoba_sim :log, :func, :log, :+, { variable: 'value' }
54
- when 'leave'
55
- rdoba_sim :log, :func, :log, :-, true # TODO check return
56
- when 'compat'
57
- rdoba_sim :log, :func, :dbp11, "'variable: \"value\"'" ; end
58
-
59
- rdoba_sim :log, :close ; end
60
-
61
- When /issue an output of the thrown (exception|standard error)(.*)/ do |type, note|
62
- case type
63
- when 'exception'
64
- if note =~ /out/
65
- rdoba_sim :log, :func, :log, :e, :'Exception.new', :$stdout
66
- else
67
- rdoba_sim :log, :func, :log, :e, :'Exception.new' ; end
68
- when 'standard error'
69
- if note =~ /notification/
70
- rdoba_sim :log, :func, :log, :e, :'StandardError.new',
71
- [ 'standard error extended info' ]
72
- else
73
- rdoba_sim :log, :func, :log, :e, :'StandardError.new' ; end ; end ; end
74
-
75
- When /look into(?: the)? (stdout|stderr|file|IO)/ do |ioname|
76
- @res = case ioname
77
- when 'file'
78
- rdoba_sim :log, :exec, :file
79
- when 'IO'
80
- rdoba_sim :log, :exec, :io
81
- when 'stdout'
82
- rdoba_sim :log, :exec, :stdout
83
- when 'stderr'
84
- rdoba_sim :log, :exec, :stderr; end ; end
85
-
86
- When /(remove|add) :(basic|extended|info|warn|enter|leave|compat) keyword.* :(functions) option(?: to the (self) object)?/ do |act, key, opt, obj|
87
- if act == 'remove'
88
- rdoba_sim :log, :func, obj, :>=, [ key.to_sym ]
89
- else
90
- rdoba_sim :log, :func, obj, :<=, [ key.to_sym ] ; end ; end
91
-
92
- When /clear the :(functions) option/ do |opt|
93
- rdoba_sim :log, :func, :log, :>=, [ :* ]
94
- end
95
-
96
- Then /see the (variable|string|number|array|'true' value) output(?: with the :(basic|extended|info|warn|enter|leave) notice)?(?: preficed with the :(.*))?/ do |subject, notice, prefices|
97
- case subject
98
- when 'variable'
99
- sym = notice && { 'basic' => '>', 'extended' => '>>', 'info' => '***',
100
- 'warn' => '%%%', 'enter' => '<<<', 'leave' => '>>>' }[ notice ] || '>'
101
- symr = sym.to_s.gsub ( '*' ) do |x| "\\#{x}" end
102
- prefices = match_keywords prefices
103
- if prefices.empty?
104
- if @res !~ /variable: "value"/
105
- raise "Invalid answer: #{@res}, must be \"variable: \"value\"" ; end
106
- else
107
- case prefices
108
- when [:timestamp]
109
- if @res !~ /\[\d\d:\d\d:\d\d\.\d{9}\]#{symr} variable: "value"/
110
- raise "Invalid answer: #{@res.chomp}, must be like " +
111
- "[00:00:00.000000000]#{sym} variable: \"value\"" ; end
112
- when [:timestamp, :pid]
113
- if @res !~ /\[\d\d:\d\d:\d\d\.\d{9}\]\{\d+\}#{symr} variable: "value"/
114
- raise "Invalid answer: #{@res.chomp}, must be like " +
115
- "[00:00:00.000000000]{0000}#{sym} variable: \"value\"" ; end
116
- when [:timestamp, :pid, :function_name]
117
- if @res !~ /\[\d\d:\d\d:\d\d\.\d{9}\]\{\d+\}\(.+\)#{symr} variable: "value"/
118
- raise "Invalid answer: #{@res.chomp}, must be like " +
119
- "[00:00:00.000000000]{0000}(name)#{sym} variable: \"value\"" ; end
120
- when [:timestamp, :pid, :function_name, :function_line]
121
- if @res !~ /\[\d\d:\d\d:\d\d\.\d{9}\]\{\d+\}\([^\.]+\.\d+\)#{symr} variable: "value"/
122
- raise "Invalid answer: #{@res.chomp}, must be like " +
123
- "[00:00:00.000000000]{0000}(name.0)#{sym} variable: \"value\"" ; end
124
- when [:timestamp, :pid, :function]
125
- expect( @res ).to match( /\[\d\d:\d\d:\d\d\.\d{9}\]\{\d+\}\([^:]+:[^\.]+\.\d+\)#{symr} variable: "value"/ )
126
- else
127
- raise "Invalid answer: #{@res}"
128
- end
129
- end
130
- when 'string'
131
- if @res !~ /string/
132
- raise "Invalid answer: #{@res}, must be \"string\"" ; end
133
- when 'number'
134
- if @res !~ /1/
135
- raise "Invalid answer: #{@res.inspect}, must be \"1\"" ; end
136
- when "'true' value"
137
- if @res !~ /true/
138
- raise "Invalid answer: #{@res.inspect}, must be \"true\"" ; end
139
- when 'array'
140
- if @res !~ /array value1, array value2/
141
- raise "Invalid answer: #{@res.inspect}, must be an enum: \"array value1, array value2\"" ; end ; end ; end
142
-
143
- Then /see the (standard error|exception) info(.*)/ do |subject, notice|
144
- case subject
145
- when 'exception'
146
- if @res !~/Exception:%> Exception/
147
- raise "Invalid answer: #{@res.inspect}, must be like " +
148
- "'Exception:%> Exception'" ; end
149
- when 'standard error'
150
- if notice =~ /notification/
151
- if @res !~ /StandardError:%> StandardError\n\tstandard error extended info/
152
- raise "Invalid answer: #{@res.inspect}, must be like " +
153
- "'StandardError:%> StandardError\n\tstandard error " +
154
- "extended info'" ; end
155
- else
156
- if @res !~ /StandardError:%> StandardError/
157
- raise "Invalid answer: #{@res.inspect}, must be like " +
158
- "'StandardError:%> StandardError'" ; end ; end ; end ; end
159
-
160
- Then /see(?: a| the)? (nothing|warning|.* error exception)/ do |subject|
161
- case subject
162
- when 'nothing'
163
- if !@res.empty?
164
- raise "Invalid answer: #{@res.inspect}, must be empty" ; end
165
- when 'warning'
166
- if @res !~ /Warning:/
167
- raise "Invalid answer: #{@res.inspect}, must be a warning " +
168
- "with the description" ; end
169
- 'log\': main is not a class/module (TypeError)'
170
- when /no method error/
171
- if @res !~ /undefined method .* \(NoMethodError\)/
172
- raise "Invalid answer: #{@res.inspect}, must notify" +
173
- " that the interpreter has not found the specified method" ; end
174
- when /name error/
175
- if @res !~ /.* \(NameError\)/
176
- raise "Invalid answer: #{@res.inspect}, must notify" +
177
- " that the the specified name isn't declared" ; end
178
- else
179
- raise "Invalid answer: #{@res.inspect}" ; end ; end
180
-
181
-
182
- Given(/^selected full Rdoba Log test plan( with self keyword)?$/) do |slf|
183
- @testplan = 'features/support/' +
184
- if slf
185
- 'fulltest_as_self.rb.in'
186
- else
187
- 'fulltest_as_log.rb.in' ; end
188
- if !File.exist? @testplan
189
- raise "Invalid file #{@testplan} for the specified full test plan" ; end
190
- end
191
-
192
- When(/^we run the test plan$/) do
193
- Open3.popen3( @testplan ) do |stdin, stdout, stderr, wait_thr|
194
- @out = stdout.read
195
- @err = stderr.read ; end ; end
196
-
197
- Then(/^we see no error on its output$/) do
198
- if !@err.empty?
199
- raise "Error found: #{@err}" ; end ; end
200
-
@@ -1,143 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rdoba'
4
-
5
- p 'main=========='
6
- rdoba :log => { :functions => [ :basic ], :prefix => [ :timestamp ] }
7
- log > "11111"
8
-
9
- def l
10
- log > "22222"
11
- end
12
-
13
- l
14
-
15
- #rdoba :log => { :functions => [ :basic ], :in => Object }
16
-
17
- p 'Class=========='
18
- class A
19
- rdoba :log => { :functions => [ :basic ], :prefix => [ :timestamp ] }
20
- log > "#{self} - When do I get executed!?"
21
- class << self
22
- log > "#{self} - And me!?" # now A's singleton class
23
- def a # declaring method in class's singleton class results in class method
24
- log > "#{self} - declared in singleton class" # it's A
25
- end
26
- end
27
-
28
- def self.b
29
- log > "#{self} - declared in class method" # self is class A again -> class method
30
- class << self
31
- log > "#{self} - declared in Class A's singleton class" # now it's Class A's singleton class
32
- end
33
- end
34
-
35
- def c
36
- log > "#{self} - declared in instance method" # self is instance of A
37
- class << self
38
- log > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
39
- end
40
- end
41
- end
42
-
43
- a = A.new
44
- A.a
45
- A.b
46
- a.c
47
-
48
- p 'Class------------B'
49
-
50
- class B
51
- rdoba :log => { :functions => [ :basic ], :prefix => [ :pid ] }
52
- log > "#{self} - When do I get executed!?"
53
- class << self
54
- log > "#{self} - And me!?" # now A's singleton class
55
- def a # declaring method in class's singleton class results in class method
56
- log > "#{self} - declared in singleton class" # it's A
57
- end
58
- end
59
-
60
- def self.b
61
- log > "#{self} - declared in class method" # self is class A again -> class method
62
- class << self
63
- log > "#{self} - declared in Class B's singleton class" # now it's Class A's singleton class
64
- end
65
- end
66
-
67
- def c
68
- log > "#{self} - declared in instance method" # self is instance of A
69
- class << self
70
- log > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
71
- end
72
- end
73
- end
74
-
75
- a = B.new
76
- B.a
77
- B.b
78
- a.c
79
-
80
- p 'Class-------------A'
81
- class A
82
- log > "#{self} - When do I get executed!?"
83
- class << self
84
- log > "#{self} - And me!?" # now A's singleton class
85
- def a # declaring method in class's singleton class results in class method
86
- log > "#{self} - declared in singleton class" # it's A
87
- end
88
- end
89
-
90
- def self.b
91
- log > "#{self} - declared in class method" # self is class A again -> class method
92
- class << self
93
- log > "#{self} - declared in Class A's singleton class" # now it's Class A's singleton class
94
- end
95
- end
96
-
97
- def c
98
- # logi
99
- log > "#{self} - declared in instance method" # self is instance of A
100
- class << self
101
- log > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
102
- end
103
- end
104
- end
105
-
106
- a = A.new
107
- A.a
108
- A.b
109
- a.c
110
-
111
- p 'Module=========='
112
- module M
113
- rdoba :log => { :functions => [ :basic ], :prefix => [ :pid ] }
114
- log > "aaa"
115
-
116
- class << self
117
- log > "#{self} - And me!?" # now A's singleton class
118
- def a # declaring method in class's singleton class results in class method
119
- log > "#{self} - declared in singleton class" # it's A
120
- end
121
- end
122
-
123
- def a
124
- log > 'mod a'
125
- end
126
-
127
- def self.b
128
- log > 'mod b'
129
- end
130
- end
131
-
132
- class C
133
- include M
134
- end
135
- C.new.a
136
-
137
- class D
138
- extend M
139
- end
140
- D.a
141
- M.b
142
-
143
-
@@ -1,144 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rdoba'
4
-
5
- p 'main=========='
6
- rdoba :log => { :as => :self, :functions => [ :basic ],
7
- :prefix => [ :timestamp ] }
8
- self > "11111"
9
-
10
- def l
11
- self > "22222"
12
- end
13
-
14
- l
15
-
16
- rdoba :log => { :as => :self, :functions => [ :basic ], :in => Object }
17
-
18
- p 'Class=========='
19
- class A
20
- rdoba :log => { :as => :self, :functions => [ :basic ],
21
- :prefix => [ :timestamp ] }
22
- self > "#{self} - When do I get executed!?"
23
- class << self
24
- self > "#{self} - And me!?" # now A's singleton class
25
- def a # declaring method in class's singleton class results in class method
26
- self > "#{self} - declared in singleton class" # it's A
27
- end
28
- end
29
-
30
- def self.b
31
- self > "#{self} - declared in class method" # self is class A again -> class method
32
- class << self
33
- self > "#{self} - declared in Class A's singleton class" # now it's Class A's singleton class
34
- end
35
- end
36
-
37
- def c
38
- self > "#{self} - declared in instance method" # self is instance of A
39
- class << self
40
- self > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
41
- end
42
- end
43
- end
44
-
45
- a = A.new
46
- A.a
47
- A.b
48
- a.c
49
-
50
- p 'Class------------B'
51
-
52
- class B
53
- rdoba :log => { :as => :self, :functions => [ :basic ], :prefix => [ :pid ] }
54
- self > "#{self} - When do I get executed!?"
55
- class << self
56
- self > "#{self} - And me!?" # now A's singleton class
57
- def a # declaring method in class's singleton class results in class method
58
- self > "#{self} - declared in singleton class" # it's A
59
- end
60
- end
61
-
62
- def self.b
63
- self > "#{self} - declared in class method" # self is class A again -> class method
64
- class << self
65
- self > "#{self} - declared in Class B's singleton class" # now it's Class A's singleton class
66
- end
67
- end
68
-
69
- def c
70
- self > "#{self} - declared in instance method" # self is instance of A
71
- class << self
72
- self > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
73
- end
74
- end
75
- end
76
-
77
- a = B.new
78
- B.a
79
- B.b
80
- a.c
81
-
82
- p 'Class-------------A'
83
- class A
84
- self > "#{self} - When do I get executed!?"
85
- class << self
86
- self > "#{self} - And me!?" # now A's singleton class
87
- def a # declaring method in class's singleton class results in class method
88
- self > "#{self} - declared in singleton class" # it's A
89
- end
90
- end
91
-
92
- def self.b
93
- self > "#{self} - declared in class method" # self is class A again -> class method
94
- class << self
95
- self > "#{self} - declared in Class A's singleton class" # now it's Class A's singleton class
96
- end
97
- end
98
-
99
- def c
100
- self > "#{self} - declared in instance method" # self is instance of A
101
- class << self
102
- self > "#{self} - declared in instance's singleton class" # now it's the A instance's singleton class
103
- end
104
- end
105
- end
106
-
107
- a = A.new
108
- A.a
109
- A.b
110
- a.c
111
-
112
- p 'Module=========='
113
- module M
114
- rdoba :log => { :as => :self, :functions => [ :basic ], :prefix => [ :pid ] }
115
- self > "aaa"
116
-
117
- class << self
118
- self > "#{self} - And me!?" # now A's singleton class
119
- def a # declaring method in class's singleton class results in class method
120
- self > "#{self} - declared in singleton class" # it's A
121
- end
122
- end
123
-
124
- def a
125
- self > 'mod a'
126
- end
127
-
128
- def self.b
129
- self > 'mod b'
130
- end
131
- end
132
-
133
- class C
134
- include M
135
- end
136
- C.new.a
137
-
138
- class D
139
- extend M
140
- end
141
- D.a
142
- M.b
143
-
144
-