@@ -221,6 +221,53 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) {
221
221
ph . sibling = newSibling ;
222
222
assert . equal ( ph . sibling . value , 123 ) ;
223
223
224
+ // Test lazy property
225
+ assert . equal ( ph . lazyValue , "computed lazily" ) ;
226
+ ph . lazyValue = "modified lazy" ;
227
+ assert . equal ( ph . lazyValue , "modified lazy" ) ;
228
+
229
+ // Test computed read-write property
230
+ assert . equal ( ph . computedReadWrite , "Value: 456" ) ;
231
+ ph . computedReadWrite = "Value: 777" ;
232
+ assert . equal ( ph . intValue , 777 ) ; // Should have parsed and set intValue
233
+ assert . equal ( ph . computedReadWrite , "Value: 777" ) ;
234
+
235
+ // Test computed readonly property
236
+ assert . equal ( ph . computedReadonly , 1554 ) ; // intValue * 2 = 777 * 2
237
+
238
+ // Test property with observers
239
+ // First, reset observer counts to start fresh
240
+ exports . resetObserverCounts ( ) ;
241
+ let initialStats = exports . getObserverStats ( ) ;
242
+ assert . equal ( initialStats , "willSet:0,didSet:0,willSetOld:0,willSetNew:0,didSetOld:0,didSetNew:0" ) ;
243
+
244
+ // Set property from JavaScript and verify observers are called
245
+ ph . observedProperty = 100 ;
246
+ assert . equal ( ph . observedProperty , 100 ) ;
247
+ let afterSetStats = exports . getObserverStats ( ) ;
248
+
249
+ // Verify willSet and didSet were called
250
+ // The stats should show: willSet:1,didSet:1,willSetOld:777,willSetNew:100,didSetOld:777,didSetNew:100
251
+ assert ( afterSetStats . includes ( "willSet:1" ) , `willSet should be called once, got: ${ afterSetStats } ` ) ;
252
+ assert ( afterSetStats . includes ( "didSet:1" ) , `didSet should be called once, got: ${ afterSetStats } ` ) ;
253
+ assert ( afterSetStats . includes ( "willSetOld:777" ) , `willSet should see old value 777, got: ${ afterSetStats } ` ) ;
254
+ assert ( afterSetStats . includes ( "willSetNew:100" ) , `willSet should see new value 100, got: ${ afterSetStats } ` ) ;
255
+ assert ( afterSetStats . includes ( "didSetOld:777" ) , `didSet should see old value 777, got: ${ afterSetStats } ` ) ;
256
+ assert ( afterSetStats . includes ( "didSetNew:100" ) , `didSet should see new value 100, got: ${ afterSetStats } ` ) ;
257
+
258
+ // Set property to a different value and verify observers are called again
259
+ ph . observedProperty = 200 ;
260
+ assert . equal ( ph . observedProperty , 200 ) ;
261
+ let afterSecondSetStats = exports . getObserverStats ( ) ;
262
+
263
+ // Now should be: willSet:2,didSet:2,willSetOld:100,willSetNew:200,didSetOld:100,didSetNew:200
264
+ assert ( afterSecondSetStats . includes ( "willSet:2" ) , `willSet should be called twice, got: ${ afterSecondSetStats } ` ) ;
265
+ assert ( afterSecondSetStats . includes ( "didSet:2" ) , `didSet should be called twice, got: ${ afterSecondSetStats } ` ) ;
266
+ assert ( afterSecondSetStats . includes ( "willSetOld:100" ) , `willSet should see old value 100 on second call, got: ${ afterSecondSetStats } ` ) ;
267
+ assert ( afterSecondSetStats . includes ( "willSetNew:200" ) , `willSet should see new value 200 on second call, got: ${ afterSecondSetStats } ` ) ;
268
+ assert ( afterSecondSetStats . includes ( "didSetOld:100" ) , `didSet should see old value 100 on second call, got: ${ afterSecondSetStats } ` ) ;
269
+ assert ( afterSecondSetStats . includes ( "didSetNew:200" ) , `didSet should see new value 200 on second call, got: ${ afterSecondSetStats } ` ) ;
270
+
224
271
ph . release ( ) ;
225
272
ph2 . release ( ) ;
226
273
@@ -235,40 +282,6 @@ function BridgeJSRuntimeTests_runJsWorks(instance, exports) {
235
282
const anyObject = { } ;
236
283
assert . equal ( exports . roundTripJSObject ( anyObject ) , anyObject ) ;
237
284
238
- // Test PropertyHolder's newly added lazy and computed properties
239
- // Create a new PropertyHolder for testing lazy/computed properties
240
- const testObj2 = { testProp2 : "test2" } ;
241
- const sibling2 = new exports . SimplePropertyHolder ( 777 ) ;
242
- const ph3 = new exports . PropertyHolder (
243
- 456 , // intValue
244
- 6.28 , // floatValue
245
- 1.414 , // doubleValue
246
- false , // boolValue
247
- "test2" , // stringValue
248
- testObj2 , // jsObject
249
- sibling2 // sibling
250
- ) ;
251
-
252
- // Test lazy property
253
- assert . equal ( ph3 . lazyValue , "computed lazily" ) ;
254
- ph3 . lazyValue = "modified lazy" ;
255
- assert . equal ( ph3 . lazyValue , "modified lazy" ) ;
256
-
257
- // Test computed readonly property
258
- assert . equal ( ph3 . computedReadonly , 912 ) ; // intValue * 2 = 456 * 2
259
-
260
- // Test computed read-write property
261
- assert . equal ( ph3 . computedReadWrite , "Value: 456" ) ;
262
- ph3 . computedReadWrite = "Value: 555" ;
263
- assert . equal ( ph3 . intValue , 555 ) ; // Should have parsed and set intValue
264
- assert . equal ( ph3 . computedReadWrite , "Value: 555" ) ;
265
-
266
- // Test property with observers
267
- ph3 . observedProperty = 100 ;
268
- assert . equal ( ph3 . observedProperty , 100 ) ;
269
-
270
- ph3 . release ( ) ;
271
-
272
285
try {
273
286
exports . throwsSwiftError ( true ) ;
274
287
assert . fail ( "Expected error" ) ;
0 commit comments