Skip to content

Commit 757f2a0

Browse files
committed
BridgeJS: Add E2E test for instance property access via globalThis
1 parent 40fa074 commit 757f2a0

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

Tests/BridgeJSGlobalTests/Generated/BridgeJS.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,27 @@ public func _bjs_GlobalUtils_PublicConverter_toString(_ _self: UnsafeMutableRawP
296296
#endif
297297
}
298298

299+
@_expose(wasm, "bjs_GlobalUtils_PublicConverter_precision_get")
300+
@_cdecl("bjs_GlobalUtils_PublicConverter_precision_get")
301+
public func _bjs_GlobalUtils_PublicConverter_precision_get(_ _self: UnsafeMutableRawPointer) -> Int32 {
302+
#if arch(wasm32)
303+
let ret = GlobalUtils.PublicConverter.bridgeJSLiftParameter(_self).precision
304+
return ret.bridgeJSLowerReturn()
305+
#else
306+
fatalError("Only available on WebAssembly")
307+
#endif
308+
}
309+
310+
@_expose(wasm, "bjs_GlobalUtils_PublicConverter_precision_set")
311+
@_cdecl("bjs_GlobalUtils_PublicConverter_precision_set")
312+
public func _bjs_GlobalUtils_PublicConverter_precision_set(_ _self: UnsafeMutableRawPointer, _ value: Int32) -> Void {
313+
#if arch(wasm32)
314+
GlobalUtils.PublicConverter.bridgeJSLiftParameter(_self).precision = Int.bridgeJSLiftParameter(value)
315+
#else
316+
fatalError("Only available on WebAssembly")
317+
#endif
318+
}
319+
299320
@_expose(wasm, "bjs_GlobalUtils_PublicConverter_deinit")
300321
@_cdecl("bjs_GlobalUtils_PublicConverter_deinit")
301322
public func _bjs_GlobalUtils_PublicConverter_deinit(_ pointer: UnsafeMutableRawPointer) -> Void {

Tests/BridgeJSGlobalTests/Generated/JavaScript/BridgeJS.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,19 @@
156156
"GlobalUtils"
157157
],
158158
"properties" : [
159+
{
160+
"isReadonly" : false,
161+
"isStatic" : false,
162+
"name" : "precision",
163+
"namespace" : [
164+
"GlobalUtils"
165+
],
166+
"type" : {
167+
"int" : {
159168

169+
}
170+
}
171+
}
160172
],
161173
"swiftCallName" : "GlobalUtils.PublicConverter"
162174
}

Tests/BridgeJSGlobalTests/GlobalAPITests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ enum Internal {
6363

6464
@JS enum GlobalUtils {
6565
@JS class PublicConverter {
66+
@JS var precision: Int = 2
67+
6668
@JS init() {}
6769

6870
@JS func toString(value: Int) -> String {

Tests/prelude.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,9 @@ function BridgeJSGlobalTests_runJsWorksGlobal() {
10321032

10331033
const globalConverter = new globalThis.GlobalUtils.PublicConverter();
10341034
assert.equal(globalConverter.toString(99), "99");
1035+
assert.equal(globalConverter.precision, 2);
1036+
globalConverter.precision = 5;
1037+
assert.equal(globalConverter.precision, 5);
10351038
globalConverter.release();
10361039

10371040
const globalHttpServer = new globalThis.GlobalNetworking.API.TestHTTPServer();

0 commit comments

Comments
 (0)