File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 1
1
# ! nqp
2
2
3
- plan (53 );
3
+ plan (57 );
4
4
5
5
# Serializing an empty SC.
6
6
{
@@ -271,3 +271,36 @@ plan(53);
271
271
ok (+ $ dsc [0 ]. b[2 ] == 4 , ' array b third element is correct' );
272
272
}
273
273
274
+ # Hash in an object attribute.
275
+ {
276
+ my $ sc := pir::nqp_create_sc__Ps(' TEST_SC_10_IN' );
277
+ my $ sh := pir::new__Ps(' ResizableStringArray' );
278
+
279
+ class T9 {
280
+ has $ ! a ;
281
+ method new () {
282
+ my $ obj := nqp ::create(self );
283
+ $ obj . BUILD();
284
+ $ obj ;
285
+ }
286
+ method BUILD () {
287
+ my % h ;
288
+ % h <a > := 42 ;
289
+ % h <b > := ' polar bear' ;
290
+ $ ! a := % h ;
291
+ }
292
+ method a () { $ ! a }
293
+ }
294
+ my $ v := T9. new ();
295
+ pir::nqp_add_object_to_sc__vPiP($ sc , 0 , $ v );
296
+
297
+ my $ serialized := pir::nqp_serialize_sc__SPP($ sc , $ sh );
298
+
299
+ my $ dsc := pir::nqp_create_sc__Ps(' TEST_SC_10_OUT' );
300
+ pir::nqp_deserialize_sc__vSPP($ serialized , $ dsc , $ sh );
301
+
302
+ ok (nqp ::istype($ dsc [0 ], T9), ' deserialized object has correct type' );
303
+ ok (+ $ dsc [0 ]. a == 2 , ' hash came back with correct element count' );
304
+ ok ($ dsc [0 ]. a<a > == 42 , ' hash first element is correct' );
305
+ ok ($ dsc [0 ]. a<b > eq ' polar bear' , ' hash second element is correct' );
306
+ }
You can’t perform that action at this time.
0 commit comments