@@ -11,13 +11,19 @@ def drop_profiler_tables
11
11
PLSQL ::Coverage . reset_cache
12
12
13
13
plsql . connect! CONNECTION_PARAMS
14
+ plsql . execute "ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=1"
14
15
drop_profiler_tables
15
16
@source = <<-SQL
16
17
CREATE OR REPLACE FUNCTION test_profiler RETURN VARCHAR2 IS
18
+
19
+ -- A comment before executed code
17
20
BEGIN
18
21
RETURN 'test_profiler';
22
+ -- A dummy empty line follows
23
+
19
24
EXCEPTION
20
25
WHEN OTHERS THEN
26
+ -- We should never reach here
21
27
RETURN 'others';
22
28
END;
23
29
SQL
@@ -26,10 +32,13 @@ def drop_profiler_tables
26
32
@coverage_data = {
27
33
DATABASE_USER . upcase => {
28
34
"TEST_PROFILER" => {
29
- 1 => 0 ,
30
- 3 => 1 ,
31
- 6 => 0 ,
32
- 7 => 1
35
+ 1 => 1 ,
36
+ 4 => 1 ,
37
+ 5 => 1 ,
38
+ 8 => 0 ,
39
+ 9 => 0 ,
40
+ 11 => 0 ,
41
+ 12 => 1
33
42
}
34
43
}
35
44
}
@@ -137,7 +146,7 @@ def drop_profiler_tables
137
146
describe "generate" do
138
147
def adjust_test_coverage
139
148
@test_coverage = @coverage_data [ DATABASE_USER . upcase ] [ 'TEST_PROFILER' ] . dup
140
- @test_coverage . delete ( 1 ) if @test_coverage [ 1 ] && @source . split ( "\n " ) [ 0 ] =~ /^CREATE OR REPLACE (.*)$/
149
+ @test_coverage . delete ( 1 ) if @test_coverage [ 1 ] == 0 && @source . split ( "\n " ) [ 0 ] =~ /^CREATE OR REPLACE (.*)$/
141
150
end
142
151
143
152
def expected_coverages
@@ -178,8 +187,11 @@ def expected_coverages
178
187
a = @details_doc . at_css ( "table.details a[name=\" line#{ i +1 } \" ]" )
179
188
a . should_not be_nil
180
189
190
+ doc_line = a . parent . children [ 1 ]
191
+ doc_line_text = doc_line ? doc_line . text : ""
192
+
181
193
# source text should be present
182
- a . parent . children [ 1 ] . text . should == line
194
+ doc_line_text . should == line
183
195
184
196
# table row should have correct class according to coverage data
185
197
tr = a . ancestors ( 'tr' ) [ 0 ]
@@ -247,4 +259,4 @@ def expected_coverages
247
259
end
248
260
end
249
261
250
- end
262
+ end
0 commit comments