jsinstrument 0.0.13 → 0.0.14
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/lib/jsinstrument/instrumenter.rb +12 -2
- data/lib/jsinstrument/version.rb +1 -1
- metadata +1 -1
@@ -99,6 +99,7 @@ module JSInstrument
|
|
99
99
|
# function coverage
|
100
100
|
#
|
101
101
|
if line and not instrumented_func_lines.member? line
|
102
|
+
# function declaration and anonymous function
|
102
103
|
if ['FunctionDecl', 'FunctionExpr'].index node_classname
|
103
104
|
if node.function_body
|
104
105
|
insert_hitfunc_in node.function_body, line
|
@@ -110,8 +111,9 @@ module JSInstrument
|
|
110
111
|
# branch coverage
|
111
112
|
#
|
112
113
|
if line and not instrumented_branch_lines.member? line
|
113
|
-
if
|
114
|
-
|
114
|
+
# if else
|
115
|
+
if 'Block' == node_classname
|
116
|
+
if 'If' == parent_classname
|
115
117
|
if parent.value.eql? node
|
116
118
|
instrumented_branch_lines.add line
|
117
119
|
insert_hitbranch_in node
|
@@ -120,6 +122,14 @@ module JSInstrument
|
|
120
122
|
insert_hitbranch_in node
|
121
123
|
end
|
122
124
|
end
|
125
|
+
# switch case
|
126
|
+
# CaseClause node has the same structure with BlockNode
|
127
|
+
# so we can share the instrument logic
|
128
|
+
elsif 'CaseClause' == node_classname
|
129
|
+
if node.value
|
130
|
+
instrumented_branch_lines.add line
|
131
|
+
insert_hitbranch_in node
|
132
|
+
end
|
123
133
|
end
|
124
134
|
end
|
125
135
|
end
|
data/lib/jsinstrument/version.rb
CHANGED