Skip to content

Commit de28db9

Browse files
Update snapshot tests
1 parent 7384ac4 commit de28db9

31 files changed

+994
-877
lines changed

Plugins/BridgeJS/Sources/BridgeJSTool/ImportTS.swift

+9
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ struct ImportTS {
446446
let this: JSObject
447447
"""
448448
).with(\.trailingTrivia, .newlines(2))
449+
450+
DeclSyntax(
451+
"""
452+
init(this: JSObject) {
453+
self.this = this
454+
}
455+
"""
456+
).with(\.trailingTrivia, .newlines(2))
457+
449458
DeclSyntax(
450459
"""
451460
init(takingThis this: Int32) {

Plugins/BridgeJS/Tests/BridgeJSToolTests/ImportTSTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
let url = Self.inputsDirectory.appendingPathComponent(input)
2020
let tsconfigPath = url.deletingLastPathComponent().appendingPathComponent("tsconfig.json")
2121
try api.addSourceFile(url.path, tsconfigPath: tsconfigPath.path)
22-
let outputSwift = try api.finalize()
22+
let outputSwift = try #require(try api.finalize())
2323
let name = url.deletingPathExtension().deletingPathExtension().deletingPathExtension().lastPathComponent
2424
try assertSnapshot(
2525
name: name,

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -40,7 +40,7 @@ export async function createInstantiator(options, swift) {
4040
const js = swift.memory.heap;
4141

4242
return {
43-
check: function check(a, b, c, d) {
43+
check: function bjs_check(a, b, c, d) {
4444
instance.exports.bjs_check(a, b, c, d);
4545
},
4646
};

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -40,19 +40,19 @@ export async function createInstantiator(options, swift) {
4040
const js = swift.memory.heap;
4141

4242
return {
43-
checkInt: function checkInt() {
43+
checkInt: function bjs_checkInt() {
4444
const ret = instance.exports.bjs_checkInt();
4545
return ret;
4646
},
47-
checkFloat: function checkFloat() {
47+
checkFloat: function bjs_checkFloat() {
4848
const ret = instance.exports.bjs_checkFloat();
4949
return ret;
5050
},
51-
checkDouble: function checkDouble() {
51+
checkDouble: function bjs_checkDouble() {
5252
const ret = instance.exports.bjs_checkDouble();
5353
return ret;
5454
},
55-
checkBool: function checkBool() {
55+
checkBool: function bjs_checkBool() {
5656
const ret = instance.exports.bjs_checkBool() !== 0;
5757
return ret;
5858
},

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -40,7 +40,7 @@ export async function createInstantiator(options, swift) {
4040
const js = swift.memory.heap;
4141

4242
return {
43-
checkString: function checkString(a) {
43+
checkString: function bjs_checkString(a) {
4444
const aBytes = textEncoder.encode(a);
4545
const aId = swift.memory.retain(aBytes);
4646
instance.exports.bjs_checkString(aId, aBytes.length);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -40,7 +40,7 @@ export async function createInstantiator(options, swift) {
4040
const js = swift.memory.heap;
4141

4242
return {
43-
checkString: function checkString() {
43+
checkString: function bjs_checkString() {
4444
instance.exports.bjs_checkString();
4545
const ret = tmpRetString;
4646
tmpRetString = undefined;

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -77,7 +77,7 @@ export async function createInstantiator(options, swift) {
7777
}
7878
return {
7979
Greeter,
80-
takeGreeter: function takeGreeter(greeter) {
80+
takeGreeter: function bjs_takeGreeter(greeter) {
8181
instance.exports.bjs_takeGreeter(greeter);
8282
},
8383
};

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createInstantiator(options, swift) {
2222
}
2323
bjs["make_jsstring"] = function(ptr, len) {
2424
const bytes = new Uint8Array(memory.buffer, ptr, len);
25-
return swift.memory.retain(textEncoder.encode(bytes));
25+
return swift.memory.retain(textDecoder.decode(bytes));
2626
}
2727
bjs["init_memory_with_result"] = function(ptr, len) {
2828
const target = new Uint8Array(memory.buffer, ptr, len);
@@ -40,7 +40,7 @@ export async function createInstantiator(options, swift) {
4040
const js = swift.memory.heap;
4141

4242
return {
43-
check: function check() {
43+
check: function bjs_check() {
4444
instance.exports.bjs_check();
4545
},
4646
};

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/PrimitiveParameters.json

-54
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/PrimitiveParameters.swift

-10
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/PrimitiveReturn.json

-55
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/PrimitiveReturn.swift

-32
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/StringParameter.json

-27
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/StringParameter.swift

-14
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/StringReturn.json

-19
This file was deleted.

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftAPITests/StringReturn.swift

-13
This file was deleted.

0 commit comments

Comments
 (0)