Merge pull request #2454 from tastywheattasteslikechicken/FixVtableAbort
[mono.git] / mcs / class / Microsoft.Build.Engine / Test / various / Conditions.cs
index f7aa66819cdc4b61f5667d7af669efd8db49c535..c3c8dacabc5c4d3e19f5c2142195cffff4297174 100644 (file)
@@ -284,6 +284,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                }
 
                [Test]
+               [Category ("NotDotNet")]
                public void TestCondition10 ()
                {
                        Engine engine = new Engine (Consts.BinPath);
@@ -336,6 +337,95 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                        Assert.AreEqual ("fr_c.txt", bgp [2].FinalItemSpec, "A4");
                }
 
+               // Test shortcircuiting
+               [Test]
+               public void TestCondition12 ()
+               {
+                       Engine engine = new Engine (Consts.BinPath);
+                       Project proj = engine.CreateNewProject ();
+
+                       string documentString = @"
+                               <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                       <PropertyGroup>
+                                               <A Condition=""'$(NonExistant)' != '' and $(NonExistant)""></A>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       proj.LoadXml (documentString);
+
+                       Assert.IsNull (proj.EvaluatedProperties ["A"], "A1");
+               }
+
+               [Test]
+               public void TestCondition_References ()
+               {
+                       Engine engine = new Engine (Consts.BinPath);
+                       Project proj = engine.CreateNewProject ();
+
+                       string documentString = @"
+                               <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                       <PropertyGroup>
+                                               <A Condition=""$([System.String]::new('test').StartsWith(`te`))"">valid</A>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       proj.LoadXml (documentString);
+
+                       Assert.AreEqual ("valid", proj.GetEvaluatedProperty ("A"), "#1");
+               }
+
+               [Test]
+               public void TestHasTrailingSlash1 ()
+               {
+                       Engine engine = new Engine (Consts.BinPath);
+                       Project proj = engine.CreateNewProject ();
+
+                       string documentString = @"
+                               <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                       <PropertyGroup>
+                                               <EmptyProp></EmptyProp>
+                                               <WithTrailingBackSlash>foo\ </WithTrailingBackSlash>
+                                               <WithTrailingFwdSlash>foo/  </WithTrailingFwdSlash>
+                                               <NoTrailing>Foo</NoTrailing>
+
+                                               <A Condition="" HasTrailingSlash('$(EmptyProp)') ""></A>
+                                               <B Condition="" HasTrailingSlash('$(WithTrailingBackSlash)') ""></B>
+                                               <C Condition="" HasTrailingSlash('$(WithTrailingFwdSlash)') ""></C>
+                                               <D Condition="" HasTrailingSlash('$(NoTrailing)') ""></D>
+                                               <E Condition="" HasTrailingSlash('$(NonExistant)') ""></E>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       proj.LoadXml (documentString);
+
+                       Assert.IsNull (proj.EvaluatedProperties ["A"], "A1");
+                       Assert.IsNotNull (proj.EvaluatedProperties ["B"], "A2");
+                       Assert.IsNotNull (proj.EvaluatedProperties ["C"], "A3");
+                       Assert.IsNull (proj.EvaluatedProperties ["D"], "A4");
+                       Assert.IsNull (proj.EvaluatedProperties ["E"], "A5");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidProjectFileException))]
+               public void TestUnknownFunction ()
+               {
+                       Engine engine = new Engine (Consts.BinPath);
+                       Project proj = engine.CreateNewProject ();
+
+                       string documentString = @"
+                               <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                       <PropertyGroup>
+                                               <A Condition="" NonExistantFunction('$(EmptyProp)') ""></A>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       proj.LoadXml (documentString);
+               }
+
                [Test]
                [ExpectedException (typeof (InvalidProjectFileException))]
                public void TestIncorrectCondition1 ()
@@ -431,5 +521,24 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
 
                        proj.LoadXml (documentString);
                }
+
+               [Test]
+               [ExpectedException (typeof (InvalidProjectFileException))]
+               public void TestIncorrectCondition6 ()
+               {
+                       Engine engine = new Engine (Consts.BinPath);
+                       Project proj = engine.CreateNewProject ();
+
+                       string documentString = @"
+                               <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                       <ItemGroup>
+                                               <A Include='a' Condition=""'$(NonExistant)' != '' or $(NonExistant)""/>
+                                       </ItemGroup>
+                               </Project>
+                       ";
+
+                       proj.LoadXml (documentString);
+               }
+
        }
 }