Skip to content

Commit 661615e

Browse files
committed
Fix tests
1 parent bb8bebf commit 661615e

File tree

6 files changed

+43
-37
lines changed

6 files changed

+43
-37
lines changed

Tests/GameMathTests/InterpolationTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ final class InterpolationTests: XCTestCase {
6767
let end = Quaternion(180°, axis: .right).normalized
6868

6969
do { // Start value
70-
let value = start.interpolated(to: end, .linear(0.0, options: [])).normalized
70+
let value = start.interpolated(to: end, .linear(0.0), options: []).normalized
7171
let expected = start
7272
XCTAssertEqual(value.w, expected.w, accuracy: .ulpOfOne)
7373
XCTAssertEqual(value.x, expected.x, accuracy: .ulpOfOne)
@@ -76,7 +76,7 @@ final class InterpolationTests: XCTestCase {
7676
}
7777

7878
do { // Halfway
79-
let value = start.interpolated(to: end, .linear(1 / 2, options: [])).normalized
79+
let value = start.interpolated(to: end, .linear(1 / 2), options: []).normalized
8080
let expected = Quaternion(90°, axis: .right).normalized
8181
let angleAroundX = expected.forward.angleAroundX
8282
let angleAroundY = expected.forward.angleAroundY
@@ -99,7 +99,7 @@ final class InterpolationTests: XCTestCase {
9999
}
100100

101101
do { // End value
102-
let value = start.interpolated(to: end, .linear(1.0, options: [])).normalized
102+
let value = start.interpolated(to: end, .linear(1.0), options: []).normalized
103103
let expected = end
104104
XCTAssertEqual(value.w, expected.w, accuracy: .ulpOfOne)
105105
XCTAssertEqual(value.x, expected.x, accuracy: .ulpOfOne)
@@ -115,7 +115,7 @@ final class InterpolationTests: XCTestCase {
115115
let end = Quaternion(-45°, axis: .right).normalized
116116

117117
do { // Start value
118-
let value = start.interpolated(to: end, .linear(0.0, options: .shortest)).normalized
118+
let value = start.interpolated(to: end, .linear(0.0), options: .shortest).normalized
119119
let expected = start
120120
XCTAssertEqual(value.w, expected.w, accuracy: .ulpOfOne)
121121
XCTAssertEqual(value.x, expected.x, accuracy: .ulpOfOne)
@@ -124,7 +124,7 @@ final class InterpolationTests: XCTestCase {
124124
}
125125

126126
do { // Halfway
127-
let value = start.interpolated(to: end, .linear(1 / 2, options: .shortest)).normalized
127+
let value = start.interpolated(to: end, .linear(1 / 2), options: .shortest).normalized
128128
let expected = Quaternion(0°, axis: .right).normalized
129129
let angleAroundX = expected.forward.angleAroundX
130130
let angleAroundY = expected.forward.angleAroundY
@@ -147,7 +147,7 @@ final class InterpolationTests: XCTestCase {
147147
}
148148

149149
do { // End value
150-
let value = start.interpolated(to: end, .linear(1.0, options: .shortest)).normalized
150+
let value = start.interpolated(to: end, .linear(1.0), options: .shortest).normalized
151151
let expected = end
152152
XCTAssertEqual(value.w, expected.w, accuracy: .ulpOfOne)
153153
XCTAssertEqual(value.x, expected.x, accuracy: .ulpOfOne)

Tests/GateEngineTests/Gravity/GravityErrorTests.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ import XCTest
1313
final class GravityErrorTests: GateEngineXCTestCase {
1414
var gravity: Gravity! = nil
1515
var randomValue: Int = 0
16+
1617
override func setUp() {
17-
gravity = Gravity()
18-
randomValue = Int.random(in: -10000 ..< 10000)
18+
self.gravity = Gravity()
19+
self.randomValue = Int.random(in: -10000 ..< 10000)
1920
}
2021

2122
// Make sure syntax errors throw
22-
func testGravitySyntaxError() throws {
23-
XCTAssertThrowsError(try gravity.compile(source: "vir myVar = 10; func main() {}"))
23+
func testGravitySyntaxError() async throws {
24+
do {
25+
try await gravity.compile(source: "vir myVar = 10; func main() {}")
26+
XCTFail()
27+
}catch{
28+
XCTAssertTrue(true)
29+
}
2430
}
2531

2632
// Make sure runtime errors throw
27-
func testGravityRuntimeError() throws {
33+
func testGravityRuntimeError() async throws {
2834
// runMain when there is no main
29-
try gravity.compile(source: "var myVar = 10; func myFunc() {return 1}")
35+
try await gravity.compile(source: "var myVar = 10; func myFunc() {return 1}")
3036
XCTAssertThrowsError(try gravity.runMain())
3137
}
3238

@@ -36,10 +42,10 @@ final class GravityErrorTests: GateEngineXCTestCase {
3642
}
3743

3844
// Is this legal? No idea
39-
func testCompilingMultipleTimes() throws {
40-
try gravity.compile(source: "var myVar = 10; func main() {return 100}")
45+
func testCompilingMultipleTimes() async throws {
46+
try await gravity.compile(source: "var myVar = 10; func main() {return 100}")
4147
XCTAssertEqual(try gravity.runMain(), 100)
42-
try gravity.compile(source: "func main() {return 101}")
48+
try await gravity.compile(source: "func main() {return 101}")
4349
XCTAssertEqual(try gravity.runMain(), 101)
4450
XCTAssertEqual(gravity.getVar("myVar"), 10)
4551
}

Tests/GateEngineTests/Gravity/GravityExtendingTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,53 @@ final class GravityExtendingTests: GateEngineXCTestCase {
1818
randomValue = Int.random(in: -10000 ..< 10000)
1919
}
2020

21-
func testHostGetClientVar() throws {
22-
try gravity.compile(source: "var randomValue = \(randomValue); func main() {}")
21+
func testHostGetClientVar() async throws {
22+
try await gravity.compile(source: "var randomValue = \(randomValue); func main() {}")
2323
try gravity.runMain()
2424
let value = gravity.getVar("randomValue")!
2525
XCTAssertEqual(value.getInt(), randomValue)
2626
}
2727

28-
func testHostSetClientVar() throws {
28+
func testHostSetClientVar() async throws {
2929
gravity.setVar("randomValue", to: randomValue)
30-
try gravity.compile(source: "extern var randomValue; func main() {}")
30+
try await gravity.compile(source: "extern var randomValue; func main() {}")
3131
try gravity.runMain()
3232
let value = gravity.getVar("randomValue")!
3333
XCTAssertEqual(value.getInt(), randomValue)
3434
}
3535

36-
func testHostRunClientClosure() throws {
36+
func testHostRunClientClosure() async throws {
3737
let gValue = gravity.createValue(randomValue)
38-
try gravity.compile(
38+
try await gravity.compile(
3939
source: "func myFunction(randomValue) {return randomValue}; func main() {}"
4040
)
4141
try gravity.runMain()
4242
let value = try gravity.runFunc("myFunction", withArguments: gValue)
4343
XCTAssertEqual(value.getInt(), randomValue)
4444
}
4545

46-
func testClientRunHostClosure() throws {
46+
func testClientRunHostClosure() async throws {
4747
gravity.setFunc("myFunction") { gravity, args in
4848
return gravity.createValue(self.randomValue)
4949
}
50-
try gravity.compile(
50+
try await gravity.compile(
5151
source: "extern func myFunction() {}; func main() {return myFunction()}"
5252
)
5353
let result = try gravity.runMain()
5454
XCTAssertEqual(result.getInt(), randomValue)
5555
}
5656

57-
func testHostGetClientInstance() throws {
58-
try gravity.compile(
57+
func testHostGetClientInstance() async throws {
58+
try await gravity.compile(
5959
source: "class TheThing {}; var theThing = TheThing(); func main() {}"
6060
)
6161
try gravity.runMain()
6262
let value = gravity.getInstance("theThing")!
6363
XCTAssertEqual(value.gravityClassName, "TheThing")
6464
}
6565

66-
func testHostGetClientInstanceVar() throws {
67-
try gravity.compile(
66+
func testHostGetClientInstanceVar() async throws {
67+
try await gravity.compile(
6868
source:
6969
"class TheThing {var myVar1; func myFunc(randomValue) { return randomValue}; var myVar2;}; var theThing = TheThing(); func main() {theThing.myVar2 = \(randomValue); theThing.myVar1 = 33}"
7070
)
@@ -74,9 +74,9 @@ final class GravityExtendingTests: GateEngineXCTestCase {
7474
XCTAssertEqual(instance.getVar("myVar1"), 33)
7575
}
7676

77-
func testHostRunClientInstanceClosure() throws {
77+
func testHostRunClientInstanceClosure() async throws {
7878
let gValue = gravity.createValue(randomValue)
79-
try gravity.compile(
79+
try await gravity.compile(
8080
source:
8181
"class TheThing {func myFunc(randomValue) {return randomValue}}; var theThing = TheThing(); func main() {}"
8282
)
@@ -88,13 +88,13 @@ final class GravityExtendingTests: GateEngineXCTestCase {
8888
XCTAssertEqual(value.getInt(), randomValue)
8989
}
9090

91-
func testHostCreateClientClass() throws {
91+
func testHostCreateClientClass() async throws {
9292
let theThingClass = gravity.createClass("TheThing")
9393
theThingClass.addVar("myVar")
9494
theThingClass.addFunc("myFunc") { gravity, sender, args in
9595
return "success!"
9696
}
97-
try gravity.compile(
97+
try await gravity.compile(
9898
source: "extern class TheThing; var theThing = TheThing(); func main() {}"
9999
)
100100
try gravity.runMain()

Tests/GateEngineTests/Gravity/GravityMultipleInstanceTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import XCTest
1111

1212
@MainActor
1313
final class GravityMultipleInstanceTests: GateEngineXCTestCase {
14-
func testMultipleInstanceSetVar() throws {
14+
func testMultipleInstanceSetVar() async throws {
1515
let script = "extern var myVar; func main() {return myVar}"
1616

1717
let gravity1 = Gravity()
1818
let gravity2 = Gravity()
1919

20-
try gravity1.compile(source: script)
20+
try await gravity1.compile(source: script)
2121
gravity1.setVar("myVar", to: 66)
2222

23-
try gravity2.compile(source: script)
23+
try await gravity2.compile(source: script)
2424
gravity2.setVar("myVar", to: 77)
2525

2626
gravity1.setVar("myVar", to: 11)

Tests/GateEngineTests/_GateEngineXCTestCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* http://stregasgate.com
66
*/
77

8-
import XCTest
8+
public import XCTest
99

1010
@testable import GateEngine
1111
@testable import Gravity

Tests/GravityTests/_GravityXCTestCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
#if !DISABLE_GRAVITY_TESTS
88

9-
import XCTest
9+
public import XCTest
1010
@testable import GateEngine
1111
@testable import Gravity
1212

@@ -18,7 +18,7 @@ open class GravityXCTestCase: XCTestCase {
1818
}
1919

2020
func runGravity(at path: String) async {
21-
let gravity = Gravity()
21+
let gravity = await Gravity()
2222

2323
do {
2424
try await gravity.compile(file: path)

0 commit comments

Comments
 (0)