Branch: Tag:

2016-11-23

2016-11-23 15:18:26 by Martin Karlgren <marty@roxen.com>

Testsuite: Add case for the new trampoline garbage avoidance technique.

Also fixed minor error in a nearby test.

6288:    return sizeof(q);    ]],2)    -  test_eq([[ +  test_any([[    int dummy;    gc();    function f = lambda() {
6304:    return n;    ]], 0)    +  test_any([[ +  // Make sure we don't get trampoline garbage with (named) lambdas +  // that reference variables in the parent scope. +  gc(); +  mapping m = ([]); +  class Refcounter() +  { mapping state; +  void create(mapping m) { state = m; state->refs++;} +  void destroy() {state->refs--;} +  }; +  int final_res; +  function foo() +  { +  object refc = Refcounter(m); +  final_res += m->refs; // Should add 1 here. +  int i = 1; +  int bar() +  { +  return i++; +  }; +  return bar; +  }; +  function bar = foo(); +  final_res += m->refs; // Should add 0 here. +  bar(); +  bar = 0; +  final_res += m->refs; // Should add 0 here. +  final_res += gc(); // Should add 0 here. +  return final_res; // 1 expected. +  ]], 1) +     test_true([[    class Foo    {