Skip to content

Commit 0756750

Browse files
committed
Update CallerFilePath tests to use current platform's path separator
1 parent 4c1f444 commit 0756750

File tree

1 file changed

+14
-11
lines changed
  • tests/fsharpqa/Source/Conformance/SpecialAttributesAndTypes/Imported/CallerInfo

1 file changed

+14
-11
lines changed

tests/fsharpqa/Source/Conformance/SpecialAttributesAndTypes/Imported/CallerInfo/CallerFilePath.fs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ type MyTy([<CallerFilePath>] ?p0 : string) =
1212
path
1313

1414
module Program =
15-
let matchesPath path (s : string) =
16-
s.EndsWith(path)
17-
&& not (s.Contains("\\\\"))
18-
&& not (path.Contains("\\.\\"))
19-
&& not (path.Contains("\\..\\"))
15+
let doubleSeparator = "##".Replace('#', System.IO.Path.DirectorySeparatorChar)
16+
let sameDirectory = "#.#".Replace('#', System.IO.Path.DirectorySeparatorChar)
17+
let parentDirectory = ".."
18+
let matchesPath (path : string) (s : string) =
19+
s.EndsWith(path.Replace('#', System.IO.Path.DirectorySeparatorChar))
20+
&& not (s.Contains(doubleSeparator))
21+
&& not (s.Contains(sameDirectory))
22+
&& not (s.Contains(parentDirectory))
2023

2124

2225
[<EntryPoint>]
@@ -25,41 +28,41 @@ module Program =
2528
let o1 = MyTy("42")
2629

2730
match o.Path with
28-
| Some(path) when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\CallerFilePath.fs" path -> ()
31+
| Some(path) when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#CallerFilePath.fs" path -> ()
2932
| x -> failwithf "Unexpected: %A" x
3033

3134
match o1.Path with
3235
| Some(path) when matchesPath "42" path -> ()
3336
| x -> failwithf "Unexpected: %A" x
3437

3538
match MyTy.GetCallerFilePath() with
36-
| Some(path) when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\CallerFilePath.fs" path -> ()
39+
| Some(path) when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#CallerFilePath.fs" path -> ()
3740
| x -> failwithf "Unexpected: %A" x
3841

3942
match MyTy.GetCallerFilePath("42") with
4043
| Some("42") -> ()
4144
| x -> failwithf "Unexpected: %A" x
4245

4346
match CallerInfoTest.FilePath() with
44-
| path when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\CallerFilePath.fs" path -> ()
47+
| path when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#CallerFilePath.fs" path -> ()
4548
| x -> failwithf "Unexpected: %A" x
4649

4750
match CallerInfoTest.FilePath("xyz") with
4851
| "xyz" -> ()
4952
| x -> failwithf "Unexpected: %A" x
5053

5154
match CallerInfoTest.AllInfo(21) with
52-
| (path, _, _) when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\CallerFilePath.fs" path -> ()
55+
| (path, _, _) when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#CallerFilePath.fs" path -> ()
5356
| x -> failwithf "Unexpected C# result with multiple parameter types: %A" x
5457

5558
# 345 "qwerty1"
5659
match CallerInfoTest.AllInfo(123) with
57-
| (path, _, _) when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\qwerty1" path -> ()
60+
| (path, _, _) when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#qwerty1" path -> ()
5861
| x -> failwithf "Unexpected C# result with multiple parameter types: %A" x
5962

6063
# 456 "qwerty2"
6164
match CallerInfoTest.AllInfo(123) with
62-
| (path, _, _) when matchesPath "Conformance\\SpecialAttributesAndTypes\\Imported\\CallerInfo\\qwerty2" path -> ()
65+
| (path, _, _) when matchesPath "Conformance#SpecialAttributesAndTypes#Imported#CallerInfo#qwerty2" path -> ()
6366
| x -> failwithf "Unexpected C# result with multiple parameter types: %A" x
6467

6568
0

0 commit comments

Comments
 (0)