Class: AnalyzedTestClassGenerator
- Inherits:
-
Object
- Object
- AnalyzedTestClassGenerator
- Defined in:
- lib/AnalyzedClassGenerator.rb
Instance Method Summary collapse
- #analyzedTestClassWithName(name) ⇒ Object
- #generateAnalyzedTestClasses ⇒ Object
-
#initialize(analyzedClasses, analyzedTestClasses, testCaseDirectory) ⇒ AnalyzedTestClassGenerator
constructor
A new instance of AnalyzedTestClassGenerator.
- #variableForLine(testClass, line) ⇒ Object
Constructor Details
#initialize(analyzedClasses, analyzedTestClasses, testCaseDirectory) ⇒ AnalyzedTestClassGenerator
Returns a new instance of AnalyzedTestClassGenerator.
123 124 125 126 127 |
# File 'lib/AnalyzedClassGenerator.rb', line 123 def initialize (analyzedClasses, analyzedTestClasses, testCaseDirectory) @analyzedClasses = analyzedClasses @analyzedTestClasses = analyzedTestClasses @testCaseDirectory = testCaseDirectory end |
Instance Method Details
#analyzedTestClassWithName(name) ⇒ Object
208 209 210 211 212 213 214 215 |
# File 'lib/AnalyzedClassGenerator.rb', line 208 def analyzedTestClassWithName (name) for testClass in @analyzedTestClasses if testClass.name == name.strip return testClass end end return nil end |
#generateAnalyzedTestClasses ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/AnalyzedClassGenerator.rb', line 129 def generateAnalyzedTestClasses testedFunctionsMap = Hash.new curlyBraces = 0 count = 0 funcCurlyBraces = 0 funcLines = 0 name = nil testClass = nil Dir.glob("#{@testCaseDirectory}/**/*.swift") do |item| next if item == '.' or item == '..' f = File.open(item, "r") f.each_line do |line| tempName = AnalyzedClassGenerator.new.classNameForLine line, name if tempName != nil name = tempName end if name != nil if line.include? "{" curlyBraces = curlyBraces + 1 end if line.include? "}" curlyBraces = curlyBraces - 1 end if testClass == nil testClass = analyzedTestClassWithName name end variable = variableForLine testClass, line if variable for analyzedClass in @analyzedClasses if variable.type == analyzedClass.name for function in analyzedClass.functions if line.include? function.name # instance function analyzedClass.addTestedFunction function end end end end elsif line.strip.length > 9 for analyzedClass in @analyzedClasses if line.include? analyzedClass.name for function in analyzedClass.functions if line.include? function.name # Class function analyzedClass.addTestedFunction function end end end end end if curlyBraces == 0 testClass = nil name = nil curlyBraces = 0 end end end f.close end return testedFunctionsMap end |
#variableForLine(testClass, line) ⇒ Object
217 218 219 220 221 222 223 224 |
# File 'lib/AnalyzedClassGenerator.rb', line 217 def variableForLine (testClass, line) for variable in testClass.variablesWithType if line.include? variable.name return variable end end return nil end |