diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wix/WixToolset.Core/Preprocessor.cs | 4 | ||||
| -rw-r--r-- | src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs | 46 |
2 files changed, 48 insertions, 2 deletions
diff --git a/src/wix/WixToolset.Core/Preprocessor.cs b/src/wix/WixToolset.Core/Preprocessor.cs index 3abe0b5f..084da8d0 100644 --- a/src/wix/WixToolset.Core/Preprocessor.cs +++ b/src/wix/WixToolset.Core/Preprocessor.cs | |||
| @@ -1089,10 +1089,10 @@ namespace WixToolset.Core | |||
| 1089 | else if (operation.Length == 0) | 1089 | else if (operation.Length == 0) |
| 1090 | { | 1090 | { |
| 1091 | // There is no right side of the equation. | 1091 | // There is no right side of the equation. |
| 1092 | // If the variable was evaluated, it exists, so the expression is true | 1092 | // If the variable was evaluated, test to see if it is a "false" value. |
| 1093 | if (startsWithVariable) | 1093 | if (startsWithVariable) |
| 1094 | { | 1094 | { |
| 1095 | expressionValue = true; | 1095 | expressionValue = !(leftValue == String.Empty || leftValue == "0" || leftValue == "false" || leftValue == "no"); |
| 1096 | } | 1096 | } |
| 1097 | else | 1097 | else |
| 1098 | { | 1098 | { |
diff --git a/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs b/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs index b3ad0803..bbae4636 100644 --- a/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs +++ b/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs | |||
| @@ -61,6 +61,52 @@ namespace WixToolsetTest.Core | |||
| 61 | WixAssert.CompareLineByLine(expected, actual); | 61 | WixAssert.CompareLineByLine(expected, actual); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | [Fact] | ||
| 65 | public void CanPreprocessFalsyCondition() | ||
| 66 | { | ||
| 67 | var input = String.Join(Environment.NewLine, | ||
| 68 | "<Wix>", | ||
| 69 | "<?define A=0?>", | ||
| 70 | "<?if $(A) ?>", | ||
| 71 | " <Fragment />", | ||
| 72 | "<?endif?>", | ||
| 73 | "</Wix>" | ||
| 74 | ); | ||
| 75 | var expected = new[] | ||
| 76 | { | ||
| 77 | "<Wix />" | ||
| 78 | }; | ||
| 79 | |||
| 80 | var result = PreprocessFromString(input); | ||
| 81 | |||
| 82 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 83 | WixAssert.CompareLineByLine(expected, actual); | ||
| 84 | } | ||
| 85 | |||
| 86 | [Fact] | ||
| 87 | public void CanPreprocessTruthyCondition() | ||
| 88 | { | ||
| 89 | var input = String.Join(Environment.NewLine, | ||
| 90 | "<Wix>", | ||
| 91 | "<?define A=1?>", | ||
| 92 | "<?if $(A) ?>", | ||
| 93 | " <Fragment />", | ||
| 94 | "<?endif?>", | ||
| 95 | "</Wix>" | ||
| 96 | ); | ||
| 97 | var expected = new[] | ||
| 98 | { | ||
| 99 | "<Wix>", | ||
| 100 | " <Fragment />", | ||
| 101 | "</Wix>" | ||
| 102 | }; | ||
| 103 | |||
| 104 | var result = PreprocessFromString(input); | ||
| 105 | |||
| 106 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 107 | WixAssert.CompareLineByLine(expected, actual); | ||
| 108 | } | ||
| 109 | |||
| 64 | private static IPreprocessResult PreprocessFromString(string xml) | 110 | private static IPreprocessResult PreprocessFromString(string xml) |
| 65 | { | 111 | { |
| 66 | using var stringReader = new StringReader(xml); | 112 | using var stringReader = new StringReader(xml); |
