Skip to content

Commit 379a6be

Browse files
committed
add testing
1 parent 42fd913 commit 379a6be

File tree

4 files changed

+68
-13
lines changed

4 files changed

+68
-13
lines changed

tests/fsharp/core/fsfromfsviacs/lib2.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,31 @@
22
using Microsoft.FSharp.Core;
33
using Microsoft.FSharp.Collections;
44

5+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("a")]
6+
57
public class Lib2
68
{
79
public static Lib.recd1 r1 = new Lib.recd1(3);
810
public static Lib.recd2 r2 = new Lib.recd2(3, "a");
911
public static Lib.rrecd2 rr2 = new Lib.rrecd2("a", 3);
1012
public static Lib.recd3<string> r3 = new Lib.recd3<string>(4, "c", null);
11-
13+
1214
public static Lib.discr1_0 d10a = Lib.discr1_0.Discr1_0_A;
1315
public static Lib.discr1_1 d11a = Lib.discr1_1.NewDiscr1_1_A(3);
1416
public static Lib.discr1_2 d12a = Lib.discr1_2.NewDiscr1_2_A(3, 4);
15-
17+
1618
public static Lib.discr2_0_0 d200a = Lib.discr2_0_0.Discr2_0_0_A;
1719
public static Lib.discr2_1_0 d210a = Lib.discr2_1_0.NewDiscr2_1_0_A(3);
1820
public static Lib.discr2_0_1 d201a = Lib.discr2_0_1.Discr2_0_1_A;
1921
public static Lib.discr2_1_1 d211a = Lib.discr2_1_1.NewDiscr2_1_1_A(3);
20-
22+
2123
public static Lib.discr2_0_0 d200b = Lib.discr2_0_0.Discr2_0_0_B;
2224
public static Lib.discr2_1_0 d210b = Lib.discr2_1_0.Discr2_1_0_B;
2325
public static Lib.discr2_0_1 d201b = Lib.discr2_0_1.NewDiscr2_0_1_B(3);
2426
public static Lib.discr2_1_1 d211b = Lib.discr2_1_1.NewDiscr2_1_1_B(4);
2527

26-
public static FSharpList<int> li1 = FSharpList<int>.Cons(3,FSharpList<int>.Empty);
27-
public static FSharpList<Lib.recd1> lr1 = FSharpList<Lib.recd1>.Cons(r1,FSharpList<Lib.recd1>.Empty);
28+
public static FSharpList<int> li1 = FSharpList<int>.Cons(3, FSharpList<int>.Empty);
29+
public static FSharpList<Lib.recd1> lr1 = FSharpList<Lib.recd1>.Cons(r1, FSharpList<Lib.recd1>.Empty);
2830

2931
public static FSharpOption<int> oi1 = FSharpOption<int>.Some(3);
3032
public static FSharpOption<Lib.recd1> or1 = FSharpOption<Lib.recd1>.Some(r1);
@@ -34,8 +36,27 @@ public class Lib2
3436

3537
public static Lib.StructUnionsTests.U0 u0 = Lib.StructUnionsTests.U0.U0;
3638
public static Lib.StructUnionsTests.U1 u1 = Lib.StructUnionsTests.U1.NewU1(3);
37-
public static Lib.StructUnionsTests.U2 u2 = Lib.StructUnionsTests.U2.NewU2(3,4);
39+
public static Lib.StructUnionsTests.U2 u2 = Lib.StructUnionsTests.U2.NewU2(3, 4);
3840

39-
static Lib2() { r3.recd3field3 = r3; }
41+
static Lib2() { r3.recd3field3 = r3; }
42+
43+
}
44+
45+
namespace Newtonsoft.Json.Converters
46+
{
47+
internal class SomeClass
48+
{
49+
public SomeClass() { }
50+
public static void SomeMethod() { }
51+
}
52+
public class ContainerClass
53+
{
54+
public ContainerClass() { }
55+
internal class SomeClass
56+
{
57+
public SomeClass() { }
58+
public static void SomeMethod() { }
59+
}
4060

61+
}
4162
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.FSharp;
2+
using Microsoft.FSharp.Core;
3+
using Microsoft.FSharp.Collections;
4+
5+
namespace Newtonsoft.Json.Converters
6+
{
7+
// This should be preferred over the same type in lib2.cs
8+
public class SomeClass
9+
{
10+
public SomeClass() { }
11+
public static void SomeMethod() { }
12+
}
13+
14+
public class ContainerClass
15+
{
16+
public ContainerClass() { }
17+
18+
// This should be preferred over the same type in lib2.cs
19+
public class SomeClass
20+
{
21+
public SomeClass() { }
22+
public static void SomeMethod() { }
23+
}
24+
25+
}
26+
}

tests/fsharp/core/fsfromfsviacs/test.fsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ module NestedStructPatternMatchingAcrossAssemblyBoundaries =
9292
let _ = test "structunion394b3f" (testPattern3mut(u2))
9393

9494

95+
let TestAccessibility() =
96+
let x = new Newtonsoft.Json.Converters.SomeClass()
97+
let x2 = new Newtonsoft.Json.Converters.ContainerClass.SomeClass()
98+
Newtonsoft.Json.Converters.SomeClass.SomeMethod()
99+
Newtonsoft.Json.Converters.ContainerClass.SomeClass.SomeMethod()
100+
95101
(*
96102
public Lib.discr1_0 d10a = Lib.discr1_0.MkDiscr1_0_A();
97103
public Lib.discr1_1 d11a = Lib.discr1_1.MkDiscr1_1_A(3);

tests/fsharp/core/tests_core.fs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,19 +316,21 @@ module FsFromFsViaCs =
316316
let csc = Printf.ksprintf (Commands.csc exec cfg.CSC)
317317
let fsc_flags = cfg.fsc_flags
318318

319-
// "%FSC%" %fsc_flags% -a -o:lib.dll -g lib.fs
320319
do! fsc "%s -a -o:lib.dll -g" fsc_flags ["lib.fs"]
321320

322-
// "%PEVERIFY%" lib.dll
323321
do! peverify "lib.dll"
324322

325-
// %CSC% /nologo /target:library /r:"%FSCOREDLLPATH%" /r:lib.dll /out:lib2.dll lib2.cs
326323
do! csc """/nologo /target:library /r:"%s" /r:lib.dll /out:lib2.dll""" cfg.FSCOREDLLPATH ["lib2.cs"]
327324

328-
// "%FSC%" %fsc_flags% -r:lib.dll -r:lib2.dll -o:test.exe -g test.fsx
329-
do! fsc "%s -r:lib.dll -r:lib2.dll -o:test.exe -g" fsc_flags ["test.fsx"]
325+
do! csc """/nologo /target:library /r:"%s" /out:lib3.dll""" cfg.FSCOREDLLPATH ["lib3.cs"]
326+
327+
do! fsc "%s -r:lib.dll -r:lib2.dll -r:lib3.dll -o:test.exe -g" fsc_flags ["test.fsx"]
328+
329+
do! peverify "test.exe"
330+
331+
// Same with library refrences the other way around
332+
do! fsc "%s -r:lib.dll -r:lib3.dll -r:lib2.dll -o:test.exe -g" fsc_flags ["test.fsx"]
330333

331-
// "%PEVERIFY%" test.exe
332334
do! peverify "test.exe"
333335

334336
}

0 commit comments

Comments
 (0)