Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2010-01-24 19:13:58 +0300
committerSebastien Pouliot <sebastien@ximian.com>2010-01-24 19:13:58 +0300
commita56e9b97c45408c4c47a692e0c9532ab3b3d6fc1 (patch)
tree5788c92f5c9d57f52f7237e8afddea2ea4109b2a /gendarme/rules/Gendarme.Rules.Smells/Test
parent63d8bd671e83201fda4a17d30fa763749c80a29a (diff)
fix some unit tests when compiled with CSC
svn path=/trunk/mono-tools/; revision=150094
Diffstat (limited to 'gendarme/rules/Gendarme.Rules.Smells/Test')
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs17
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog7
2 files changed, 23 insertions, 1 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs
index 2ce507e0..8d29f214 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs
@@ -92,9 +92,18 @@ namespace Test.Rules.Smells {
[Test]
public void SuccessOnMethodWithoutSwitchAndGeneratorTest ()
{
- AssertRuleDoesNotApply (Type.GetType ("Test.Rules.Smells.AvoidSwitchStatementsTest+<MethodWithoutSwitchAndGenerator>c__Iterator0"), "MoveNext");
+ // compiler generated code (mono gmcs)
+ Type type = Type.GetType ("Test.Rules.Smells.AvoidSwitchStatementsTest+<MethodWithoutSwitchAndGenerator>c__Iterator0");
+ if (type == null) {
+ // if not found try the output of MS csc
+ type = Type.GetType ("Test.Rules.Smells.AvoidSwitchStatementsTest+<MethodWithoutSwitchAndGenerator>d__0");
+ }
+ Assert.IsNotNull (type, "compiler generated type name");
+ AssertRuleDoesNotApply (type, "MoveNext");
}
+ // if the number of elements in the swicth is small (like <= 6) then CSC (but not GMCS)
+ // well generate code using String::op_Equality instead of a switch IL statement
void SwitchWithStrings (string sample)
{
switch (sample) {
@@ -102,7 +111,13 @@ namespace Test.Rules.Smells {
case "Bar":
return;
case "Baz":
+ case "Bad":
throw new ArgumentException ("sample");
+ case "Zoo":
+ case "Yoo":
+ throw new FormatException ("sample");
+ case "*":
+ break;
}
}
diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
index 7b90e337..c396f1ff 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
+++ b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-24 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AvoidSwitchStatementsTest.cs: Deal with different compiler
+ generated names for iterators (gmcs versus csc). Also make the
+ switch/case on string longer (> 6) so CSC won't optimize it
+ as a serie of String::op_Equality (failing the unit test)
+
2008-12-22 NĂ©stor Salceda <nestor.salceda@gmail.com>
* AvoidSwitchStatementsTest.cs: Added a test for table-driven