Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cqthyy/params integration unit tests #7352

Merged
merged 17 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
created bicepparam sample file for integration test, unit test fixes
  • Loading branch information
Cathy Cao committed Jun 22, 2022
commit 55ff8c237c09e6434b5de3222bc49b4c0425c00b
58 changes: 58 additions & 0 deletions src/Bicep.Core.Samples/Files/Parameters_LF/main.bicepparam
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git by default will convert line endings depending on whether you're checking out code on Windows (\r\n) or Unix/Linux (\n). This causes problems for the baseline tests - to fix this, you may need to copy the config we added for .bicep to your new extension - to respect the newline format of the file and avoid converting on different platforms:

bicep/.gitattributes

Lines 1 to 2 in 6d0eeaf

*.bicep -text
*.ts text eol=lf

This is a
multiline comment!
*/

// This is a single line comment

// using keyword for specifying a Bicep file
using './main.bicep/'

// parameter assignment to literals
param myInt = 42
param myStr = "hello world!"
param myBool = true

// parameter assignment to objects
param myObj = {
name: 'vm1'
location: 'westus'
}
param myComplexObj = {
enabled: true
name: 'complex object!'
priority: 3
data: {
a: 'b'
c: [
'd'
'e'
]
}
}

// parameter assignment to arrays
param myIntArr = [
1
2
3
4
5
]
param myStrArr = [
'ant'
'bear'
'cat'
'dog'
]
param myComplexArr = [
'eagle'
21
false
{
f: [
'g'
'h'
]
}
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the we allow non-literal values at syntax level, we can add some test cases to ensure they can also be parsed, for example:

param myFunction = union({}, {})

param myComplexArrWithFunction = [
  {
    foo: resourceGroup()
  }
  true
  [
    42
  ]
]

They can also be useful for validating semantic diagnostics later, since we are going to implement semantic checking to block non-literal values.

2 changes: 1 addition & 1 deletion src/Bicep.Core.UnitTests/Parsing/ParamsParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void TestParameterArrayAssignment(String text)
}

[DataTestMethod]
[DataRow("using './bicep.main' \n")]
[DataRow("using './main.bicep' \n")]
public void TestParsingUsingKeyword(String text)
{
var programSyntax = ParamsParserHelper.ParamsParse(text);
Expand Down