#  Check that constant folding works.
#
#  If it doesn't, we'll at least get diagnostics about non-constant sizes
#  in spec or record.  We might even get wrong output!

resource c
    type e = enum (zz, aa, bb, cc, dd, ee)
    const int c0 = int(bool(0.0))
    const int c1 = int(real(char(e(true))))
    const int c2 = int(char(real(real(bb))))
    const int c3 = int(char(e(3.14159)))
    const int c4 = int(dd)
    const int c5 = int(2*2.7183)
    const int c6 = -+-(2*3 + 12/4 - 5 + 19%17)
    const int c7 = (1<<3) - (3>>1)
    const int c8 = 58x & 29x
    const int c9 = (0Ex xor 6) | 1
    const int c10 = int (-+- (3 * 2.7 + 76.1 / 11 - 4.8))
    type t = rec (
	bool m1[c0:c5];
	char m2[c1:c6];
	int m3[c2:c7];
	e m4[c3:c8];
	real m5[c9];
	string[c10] m6;
	string[51/3-2*3] m7;
    )
    op o[c5]()
body c ()
    t  v 
    reply
    P(o[3])
    write ("in c:", c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
    write ("     ", lb(v.m1), ub(v.m1), lb(v.m2), ub(v.m2), lb(v.m3), ub(v.m3),
	lb(v.m4), ub(v.m4), lb(v.m5), ub(v.m5),
	maxlength(v.m6), maxlength(v.m7))
end

resource r ()
    import c
    t  v 
    cap c ccap = create c ()
    write ("in r:", c1, c2, c3, c4, c5, c.c6, c.c7, c8, c9, c10)
    write ("     ", lb(v.m1), ub(v.m1), lb(v.m2), ub(v.m2), lb(v.m3), ub(v.m3),
	lb(v.m4), ub(v.m4), lb(v.m5), ub(v.m5),
	maxlength(v.m6), maxlength(v.m7))
    ccap.o[3]()
    write ("done")
end
