File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
1
# ! nqp
2
2
3
- plan (16 );
3
+ plan (22 );
4
4
5
5
# Serializing an empty SC.
6
6
{
@@ -78,3 +78,37 @@ plan(16);
78
78
ok (nqp ::unbox_s($ dsc [0 ]) eq ' dugong' , ' deserialized object has correct value' );
79
79
}
80
80
81
+ # Serializing an SC with a P6opaque containing a P6int, P6num and P6str.
82
+ {
83
+ my $ sc := pir::nqp_create_sc__Ps(' TEST_SC_5_IN' );
84
+ my $ sh := pir::new__Ps(' ResizableStringArray' );
85
+
86
+ class T4 {
87
+ has int $ ! a ;
88
+ has num $ ! b ;
89
+ has str $ ! c ;
90
+ method BUILD () {
91
+ $ ! a := 42 ;
92
+ $ ! b := 6.9 ;
93
+ $ ! c := ' llama' ;
94
+ }
95
+ method a () { $ ! a }
96
+ method b () { $ ! b }
97
+ method c () { $ ! c }
98
+ }
99
+ my $ v := T4. new ();
100
+ $ sc [0 ] := $ v ;
101
+
102
+ my $ serialized := pir::nqp_serialize_sc__SPP($ sc , $ sh );
103
+ ok (nqp :: chars ($ serialized ) > 36 , ' serialized SC with P6opaque output longer than a header' );
104
+
105
+ my $ dsc := pir::nqp_create_sc__Ps(' TEST_SC_5_OUT' );
106
+ pir::nqp_deserialize_sc__vSPP($ serialized , $ dsc , $ sh );
107
+
108
+ ok (nqp :: elems ($ dsc ) == 1 , ' deserialized SC has a single element' );
109
+ ok (nqp ::istype($ dsc [0 ], T4), ' deserialized object has correct type' );
110
+ ok ($ dsc [0 ]. a == 42 , ' P6int attribute has correct value' );
111
+ ok ($ dsc [0 ]. b == 6.9 , ' P6num attribute has correct value' );
112
+ ok ($ dsc [0 ]. c == ' llama' , ' P6str attribute has correct value' );
113
+ }
114
+
You can’t perform that action at this time.
0 commit comments