Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
16219e30
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,发现更多精彩内容 >>
提交
16219e30
编写于
1月 30, 2015
作者:
V
vladres
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove some invalid GetHashCode tests, put the other under #if (changeset 1407835)
上级
af1b89e8
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
49 addition
and
32 deletion
+49
-32
src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs
...ers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs
+3
-1
src/Compilers/Core/CodeAnalysisTest/CorLibTypesTests.cs
src/Compilers/Core/CodeAnalysisTest/CorLibTypesTests.cs
+19
-9
src/Compilers/Core/CodeAnalysisTest/FileLinePositionSpanTests.cs
...pilers/Core/CodeAnalysisTest/FileLinePositionSpanTests.cs
+14
-4
src/Compilers/Core/CodeAnalysisTest/LinePositionTests.cs
src/Compilers/Core/CodeAnalysisTest/LinePositionTests.cs
+9
-0
src/Compilers/Core/CodeAnalysisTest/MetadataReferences/AssemblyPortabilityPolicyTests.cs
...Test/MetadataReferences/AssemblyPortabilityPolicyTests.cs
+0
-1
src/Compilers/VisualBasic/Test/Emit/Emit/EmitMetadata.vb
src/Compilers/VisualBasic/Test/Emit/Emit/EmitMetadata.vb
+0
-1
src/Compilers/VisualBasic/Test/Semantic/Compilation/ReferenceManagerTests.vb
...lBasic/Test/Semantic/Compilation/ReferenceManagerTests.vb
+0
-9
src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
...lBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
+0
-1
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/TypeTests.vb
.../VisualBasic/Test/Symbol/SymbolsTests/Source/TypeTests.vb
+3
-2
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb
.../VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb
+1
-2
src/Compilers/VisualBasic/Test/Syntax/TestSyntaxNodes.vb
src/Compilers/VisualBasic/Test/Syntax/TestSyntaxNodes.vb
+0
-2
未找到文件。
src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs
浏览文件 @
16219e30
...
...
@@ -1571,8 +1571,10 @@ class C<T, U, V>
Assert
.
Equal
(
actualTypeParameters
[
0
].
GetHashCode
(),
actualTypeParameters
[
1
].
GetHashCode
());
Assert
.
NotEqual
(
actualTypeParameters
[
0
],
actualTypeParameters
[
2
]);
Assert
.
NotEqual
(
actualTypeParameters
[
0
].
GetHashCode
(),
actualTypeParameters
[
2
].
GetHashCode
());
#if !DISABLE_GOOD_HASH_TESTS
Assert
.
NotEqual
(
actualTypeParameters
[
0
].
GetHashCode
(),
actualTypeParameters
[
2
].
GetHashCode
());
#endif
}
[
Fact
]
...
...
src/Compilers/Core/CodeAnalysisTest/CorLibTypesTests.cs
浏览文件 @
16219e30
...
...
@@ -134,19 +134,29 @@ public void ConstantValueGetHashCodeTest01()
var
cv82
=
ConstantValue
.
Create
((
ulong
)
123456789
);
Assert
.
Equal
(
cv81
.
GetHashCode
(),
cv82
.
GetHashCode
());
cv11
=
ConstantValue
.
Create
(
"123"
);
cv12
=
ConstantValue
.
Create
(
"321"
);
Assert
.
NotEqual
(
cv11
.
GetHashCode
(),
cv12
.
GetHashCode
());
var
cv91
=
ConstantValue
.
Create
(
1.1
m
);
var
cv92
=
ConstantValue
.
Create
(
1.1
m
);
Assert
.
Equal
(
cv91
.
GetHashCode
(),
cv92
.
GetHashCode
());
}
cv11
=
ConstantValue
.
Create
(
1.1
m
);
cv12
=
ConstantValue
.
Create
(
1.1
m
);
Assert
.
Equal
(
cv11
.
GetHashCode
(),
cv12
.
GetHashCode
());
// In general, different values are not required to have different hash codes.
// But for perf reasons we want hash functions with a good distribution,
// so we expect hash codes to differ if a single component is incremented.
// But program correctness should be preserved even with a null hash function,
// so we need a way to disable these tests during such correctness validation.
#if !DISABLE_GOOD_HASH_TESTS
[
Fact
]
public
void
ConstantValueGetHashCodeTest02
()
{
var
cv1
=
ConstantValue
.
Create
(
"1"
);
var
cv2
=
ConstantValue
.
Create
(
"2"
);
cv11
=
ConstantValue
.
Create
(
DateTime
.
Now
);
cv12
=
ConstantValue
.
Create
(
new
DateTime
());
Assert
.
NotEqual
(
cv11
.
GetHashCode
(),
cv12
.
GetHashCode
());
Assert
.
NotEqual
(
cv1
.
GetHashCode
(),
cv2
.
GetHashCode
());
}
#endif
[
Fact
]
public
void
ConstantValueToStringTest01
()
{
...
...
src/Compilers/Core/CodeAnalysisTest/FileLinePositionSpanTests.cs
浏览文件 @
16219e30
...
...
@@ -50,22 +50,32 @@ public void Ctor1()
});
}
// In general, different values are not required to have different hash codes.
// But for perf reasons we want hash functions with a good distribution,
// so we expect hash codes to differ if a single component is incremented.
// But program correctness should be preserved even with a null hash function,
// so we need a way to disable these tests during such correctness validation.
#if !DISABLE_GOOD_HASH_TESTS
[
Fact
]
public
void
SaneHashCode
()
{
var
hash1
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
1
,
2
),
new
LinePosition
(
3
,
5
)).
GetHashCode
();
var
hash2
=
new
FileLinePositionSpan
(
"C:\\foo1.cs"
,
new
LinePosition
(
1
,
2
),
new
LinePosition
(
3
,
5
)).
GetHashCode
();
var
hash3
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
1
,
3
),
new
LinePosition
(
3
,
5
)).
GetHashCode
();
var
hash4
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
1
,
1
),
new
LinePosition
(
6
,
5
)).
GetHashCode
();
var
hash4
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
1
,
2
),
new
LinePosition
(
6
,
5
)).
GetHashCode
();
var
hash5
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
2
,
2
),
new
LinePosition
(
6
,
5
)).
GetHashCode
();
var
hash6
=
new
FileLinePositionSpan
(
"C:\\foo.cs"
,
new
LinePosition
(
2
,
2
),
new
LinePosition
(
6
,
8
)).
GetHashCode
();
Assert
.
NotEqual
(
hash1
,
hash2
);
Assert
.
NotEqual
(
hash1
,
hash3
);
Assert
.
NotEqual
(
hash1
,
hash4
);
Assert
.
NotEqual
(
hash2
,
hash3
);
Assert
.
NotEqual
(
hash2
,
hash4
);
Assert
.
NotEqual
(
hash3
,
hash4
);
Assert
.
NotEqual
(
hash4
,
hash5
);
Assert
.
NotEqual
(
hash6
,
hash6
);
}
#endif
[
Fact
]
public
void
TestToString
()
{
...
...
src/Compilers/Core/CodeAnalysisTest/LinePositionTests.cs
浏览文件 @
16219e30
...
...
@@ -45,6 +45,13 @@ public void Ctor3()
Assert
.
Equal
(
13
,
lp
.
Character
);
}
// In general, different values are not required to have different hash codes.
// But for perf reasons we want hash functions with a good distribution,
// so we expect hash codes to differ if a single component is incremented.
// But program correctness should be preserved even with a null hash function,
// so we need a way to disable these tests during such correctness validation.
#if !DISABLE_GOOD_HASH_TESTS
[
Fact
]
public
void
SaneHashCode
()
{
...
...
@@ -61,6 +68,8 @@ public void SaneHashCode()
Assert
.
NotEqual
(
hash3
,
hash4
);
}
#endif
[
Fact
]
public
void
CompareTo
()
{
...
...
src/Compilers/Core/CodeAnalysisTest/MetadataReferences/AssemblyPortabilityPolicyTests.cs
浏览文件 @
16219e30
...
...
@@ -422,7 +422,6 @@ public void Fusion_TestEquals()
policy2
=
FusionAssemblyPortabilityPolicy
.
LoadFromFile
(
appConfig
.
Path
);
Assert
.
NotEqual
(
policy1
,
policy2
);
Assert
.
NotEqual
(
policy1
.
GetHashCode
(),
policy2
.
GetHashCode
());
var
appConfig2
=
Temp
.
CreateFile
().
WriteAllText
(
correctAppConfigText
);
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/EmitMetadata.vb
浏览文件 @
16219e30
...
...
@@ -434,7 +434,6 @@ End Class
Assert
.
Null
(
method1Ret
.
ContainingSymbol
)
Assert
.
Equal
(
ImmutableArray
.
Create
(
Of
Location
)(),
method1Ret
.
Locations
)
Assert
.
Equal
(
ImmutableArray
.
Create
(
Of
SyntaxReference
)(),
method1Ret
.
DeclaringSyntaxReferences
)
Assert
.
NotEqual
(
0
,
method1Ret
.
GetHashCode
)
Assert
.
True
(
classA
.
IsMustInherit
)
Assert
.
Equal
(
Accessibility
.
Public
,
classA
.
DeclaredAccessibility
)
...
...
src/Compilers/VisualBasic/Test/Semantic/Compilation/ReferenceManagerTests.vb
浏览文件 @
16219e30
...
...
@@ -1617,15 +1617,6 @@ End Class
Assert
.
NotEqual
(
mca1
,
Copymca1
)
Assert
.
Equal
(
mca1
.
ToString
,
Copymca1
.
ToString
)
Assert
.
Equal
(
mca1
.
Kind
,
Copymca1
.
Kind
)
'With no alias this will result in hashcode of 0
Dim
mrp1
As
MetadataReferenceProperties
=
refa
.
Properties
Assert
.
Equal
(
0
,
mrp1
.
GetHashCode
)
'With the use of the alias this will generate a hashcode
Dim
refb
=
AssemblyMetadata
.
CreateFromImage
(
a
.
EmitToArray
()).
GetReference
(
display
:
=
"A"
,
aliases
:
=
ImmutableArray
.
Create
(
"Alias1"
))
Dim
mrp2
As
MetadataReferenceProperties
=
refb
.
Properties
Assert
.
NotEqual
(
0
,
mrp2
.
GetHashCode
)
End
Sub
<
Fact
,
WorkItem
(
905495
,
"DevDiv"
)
>
...
...
src/Compilers/VisualBasic/Test/Semantic/Compilation/SemanticModelAPITests.vb
浏览文件 @
16219e30
...
...
@@ -2179,7 +2179,6 @@ Module M
Assert
.
True
(
conv3
<>
conv2
,
"Check equality implementation"
)
Assert
.
False
(
conv3
.
Equals
(
conv2
),
"Check equality implementation"
)
Assert
.
False
(
conv3
.
Equals
(
DirectCast
(
conv2
,
Object
)),
"Check equality implementation"
)
Assert
.
False
(
conv3
.
GetHashCode
()
=
conv2
.
GetHashCode
(),
"Check equality implementation"
)
CompilationUtils
.
AssertNoErrors
(
compilation
)
End
Sub
...
...
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/TypeTests.vb
浏览文件 @
16219e30
...
...
@@ -133,9 +133,10 @@ End Namespace
Assert
.
Same
(
delegateB
,
delegateB
.
TypeParameters
(
0
).
ContainingSymbol
)
Assert
.
Equal
(
1
,
delegateB
.
Locations
.
Length
())
Assert
.
Equal
(
"System.MulticastDelegate"
,
delegateB
.
BaseType
.
ToTestDisplayString
())
Assert
.
NotEqual
(
0
,
IdentifierComparison
.
GetHashCode
(
"B"
))
Assert
.
NotEqual
(
0
,
IdentifierComparison
.
GetHashCode
(
"A"
))
#If Not DISABLE_GOOD_HASH_TESTS Then
Assert
.
NotEqual
(
IdentifierComparison
.
GetHashCode
(
"A"
),
IdentifierComparison
.
GetHashCode
(
"B"
))
#End If
Dim
enumE
=
DirectCast
(
membersOfN
(
2
),
NamedTypeSymbol
)
Assert
.
Equal
(
nsN
.
GetTypeMembers
(
"E"
,
0
).
First
(),
enumE
)
Assert
.
Equal
(
nsN
,
enumE
.
ContainingSymbol
)
...
...
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb
浏览文件 @
16219e30
...
...
@@ -5,9 +5,9 @@ Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
...
...
@@ -22244,7 +22244,6 @@ End Class
Assert.Equal("B", errTypeSym.Name)
Assert.Equal(0, errTypeSym.TypeArguments.Length)
Assert.Equal(0, errTypeSym.TypeParameters.Length)
Assert.NotEqual(0, errTypeSym.GetHashCode)
Assert.Equal(errTypeSym.CandidateSymbols.Length, errTypeSym.IErrorTypeSymbol_CandidateSymbols.Length)
End Sub
...
...
src/Compilers/VisualBasic/Test/Syntax/TestSyntaxNodes.vb
浏览文件 @
16219e30
...
...
@@ -110,8 +110,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
Loop
End
If
Assert
.
NotEqual
(
0
,
children
.
GetHashCode
)
Assert
.
NotEqual
(
0
,
children
.
Reverse
.
GetHashCode
)
Dim
b1
As
Integer
=
0
Dim
enumerator
=
children
.
GetEnumerator
enumerator
.
Reset
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录