Skip to content

Commit 676e10c

Browse files
committed
migrate SymbolGraphTests
1 parent 8dbfc2e commit 676e10c

File tree

8 files changed

+127
-212
lines changed

8 files changed

+127
-212
lines changed

Package.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,9 @@ let package:Package = .init(
672672
.target(name: "Testing_"),
673673
]),
674674

675-
.executableTarget(name: "SymbolGraphTests",
675+
.testTarget(name: "SymbolGraphTests",
676676
dependencies: [
677677
.target(name: "SymbolGraphs"),
678-
.target(name: "Testing_"),
679678
]),
680679

681680
.executableTarget(name: "SymbolTests",
@@ -689,8 +688,7 @@ let package:Package = .init(
689688
.target(name: "System_"),
690689
.target(name: "Testing_"),
691690
],
692-
exclude:
693-
[
691+
exclude: [
694692
"directories",
695693
]),
696694

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import Availability
2+
import BSON
3+
import Testing
4+
5+
@Suite
6+
enum Availabilities
7+
{
8+
@Test
9+
static func Basic() throws
10+
{
11+
let availability:Availability = .init(.init(
12+
deprecated: .unconditionally,
13+
renamed: "Renamed",
14+
message: "Message"))
15+
16+
let bson:BSON.Document = .init(encoding: availability)
17+
let decoded:Availability = try .init(bson: bson)
18+
19+
#expect(availability == decoded)
20+
}
21+
@Test
22+
static func Agnostic() throws
23+
{
24+
let availability:Availability = .init(agnostic: [
25+
.swift: .init(
26+
deprecated: .since(.minor(.v(5, 8))),
27+
renamed: "Renamed",
28+
message: "Message"),
29+
])
30+
31+
let bson:BSON.Document = .init(encoding: availability)
32+
let decoded:Availability = try .init(bson: bson)
33+
34+
#expect(availability == decoded)
35+
}
36+
@Test
37+
static func Platform() throws
38+
{
39+
let availability:Availability = .init(platforms: [
40+
.macOS: .init(
41+
unavailable: .unconditionally,
42+
deprecated: .since(.patch(.v(0, 0, 0))),
43+
introduced: .patch(.v(5, 6, 7)),
44+
obsoleted: .minor(.v(8, 9)),
45+
renamed: "Renamed",
46+
message: "Message"),
47+
])
48+
49+
let bson:BSON.Document = .init(encoding: availability)
50+
let decoded:Availability = try .init(bson: bson)
51+
52+
#expect(availability == decoded)
53+
}
54+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import BSON
2+
import SymbolGraphs
3+
import Testing
4+
5+
struct Dependencies
6+
{
7+
@Test(arguments: [
8+
.init(package: .init(name: "swift-example"),
9+
requirement: .exact(.release(.v(1, 2, 3))),
10+
revision: 0xabcd1234,
11+
version: .stable(.release(.v(1, 2, 3)))),
12+
.init(package: .init(name: "swift-example"),
13+
requirement: nil,
14+
revision: 0xabcd1234,
15+
version: "master"),
16+
] as [SymbolGraphMetadata.Dependency])
17+
static func Dependency(_ value:SymbolGraphMetadata.Dependency) throws
18+
{
19+
let encoded:BSON.Document = .init(encoding: value)
20+
let decoded:SymbolGraphMetadata.Dependency = try .init(bson: encoded)
21+
22+
#expect(value == decoded)
23+
}
24+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import BSON
2+
import Signatures
3+
import SymbolGraphs
4+
import Testing
5+
6+
@Suite
7+
struct Generics
8+
{
9+
@Test
10+
static func Parameters() throws
11+
{
12+
let parameters:[GenericParameter] = [
13+
.init(name: "T", depth: 0),
14+
.init(name: "Element", depth: 0),
15+
.init(name: "Element", depth: 1),
16+
.init(name: "Element", depth: 12),
17+
.init(name: "🇺🇸", depth: 1776),
18+
.init(name: "🇺🇸", depth: .max),
19+
]
20+
21+
let bson:BSON.List = .init(elements: parameters)
22+
let decoded:[GenericParameter] = try .init(bson: bson)
23+
24+
#expect(parameters == decoded)
25+
}
26+
27+
@Test(arguments: [
28+
.init(spelling: "", nominal: 13),
29+
.init(spelling: "Dictionary<Int, String>.Index", nominal: nil),
30+
] as [GenericType<Int32>],
31+
[
32+
.conformer,
33+
.subclass,
34+
.equal
35+
] as [GenericOperator])
36+
static func Constraints(_ whom:GenericType<Int32>, _ what:GenericOperator) throws
37+
{
38+
let constraint:GenericConstraint<Int32> = .where("T.RawValue",
39+
is: what,
40+
to: whom)
41+
42+
let bson:BSON.Document = .init(encoding: constraint)
43+
let decoded:GenericConstraint<Int32> = try .init(bson: bson)
44+
45+
#expect(constraint == decoded)
46+
}
47+
}

Sources/SymbolGraphTests/Main.Availabilities.swift

Lines changed: 0 additions & 71 deletions
This file was deleted.

Sources/SymbolGraphTests/Main.Dependencies.swift

Lines changed: 0 additions & 49 deletions
This file was deleted.

Sources/SymbolGraphTests/Main.Generics.swift

Lines changed: 0 additions & 74 deletions
This file was deleted.

Sources/SymbolGraphTests/Main.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)