X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/944bf9362ff51217b1617f85126d26e821b8aa91..00d59354c311fb28730b7c9b117b0d91aac092cc:/test/test.sod diff --git a/test/test.sod b/test/test.sod index 72febd5..5a029cd 100644 --- a/test/test.sod +++ b/test/test.sod @@ -353,4 +353,26 @@ code c: tests { DONE(3); } +/*----- Static instances --------------------------------------------------*/ + +[link = SodObject, nick = st] +class StaticObject: SodObject { + int x, y = 2, z = 3; + [readonly = t] void step() { STEP(me->st.x); } +} + +[extern = t] instance StaticObject mystatic: st.x = 0, st.z = 69; +[const = nil] instance StaticObject otherstatic: st.x = 3, st.y = 42; + +code c: tests { + prepare("static instance"); + StaticObject_step(mystatic); + if (mystatic->st.y == 2) STEP(1); + if (mystatic->st.z == 69) STEP(2); + StaticObject_step(otherstatic); + if (otherstatic->st.y == 42) STEP(4); + if (otherstatic->st.z == 3) STEP(5); + DONE(6); +} + /*----- That's all, folks -------------------------------------------------*/