Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
49a82631
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,发现更多精彩内容 >>
提交
49a82631
编写于
6月 15, 2016
作者:
B
B. Nordli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests in PatternMatchingTests that fails in cultures with different decimal separator than '.'.
上级
ac8f350e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
104 addition
and
16 deletion
+104
-16
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
...rs/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
+40
-16
src/Test/Utilities/Shared/FX/EnsureEnglishCulture.cs
src/Test/Utilities/Shared/FX/EnsureEnglishCulture.cs
+63
-0
src/Test/Utilities/Shared/TestUtilities.projitems
src/Test/Utilities/Shared/TestUtilities.projitems
+1
-0
未找到文件。
src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests.cs
浏览文件 @
49a82631
...
...
@@ -177,7 +177,9 @@ public static void Test<T>(object x)
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
(
);
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"expression 1 is not String
expression foo is not Int32
expression 1 is Int32 1
...
...
@@ -186,7 +188,8 @@ public static void Test<T>(object x)
expression 1 is Nullable`1 1
expression is not Nullable`1
expression is not String"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
@@ -285,11 +288,14 @@ private static void M(object o)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"No for 1
Yes for 10
No for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
@@ -317,11 +323,14 @@ private static bool M(object o, bool result)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"False for 1
True for 10
False for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
@@ -350,11 +359,14 @@ private static bool M(object o, bool result)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"False for 1
True for 10
False for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
,
WorkItem
(
8778
,
"https://github.com/dotnet/roslyn/issues/8778"
)]
...
...
@@ -383,11 +395,14 @@ private static bool M(object o, bool result)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
.
WithLocalFunctionsFeature
());
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"False for 1
True for 10
False for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
,
WorkItem
(
8778
,
"https://github.com/dotnet/roslyn/issues/8778"
)]
...
...
@@ -418,11 +433,14 @@ private static bool M(object o, bool result)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"False for 1
True for 10
False for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
@@ -489,11 +507,14 @@ private static bool M(object o, bool result)
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"False for 1
True for 10
False for 1.2"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
@@ -539,7 +560,9 @@ public static void Main()
"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
,
options
:
TestOptions
.
DebugExe
,
parseOptions
:
patternParseOptions
);
compilation
.
VerifyDiagnostics
();
var
expectedOutput
=
using
(
new
EnsureEnglishCulture
())
{
var
expectedOutput
=
@"one
int 10
long 20
...
...
@@ -550,7 +573,8 @@ struct Boolean True
struct X X
class Exception System.Exception: boo
"
;
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
var
comp
=
CompileAndVerify
(
compilation
,
expectedOutput
:
expectedOutput
);
}
}
[
Fact
]
...
...
src/Test/Utilities/Shared/FX/EnsureEnglishCulture.cs
0 → 100644
浏览文件 @
49a82631
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Diagnostics
;
using
System.Globalization
;
using
System.Threading
;
namespace
Roslyn.Test.Utilities
{
public
class
EnsureEnglishCulture
:
IDisposable
{
public
static
CultureInfo
PreferredOrNull
{
get
{
var
currentCultureName
=
CultureInfo
.
CurrentCulture
.
Name
;
if
(
currentCultureName
.
Length
==
0
||
currentCultureName
.
StartsWith
(
"en"
,
StringComparison
.
OrdinalIgnoreCase
))
{
return
null
;
}
return
CultureInfo
.
InvariantCulture
;
}
}
private
bool
_needToRestore
;
private
readonly
CultureInfo
_threadCulture
;
private
readonly
int
_threadId
;
public
EnsureEnglishCulture
()
{
_threadId
=
Thread
.
CurrentThread
.
ManagedThreadId
;
var
preferred
=
PreferredOrNull
;
if
(
preferred
!=
null
)
{
_threadCulture
=
CultureInfo
.
CurrentCulture
;
_needToRestore
=
true
;
#if DNX
CultureInfo
.
CurrentCulture
=
preferred
;
#else
Thread
.
CurrentThread
.
CurrentCulture
=
preferred
;
#endif
}
}
public
void
Dispose
()
{
Debug
.
Assert
(
_threadId
==
Thread
.
CurrentThread
.
ManagedThreadId
);
if
(
_needToRestore
&&
_threadId
==
Thread
.
CurrentThread
.
ManagedThreadId
)
{
_needToRestore
=
false
;
#if DNX
CultureInfo
.
CurrentCulture
=
_threadCulture
;
#else
Thread
.
CurrentThread
.
CurrentCulture
=
_threadCulture
;
#endif
}
}
}
}
src/Test/Utilities/Shared/TestUtilities.projitems
浏览文件 @
49a82631
...
...
@@ -43,6 +43,7 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\CultureHelpers.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\DirectoryHelper.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\EncodingUtilities.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\EnsureEnglishCulture.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\EnsureEnglishUICulture.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\EventWaiter.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)FX\ImmutableArrayTestExtensions.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录