michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var expect = "pass"; michael@0: var actual; michael@0: michael@0: /* michael@0: * We hardcode here that GenerateBlockId limits a program to 2^20 blocks. Start michael@0: * with 2^19 blocks, then test 2^20 - 1 blocks, finally test the limit. michael@0: */ michael@0: var s = "{}"; michael@0: for (var i = 0; i < 21; i++) michael@0: s += s; michael@0: michael@0: try { michael@0: eval(s); michael@0: actual = "pass"; michael@0: } catch (e) { michael@0: actual = "fail: " + e; michael@0: } michael@0: michael@0: assertEq(actual, expect); michael@0: michael@0: s += s.slice(0, -2); michael@0: michael@0: try { michael@0: eval(s); michael@0: actual = "pass"; michael@0: } catch (e) { michael@0: actual = "fail: " + e; michael@0: } michael@0: michael@0: assertEq(actual, expect); michael@0: michael@0: s += "{}"; michael@0: michael@0: try { michael@0: eval(s); michael@0: actual = "fail: expected InternalError: program too large"; michael@0: } catch (e) { michael@0: actual = (e.message == "program too large") ? "pass" : "fail: " + e; michael@0: } michael@0: michael@0: assertEq(actual, expect); michael@0: michael@0: reportCompare(0, 0, "ok");