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