michael@0: if (typeof TypedObject === 'undefined') michael@0: quit(); michael@0: michael@0: var StructType = TypedObject.StructType; michael@0: var uint8 = TypedObject.uint8; michael@0: michael@0: function check(c) { michael@0: assertEq(c.r, 129); michael@0: } michael@0: michael@0: function run() { michael@0: var RgbColor = new StructType({r: uint8, g: uint8, b: uint8}); michael@0: var Fade = new StructType({from: RgbColor, to: RgbColor}); michael@0: michael@0: var BrgColor = new StructType({b: uint8, r: uint8, g: uint8}); michael@0: var BrgFade = new StructType({from: BrgColor, to: BrgColor}); michael@0: michael@0: var gray = new RgbColor({r: 129, g: 128, b: 127}); michael@0: michael@0: var fade = new Fade({from: gray, to: gray}); michael@0: fade.to = {r: 129, g: 128, b: 127}; michael@0: michael@0: var brgGray = new BrgColor(gray); michael@0: fade.from = brgGray; michael@0: michael@0: var brgFade = new BrgFade(fade); michael@0: michael@0: check(fade.to); michael@0: check(brgFade.to); michael@0: check(fade.to); michael@0: check(brgFade.to); michael@0: } michael@0: michael@0: run();