Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0080456

Browse files
committed
Update param array test case to build C# component on-the-fly instead of using a checked-in binary. Also fill in the test case a bit more. (changeset 1239498)
1 parent8e5f72e commit0080456

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

‎tests/fsharpqa/Source/Misc/ConsumeParamArray.fsscript‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,29 @@ type Foo() =
1818

1919
[<assembly:AttributeWithParamArray ([| |])>]
2020
do
21-
let testPassed =
22-
let getTestAttribute (t : Type) =
23-
let tyAttributes = t.GetCustomAttributes(false)
24-
let attrib = tyAttributes |> Array.find (fun attrib -> match attrib with :? AttributeWithParamArray -> true | _ -> false)
25-
(attrib :?> AttributeWithParamArray)
26-
27-
let tyFoo = typeof<Foo>
28-
let testAtt = getTestAttribute tyFoo
29-
if testAtt.Parameters <> [| (0 :> obj) |] then
30-
false
31-
else
32-
true
21+
let getTestAttribute (t : Type) =
22+
let tyAttributes = t.GetCustomAttributes(false)
23+
let attrib = tyAttributes |> Array.find (fun attrib -> match attrib with :? AttributeWithParamArray -> true | _ -> false)
24+
(attrib :?> AttributeWithParamArray)
25+
26+
let tyFoo = typeof<Foo>
27+
let testAtt = getTestAttribute tyFoo
28+
if testAtt.Parameters <> [| (0 :> obj) |] then
29+
printfn "Attribute parameters not as expected"
30+
exit 1
31+
32+
let directCallWorks =
33+
CSParamArray.Method(9, 8, 7) + CSParamArray.Method(1, 2) + CSParamArray.Method() = (9 + 8 + 7) + (1 + 2)
34+
if not directCallWorks then
35+
printfn "Calling C# param array method gave unexpected result"
36+
exit 1
3337

34-
if not testPassed then exit 1
38+
let callParamArray (x : int array) = CSParamArray.Method(x)
39+
let asArrayCallWorks = (callParamArray [| 9; 8; 7 |]) = (9 + 8 + 7)
40+
if not asArrayCallWorks then
41+
printfn "Calling C# param array method, passing args as an array, gave unexpected result"
42+
exit 1
43+
3544
exit 0
45+
46+

‎tests/fsharpqa/Source/Misc/ParamArray.cs‎

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,27 @@
22

33
namespaceCSharpAssembly
44
{
5-
[AttributeUsage(AttributeTargets.All)]
6-
publicclassAttributeWithParamArray:Attribute
7-
{
8-
publicobject[]Parameters;
5+
[AttributeUsage(AttributeTargets.All)]
6+
publicclassAttributeWithParamArray:Attribute
7+
{
8+
publicobject[]Parameters;
99

10-
publicAttributeWithParamArray(paramsobject[]x)
11-
{
10+
publicAttributeWithParamArray(paramsobject[]x)
11+
{
1212

13-
Parameters=x;
14-
}
15-
}
13+
Parameters=x;
14+
}
15+
}
1616

17-
publicclassFoo
18-
{
19-
staticintMain(string[]args)
20-
{
21-
Console.WriteLine(Foo.Method());
22-
Console.WriteLine(Foo.Method(1));
23-
Console.WriteLine(Foo.Method(1,2));
24-
Console.WriteLine(Foo.Method(1,2,3));
25-
Console.WriteLine(Foo.Method(1,2,3,4));
17+
publicclassCSParamArray
18+
{
19+
publicstaticintMethod(paramsint[]allArgs)
20+
{
21+
inttotal=0;
22+
foreach(intiinallArgs)
23+
total+=i;
2624

27-
return0;
28-
}
29-
30-
staticintMethod(paramsint[]allArgs)
31-
{
32-
inttotal=0;
33-
foreach(intiinallArgs)
34-
total+=i;
35-
36-
returntotal;
37-
}
38-
}
25+
returntotal;
26+
}
27+
}
3928
}
-4 KB
Binary file not shown.

‎tests/fsharpqa/Source/Misc/env.lst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SOURCE=ConsumeParamArray.fsscript# ConsumeParamArray.fsscript
2-
SOURCE=E_ConsumeParamArray.fsscript# E_ConsumeParamArray.fsscript
1+
PRECMD="\$CSC_PIPE /target:library ParamArray.cs"SOURCE=ConsumeParamArray.fsscript# ConsumeParamArray.fsscript
2+
PRECMD="\$CSC_PIPE /target:library ParamArray.cs"SOURCE=E_ConsumeParamArray.fsscript# E_ConsumeParamArray.fsscript
33

44
SOURCE=E_productioncoverage01.fs# E_productioncoverage01.fs
55
SOURCE=E_productioncoverage02.fs# E_productioncoverage02.fs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp