Fix unit tests
This commit is contained in:
parent
b0a6930a76
commit
525790aefc
|
|
@ -19,7 +19,7 @@ public:
|
||||||
{
|
{
|
||||||
foreach (span; spans)
|
foreach (span; spans)
|
||||||
{
|
{
|
||||||
if (span.low <= line && span.high >= line)
|
if (line >= span.low && line <= span.high)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -61,23 +61,21 @@ private:
|
||||||
enum context = 3;
|
enum context = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This test is broken, and none of the code in this module is
|
unittest
|
||||||
// used anywhere. Is it okay to remove?
|
|
||||||
version (none) unittest
|
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
LineSpans l;
|
LineSpans l;
|
||||||
l.addLine(4);
|
l.addLine(5);
|
||||||
foreach (i; 2 .. 7)
|
foreach (i; 2 .. 9)
|
||||||
assert (l.containsLine(i));
|
assert (l.containsLine(i));
|
||||||
assert (!l.containsLine(1));
|
assert (!l.containsLine(1));
|
||||||
assert (!l.containsLine(7));
|
assert (!l.containsLine(9));
|
||||||
l.addLine(5);
|
l.addLine(5);
|
||||||
assert (l.containsLine(7));
|
assert (l.containsLine(7));
|
||||||
l.addLine(40);
|
l.addLine(40);
|
||||||
l.addLine(35);
|
l.addLine(35);
|
||||||
foreach (i; 33 .. 43)
|
foreach (i; 33 .. 43)
|
||||||
assert (l.containsLine(i));
|
assert (l.containsLine(i));
|
||||||
stderr.writeln("Unit tests for LineSpans passed");
|
stderr.writeln("Unittest for LineSpans passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,17 @@ import analysis.unused;
|
||||||
|
|
||||||
enum AnalyzerCheck : int
|
enum AnalyzerCheck : int
|
||||||
{
|
{
|
||||||
style_check = 0x1,
|
style_check = 0x1,
|
||||||
enum_array_literal_check = 0x2,
|
enum_array_literal_check = 0x2,
|
||||||
exception_check = 0x4,
|
exception_check = 0x4,
|
||||||
delete_check = 0x8,
|
delete_check = 0x8,
|
||||||
float_operator_check = 0x10,
|
float_operator_check = 0x10,
|
||||||
number_style_check = 0x20,
|
number_style_check = 0x20,
|
||||||
object_const_check = 0x40,
|
object_const_check = 0x40,
|
||||||
backwards_range_check = 0x80,
|
backwards_range_check = 0x80,
|
||||||
if_else_same_check = 0x100,
|
if_else_same_check = 0x100,
|
||||||
constructor_check = 0x200,
|
constructor_check = 0x200,
|
||||||
unused_variable_check = 0x400,
|
unused_variable_check = 0x400,
|
||||||
all = 0x7FF
|
all = 0x7FF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1251,8 +1251,7 @@ incorrect;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This test is broken on 32bit x86 Atom under Linux
|
unittest
|
||||||
version (none) unittest
|
|
||||||
{
|
{
|
||||||
string sourceCode =
|
string sourceCode =
|
||||||
q{class ClassZero;
|
q{class ClassZero;
|
||||||
|
|
@ -1264,6 +1263,10 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
||||||
|
|
||||||
Parser p = getParserForUnittest(sourceCode, "parseClassDeclaration");
|
Parser p = getParserForUnittest(sourceCode, "parseClassDeclaration");
|
||||||
|
|
||||||
|
auto classZero = p.parseClassDeclaration();
|
||||||
|
assert (classZero.name.text == "ClassZero");
|
||||||
|
assert (classZero.structBody is null);
|
||||||
|
|
||||||
auto classOne = p.parseClassDeclaration();
|
auto classOne = p.parseClassDeclaration();
|
||||||
assert (classOne.name.text == "ClassOne"); // FIXME classOne.name.text is "ClassZero" on my machine TM
|
assert (classOne.name.text == "ClassOne"); // FIXME classOne.name.text is "ClassZero" on my machine TM
|
||||||
assert (classOne.structBody.declarations.length == 0);
|
assert (classOne.structBody.declarations.length == 0);
|
||||||
|
|
@ -1288,14 +1291,14 @@ class ClassFive(A, B) : Super if (someTest()) {}}c;
|
||||||
assert (classThree.structBody.declarations.length == 0,
|
assert (classThree.structBody.declarations.length == 0,
|
||||||
to!string(classThree.structBody.declarations.length));
|
to!string(classThree.structBody.declarations.length));
|
||||||
|
|
||||||
//auto classFour = p.parseClassDeclaration();
|
auto classFour = p.parseClassDeclaration();
|
||||||
//assert (classFour.name == "ClassFour", classFour.name.text);
|
assert (classFour.name.text == "ClassFour", classFour.name.text);
|
||||||
//assert (classFour.templateParameters !is null);
|
assert (classFour.templateParameters !is null);
|
||||||
//assert (classFour.baseClassList !is null);
|
assert (classFour.baseClassList !is null);
|
||||||
//assert (classFour.constraint !is null);
|
assert (classFour.constraint !is null);
|
||||||
//assert (classFour.baseClassList.items.length == 1);
|
assert (classFour.baseClassList.items.length == 1);
|
||||||
//assert (classFour.structBody.declarationOrInvariants.length == 0,
|
assert (classFour.structBody.declarations.length == 0,
|
||||||
// to!string(classFour.structBody.declarationOrInvariants.length));
|
to!string(classFour.structBody.declarations.length));
|
||||||
|
|
||||||
stderr.writeln("Unittest for parseClassDeclaration() passed.");
|
stderr.writeln("Unittest for parseClassDeclaration() passed.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue