Changeset 188de86 in git for Tst/Short/pyobject.tst
- Timestamp:
- Aug 2, 2012, 4:09:13 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'c987db42cd2ec943b97ac5746c99892ceddf909c')
- Children:
- 4f9652847609cefd5ff3b91d14f34611592ab699
- Parents:
- 0419aba8292e7109329604d8ad03b70f8ef6542344a1c2199e33375a631289eaab7a81954c8383e2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Tst/Short/pyobject.tst
r0419ab r188de86 138 138 attrib(new_pyobj, "new_attr"); // -> error message 139 139 140 // python list from empty Singular list (bug fixed?) 141 pyobject ll_empty = list(); 142 ll_empty; 143 144 // converting to and from intvec 145 intvec v0; 146 v0; 147 pyobject obj0 = v0; 148 obj0; 149 150 intvec v=(1,2,3); 151 pyobject obj = v; 152 obj; 153 intvec(obj); 154 155 intvec(python_eval("[1,2,9999999999]")); // -> error 156 intvec(python_eval("[1,2,list()]")); // -> error 157 158 ring r=0,x,lp; 159 def rl = ringlist(r); 160 161 python_eval("tuple")(list(rl[1..3])); 162 163 // interaction with newstruct'ed type 164 newstruct("wrapping","pyobject p"); 165 wrapping wrapped; 166 167 pyobject seventeen = 17; 168 wrapped.p = seventeen; 169 wrapped; 170 171 proc unwrap(wrapping arg) { return (arg.p); } 172 system("install", "wrapping", "pyobject", unwrap, 1); 173 174 pyobject released = wrapped; 175 released; 176 177 proc wrap(pyobject arg) { wrapping res; res.p = arg; return (res); } 178 system("install", "pyobject", "wrapping", wrap, 1); 179 180 pyobject nineteen = 19; 181 wrapped = nineteen; 182 wrapped; 183 184 185 // interaction with built-ins 186 proc to_poly(pyobject arg) { return (poly(23)); } 187 system("install", "pyobject", "poly", to_poly, 1); 188 189 pyobject for_poly="4poly"; 190 poly(for_poly); 191 192 proc from_poly(poly arg) { pyobject res = string(arg); return (res); } 193 system("install", "pyobject", "=", from_poly, 1); 194 195 poly p = x+1; 196 for_poly = p; 197 for_poly; 198 199 200 // interaction with both built-ins and newstructs 201 newstruct("another","pyobject p"); 202 another other; 203 other.p = seventeen; 204 other; 205 206 released = other; // -> error 207 released; 208 209 proc from_types(def arg) { 210 if (typeof(arg) == "poly") { return (from_poly(arg)); } 211 if (typeof(arg) == "another") { return (arg.p); } 212 } 213 system("install", "pyobject", "=", from_types, 1); 214 215 released = other; 216 released; 217 released = p; 218 released; 219 220 proc from_ideal(ideal arg) { pyobject res = "(missing)"; return (res); } 221 system("install", "pyobject", "=", from_ideal, 1); 222 pyobject ported = ringlist(r); 223 ported; 224 140 225 tst_status(1); 141 226 $
Note: See TracChangeset
for help on using the changeset viewer.