Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c4ffa35c
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c4ffa35c
编写于
3月 30, 2017
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a few more tests for both C# and VB
上级
8273d55d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
122 addition
and
0 deletion
+122
-0
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IVariableDeclaration.cs
...mantic/IOperation/IOperationTests_IVariableDeclaration.cs
+39
-0
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IVariableDeclaration.vb
...mantic/IOperation/IOperationTests_IVariableDeclaration.vb
+83
-0
未找到文件。
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IVariableDeclaration.cs
浏览文件 @
c4ffa35c
...
...
@@ -251,6 +251,45 @@ static void Main(string[] args)
VerifyOperationTreeForTest
<
VariableDeclarationSyntax
>(
source
,
expectedOperationTree
);
}
[
Fact
]
public
void
InvalidArrayDeclaration
()
{
string
source
=
@"
class Program
{
static void Main(string[] args)
{
/*<bind>*/int[2, 3] a/*</bind>*/;
}
}
"
;
string
expectedOperationTree
=
@"
IVariableDeclarationStatement (1 variables) (OperationKind.VariableDeclarationStatement)
IVariableDeclaration: System.Int32[,] a (OperationKind.VariableDeclaration)
"
;
VerifyOperationTreeForTest
<
VariableDeclarationSyntax
>(
source
,
expectedOperationTree
);
}
[
Fact
]
public
void
InvalidArrayMultipleDeclaration
()
{
string
source
=
@"
class Program
{
static void Main(string[] args)
{
/*<bind>*/int[2, 3] a, b/*</bind>*/;
}
}
"
;
string
expectedOperationTree
=
@"
IVariableDeclarationStatement (2 variables) (OperationKind.VariableDeclarationStatement)
IVariableDeclaration: System.Int32[,] a (OperationKind.VariableDeclaration)
IVariableDeclaration: System.Int32[,] b (OperationKind.VariableDeclaration)
"
;
VerifyOperationTreeForTest
<
VariableDeclarationSyntax
>(
source
,
expectedOperationTree
);
}
#
endregion
#
region
Fixed
Statements
...
...
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IVariableDeclaration.vb
浏览文件 @
c4ffa35c
...
...
@@ -335,6 +335,28 @@ IVariableDeclarationStatement (3 variables) (OperationKind.VariableDeclarationSt
VerifyOperationTreeForTest
(
Of
LocalDeclarationStatementSyntax
)(
source
,
expectedOperationTree
)
End
Sub
<
Fact
(),
WorkItem
(
17599
,
"https://github.com/dotnet/roslyn/issues/17599"
)
>
Public
Sub
MixedDimAsNewAndEqualsDeclarationsReversedOrder
()
Dim
source
=
<
!
[
CDATA
[
Module
Program
Sub
Main
(
args
As
String
())
Dim
b1
As
Boolean
,
i1
,
i2
As
New
Integer
'BIND:"Dim b1 As Boolean, i1, i2 As New Integer"
End
Sub
End
Module
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IVariableDeclarationStatement
(
3
variables
)
(
OperationKind
.
VariableDeclarationStatement
)
IVariableDeclaration
:
b1
As
System
.
Boolean
(
OperationKind
.
VariableDeclaration
)
IVariableDeclaration
:
i1
As
System
.
Int32
(
OperationKind
.
VariableDeclaration
)
Initializer
:
IObjectCreationExpression
(
Constructor
:
Sub
System
.
Int32
.
.
ctor
())
(
OperationKind
.
ObjectCreationExpression
,
Type
:
System
.
Int32
)
IVariableDeclaration
:
i2
As
System
.
Int32
(
OperationKind
.
VariableDeclaration
)
Initializer
:
IObjectCreationExpression
(
Constructor
:
Sub
System
.
Int32
.
.
ctor
())
(
OperationKind
.
ObjectCreationExpression
,
Type
:
System
.
Int32
)
]]
>
.
Value
VerifyOperationTreeForTest
(
Of
LocalDeclarationStatementSyntax
)(
source
,
expectedOperationTree
)
End
Sub
<
Fact
(),
WorkItem
(
17599
,
"https://github.com/dotnet/roslyn/issues/17599"
)
>
Public
Sub
DimAsNewMultipleDeclarationsSameInitializerInstance
()
Dim
source
=
<
!
[
CDATA
[
...
...
@@ -366,6 +388,67 @@ End Module
Assert
.
Same
(
var1
.
InitialValue
,
var2
.
InitialValue
)
End
Sub
<
Fact
(),
WorkItem
(
17599
,
"https://github.com/dotnet/roslyn/issues/17599"
)
>
Public
Sub
ArrayDeclarationWithLength
()
Dim
source
=
<
!
[
CDATA
[
Module
Program
Sub
Main
(
args
As
String
())
Dim
i1
(
2
)
As
Integer
'BIND:"Dim i1(2) As Integer"
End
Sub
End
Module
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IVariableDeclarationStatement
(
1
variables
)
(
OperationKind
.
VariableDeclarationStatement
)
IVariableDeclaration
:
i1
As
System
.
Int32
()
(
OperationKind
.
VariableDeclaration
)
Initializer
:
IArrayCreationExpression
(
Dimension
sizes
:
1
,
Element
Type
:
System
.
Int32
)
(
OperationKind
.
ArrayCreationExpression
,
Type
:
System
.
Int32
())
IBinaryOperatorExpression
(
BinaryOperationKind
.
IntegerAdd
)
(
OperationKind
.
BinaryOperatorExpression
,
Type
:
System
.
Int32
,
Constant
:
3
)
Left
:
ILiteralExpression
(
Text
:
2
)
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
2
)
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
1
)
]]
>
.
Value
VerifyOperationTreeForTest
(
Of
LocalDeclarationStatementSyntax
)(
source
,
expectedOperationTree
)
End
Sub
<
Fact
(),
WorkItem
(
17599
,
"https://github.com/dotnet/roslyn/issues/17599"
)
>
Public
Sub
ArrayDeclarationMultipleVariables
()
Dim
source
=
<
!
[
CDATA
[
Module
Program
Sub
Main
(
args
As
String
())
Dim
i1
(),
i2
As
Integer
'BIND:"Dim i1(), i2 As Integer"
End
Sub
End
Module
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IVariableDeclarationStatement
(
2
variables
)
(
OperationKind
.
VariableDeclarationStatement
)
IVariableDeclaration
:
i1
As
System
.
Int32
()
(
OperationKind
.
VariableDeclaration
)
IVariableDeclaration
:
i2
As
System
.
Int32
(
OperationKind
.
VariableDeclaration
)
]]
>
.
Value
VerifyOperationTreeForTest
(
Of
LocalDeclarationStatementSyntax
)(
source
,
expectedOperationTree
)
End
Sub
<
Fact
(),
WorkItem
(
17599
,
"https://github.com/dotnet/roslyn/issues/17599"
)
>
Public
Sub
ArrayDeclarationInvalidAsNew
()
Dim
source
=
<
!
[
CDATA
[
Module
Program
Sub
Main
(
args
As
String
())
Dim
i1
(
2
)
As
New
Integer
'BIND:"Dim i1(2) As New Integer"
End
Sub
End
Module
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IVariableDeclarationStatement
(
1
variables
)
(
OperationKind
.
VariableDeclarationStatement
,
IsInvalid
)
IVariableDeclaration
:
i1
As
System
.
Int32
()
(
OperationKind
.
VariableDeclaration
,
IsInvalid
)
Initializer
:
IInvalidExpression
(
OperationKind
.
InvalidExpression
,
Type
:
System
.
Int32
(),
IsInvalid
)
]]
>
.
Value
VerifyOperationTreeForTest
(
Of
LocalDeclarationStatementSyntax
)(
source
,
expectedOperationTree
)
End
Sub
#End Region
#Region "Using Statements"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录