fluentasserts.core.operations.instanceOf 18/18(100%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
2061
2161
220
2361
240
2561
260
270
280
2961
300
3161
3229
330
340
3561
360
3761
3826
3926
4026
4126
420
430
4487
4513
460
470
4887
4913
500
510
5261
530
module fluentasserts.core.operations.instanceOf; import fluentasserts.core.results; import fluentasserts.core.evaluation; import fluentasserts.core.lifecycle; import std.conv; import std.datetime; import std.algorithm; version(unittest) { import fluentasserts.core.expect; } static immutable instanceOfDescription = "Asserts that the tested value is related to a type."; /// IResult[] instanceOf(ref Evaluation evaluation) @safe nothrow { string expectedType = evaluation.expectedValue.strValue[1 .. $-1]; string currentType = evaluation.currentValue.typeNames[0]; evaluation.message.addText(". "); auto existingTypes = findAmong(evaluation.currentValue.typeNames, [expectedType]); import std.stdio; auto isExpected = existingTypes.length > 0; if(evaluation.isNegated) { isExpected = !isExpected; } IResult[] results = []; if(!isExpected) { evaluation.message.addValue(evaluation.currentValue.strValue); evaluation.message.addText(" is instance of "); evaluation.message.addValue(currentType); evaluation.message.addText("."); } if(!isExpected && !evaluation.isNegated) { try results ~= new ExpectedActualResult("typeof " ~ expectedType, "typeof " ~ currentType); catch(Exception) {} } if(!isExpected && evaluation.isNegated) { try results ~= new ExpectedActualResult("not typeof " ~ expectedType, "typeof " ~ currentType); catch(Exception) {} } return results; }