diff --git a/src/Bicep.Core.IntegrationTests/Bicep.Core.IntegrationTests.csproj b/src/Bicep.Core.IntegrationTests/Bicep.Core.IntegrationTests.csproj index bee8a0f99da..4522a652e75 100644 --- a/src/Bicep.Core.IntegrationTests/Bicep.Core.IntegrationTests.csproj +++ b/src/Bicep.Core.IntegrationTests/Bicep.Core.IntegrationTests.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs index cd5c01496c1..548f788a8b2 100644 --- a/src/Bicep.Core.IntegrationTests/ScenarioTests.cs +++ b/src/Bicep.Core.IntegrationTests/ScenarioTests.cs @@ -15,6 +15,7 @@ namespace Bicep.Core.IntegrationTests public class ScenarioTests { [TestMethod] + // https://github.com/azure/bicep/issues/746 public void Test_Issue746() { var result = CompilationHelper.Compile(@" @@ -32,6 +33,7 @@ param l } [TestMethod] + // https://github.com/azure/bicep/issues/801 public void Test_Issue801() { var result = CompilationHelper.Compile( @@ -93,6 +95,7 @@ param name string } [TestMethod] + // https://github.com/azure/bicep/issues/982 public void Test_Issue982() { var result = CompilationHelper.Compile(@" @@ -117,6 +120,7 @@ param serverFarmId string } [TestMethod] + // https://github.com/azure/bicep/issues/1093 public void Test_Issue1093() { var result = CompilationHelper.Compile( @@ -156,6 +160,7 @@ param rgName string } [TestMethod] + // https://github.com/azure/bicep/issues/1173 public void Test_Issue1173() { var result = CompilationHelper.Compile( @@ -310,6 +315,7 @@ param rtName string } [TestMethod] + // https://github.com/azure/bicep/issues/1185 public void Test_Issue1185() { var result = CompilationHelper.Compile( @@ -338,6 +344,7 @@ param mgName string } [TestMethod] + // https://github.com/azure/bicep/issues/1332 public void Test_Issue1332() { var result = CompilationHelper.Compile(@" @@ -354,6 +361,7 @@ public void Test_Issue1332() } [TestMethod] + // https://github.com/azure/bicep/issues/486 public void Test_Issue486() { var result = CompilationHelper.Compile(@" @@ -371,6 +379,7 @@ public void Test_Issue486() } [TestMethod] + // https://github.com/azure/bicep/issues/1362 public void Test_Issue1362_1() { var result = CompilationHelper.Compile( @@ -390,6 +399,7 @@ public void Test_Issue1362_1() } [TestMethod] + // https://github.com/azure/bicep/issues/1362 public void Test_Issue1362_2() { var result = CompilationHelper.Compile( @@ -409,6 +419,7 @@ public void Test_Issue1362_2() } [TestMethod] + // https://github.com/azure/bicep/issues/1402 public void Test_Issue1402() { var result = CompilationHelper.Compile( @@ -429,6 +440,7 @@ public void Test_Issue1402() } [TestMethod] + // https://github.com/azure/bicep/issues/1391 public void Test_Issue1391() { var result = CompilationHelper.Compile(@" @@ -449,6 +461,7 @@ public void Test_Issue1391() } [TestMethod] + // https://github.com/azure/bicep/issues/1454 public void Test_Issue1454() { var result = CompilationHelper.Compile( @@ -513,6 +526,7 @@ param location string } [TestMethod] + // https://github.com/azure/bicep/issues/1465 public void Test_Issue1465() { var result = CompilationHelper.Compile(@" @@ -526,6 +540,7 @@ public void Test_Issue1465() } [TestMethod] + // https://github.com/azure/bicep/issues/822 public void Test_Issue822() { var result = CompilationHelper.Compile( @@ -558,6 +573,7 @@ param name string } [TestMethod] + // https://github.com/azure/bicep/issues/822 public void Test_Issue822_scoped() { var result = CompilationHelper.Compile( @@ -587,6 +603,7 @@ param name string } [TestMethod] + // https://github.com/azure/bicep/issues/1388 public void Test_Issue1388() { var result = CompilationHelper.Compile(@" @@ -644,6 +661,7 @@ param groupReaderId string } [TestMethod] + // https://github.com/azure/bicep/issues/1364 public void Test_Issue1364() { var result = CompilationHelper.Compile(@" @@ -657,6 +675,7 @@ public void Test_Issue1364() } [TestMethod] + // https://github.com/azure/bicep/issues/569 public void Test_Issue569_success() { var result = CompilationHelper.Compile(@" @@ -673,6 +692,7 @@ param myparam string } [TestMethod] + // https://github.com/azure/bicep/issues/569 public void Test_Issue569_duplicates() { var result = CompilationHelper.Compile(@" @@ -688,6 +708,7 @@ public void Test_Issue569_duplicates() } [TestMethod] + // https://github.com/azure/bicep/issues/569 public void Test_Issue569_outputs_cannot_be_referenced() { var result = CompilationHelper.Compile(@" @@ -702,6 +723,7 @@ public void Test_Issue569_outputs_cannot_be_referenced() } [TestMethod] + // https://github.com/azure/bicep/issues/1599 public void Test_Issue1599() { var result = CompilationHelper.Compile(@" @@ -716,6 +738,7 @@ public void Test_Issue1599() } [TestMethod] + // https://github.com/azure/bicep/issues/1661 public void Test_Issue1661() { // Issue 1661 only repros if global-resources.bicep exists and kevault-secrets.bicep does not @@ -804,6 +827,7 @@ param tags object } [TestMethod] + // https://github.com/azure/bicep/issues/1592 public void Test_Issue1592() { var result = CompilationHelper.Compile( @@ -821,6 +845,7 @@ public void Test_Issue1592() } [TestMethod] + // https://github.com/azure/bicep/issues/1592 public void Test_Issue1592_special_cases() { var result = CompilationHelper.Compile( @@ -844,6 +869,7 @@ param someParam string } [TestMethod] + // https://github.com/azure/bicep/issues/1432 public void Test_Issue1432() { var result = CompilationHelper.Compile(@" @@ -861,6 +887,7 @@ public void Test_Issue1432() } [TestMethod] + // https://github.com/azure/bicep/issues/1817 public void Test_Issue1817() { var result = CompilationHelper.Compile(@" @@ -877,6 +904,7 @@ public void Test_Issue1817() } [TestMethod] + // https://github.com/azure/bicep/issues/1630 public void Test_Issue1630() { var result = CompilationHelper.Compile(@" @@ -901,6 +929,7 @@ public void Test_Issue1630() } [TestMethod] + // https://github.com/azure/bicep/issues/1627 public void Test_Issue1627() { var result = CompilationHelper.Compile(("main.bicep", @" @@ -929,6 +958,7 @@ param foo int } [TestMethod] + // https://github.com/azure/bicep/issues/1941 public void Test_Issue1941() { var result = CompilationHelper.Compile(@" @@ -993,6 +1023,7 @@ param location string } [TestMethod] + // https://github.com/azure/bicep/issues/657 public void Test_Issue657_discriminators() { var customTypes = new [] { @@ -1090,6 +1121,7 @@ public void Test_Issue657_discriminators() } [TestMethod] + // https://github.com/azure/bicep/issues/657 public void Test_Issue657_enum() { var customTypes = new [] { @@ -1178,6 +1210,7 @@ public void Test_Issue657_enum() } [TestMethod] + // https://github.com/azure/bicep/issues/1985 public void Test_Issue1985() { var result = CompilationHelper.Compile(@" @@ -1212,6 +1245,7 @@ public void Test_Issue1985() } [TestMethod] + // https://github.com/azure/bicep/issues/1986 public void Test_Issue1986() { var result = CompilationHelper.Compile(@" @@ -1252,6 +1286,7 @@ public void Test_Issue1986() } [TestMethod] + // https://github.com/azure/bicep/issues/1986 public void Test_Issue1986_nested() { var result = CompilationHelper.Compile(@" @@ -1291,6 +1326,7 @@ public void Test_Issue1986_nested() } [TestMethod] + // https://github.com/azure/bicep/issues/1986 public void Test_Issue1986_loops() { var result = CompilationHelper.Compile(@" @@ -1333,5 +1369,58 @@ public void Test_Issue1986_loops() "[resourceId('Microsoft.Network/virtualNetworks', variables('vnets')[copyIndex()])]", // dependsOn should include the virtualNetwork parent resource }); } + + [TestMethod] + // https://github.com/azure/bicep/issues/1993 + public void Test_Issue1993() + { + var result = CompilationHelper.Compile(@" +//""flat"" string +var jsonStringFlat = '[""one"",""two"",""three"" ]' + +//Good Array +var jsonStringGood = ''' +[ + ""one"", + ""two"", + ""three"" +]''' + +//Bad Array +var jsonStringBad = ''' +[ + ""one"", + ""two"", + ""three"" +] +''' +var jsonArrayFlat = json(jsonStringFlat) +var jsonArrayGood = json(jsonStringGood) +var jsonArrayBad = json(jsonStringBad) + +output flatArray array = [for (name, i) in jsonArrayFlat: { + element: name +}] + +output goodArray array = [for (name, i) in jsonArrayGood: { + element: name +}] + +output badArray array = [for (name, i) in jsonArrayBad : { + element: name +}] +"); + + + var evaluated = TemplateEvaluator.Evaluate(result.Template); + var expectedOutput = new JArray { + new JObject { ["element"] = "one" }, + new JObject { ["element"] = "two" }, + new JObject { ["element"] = "three" }, + }; + evaluated.Should().HaveValueAtPath("$.outputs['flatArray'].value", expectedOutput); + evaluated.Should().HaveValueAtPath("$.outputs['goodArray'].value", expectedOutput); + evaluated.Should().HaveValueAtPath("$.outputs['badArray'].value", expectedOutput); + } } } \ No newline at end of file diff --git a/src/Bicep.Core.Samples/Files/Variables_LF/main.json b/src/Bicep.Core.Samples/Files/Variables_LF/main.json index e505c746d04..0ebe70fd977 100644 --- a/src/Bicep.Core.Samples/Files/Variables_LF/main.json +++ b/src/Bicep.Core.Samples/Files/Variables_LF/main.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "dev", - "templateHash": "4515800226062018461" + "templateHash": "5466344590259907996" } }, "parameters": { @@ -34,7 +34,7 @@ "doubleInterp": "[format('abc{0}_{1}', format('def{0}', 123), format('{0}{1}', 456, 789))]", "curliesInInterp": "[format('{{{0}{{0}}{1}}}', 123, true())]", "bracketInTheMiddle": "a[b]", - "bracketAtBeginning": "[[test", + "bracketAtBeginning": "[test", "enclosingBrackets": "[[test]", "emptyJsonArray": "[[]", "interpolatedBrackets": "[format('[{0}]', variables('myInt'))]", diff --git a/src/Bicep.Core/Bicep.Core.csproj b/src/Bicep.Core/Bicep.Core.csproj index bb8b388af47..03543c1a476 100644 --- a/src/Bicep.Core/Bicep.Core.csproj +++ b/src/Bicep.Core/Bicep.Core.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/Bicep.Decompiler/Bicep.Decompiler.csproj b/src/Bicep.Decompiler/Bicep.Decompiler.csproj index 84fa7b12232..229c21c3e48 100644 --- a/src/Bicep.Decompiler/Bicep.Decompiler.csproj +++ b/src/Bicep.Decompiler/Bicep.Decompiler.csproj @@ -11,7 +11,7 @@ - + \ No newline at end of file