pike.git / src / testsuite.in

version» Context lines:

pike.git/src/testsuite.in:1: - test_true([["$Id: testsuite.in,v 1.585 2003/01/15 14:49:52 nilsson Exp $"]]); + test_true([["$Id: testsuite.in,v 1.586 2003/01/15 19:07:15 mast Exp $"]]);      // This triggered a bug only if run sufficiently early.   test_compile_any([[#pike 7.2]])      cond([[all_constants()->_verify_internals]],   [[    test_do(_verify_internals())   ]]);   test_eq(1e1,10.0);   test_eq(1E1,10.0);
pike.git/src/testsuite.in:2689:   test_program([[inline string foo(string s){ while(s[0] == ' ' || s[0] == '\t') s = s[1..]; return(s); } string a() { return foo(" bar"); }]])         // lambda function tests      test_true([[lambda(int x) { return lambda() { return x; };}]])   test_eq([[lambda(int x) { return lambda() { return x; };}(4)()]],4)   test_eq([[lambda(int x) { return lambda() { return x; };}(17)()]],17)   test_eq([[lambda(int x) { return lambda() { return lambda() { return x; };};}(17)()()]],17)    + // trampoline tests + test_do([[{ +  function trampoline = +  lambda() { +  int i = 17; +  return lambda () { +  error ("Trampoline called.\n"); +  return i; +  }; +  }(); +  +  // Now find the trampoline object. Pike tries very hard to hide +  // it, so we have to do it the difficult way.. +  object obj; +  find_trampoline_object: { +  object start = this; +  for (obj = start; +  objectp (obj) || // It's a normal object. +  (intp (obj) && obj) || // It's a bignum object. +  zero_type (obj); // It's a destructed object. +  obj = _prev (obj)) +  if (obj->`() == trampoline) break find_trampoline_object; +  for (obj = _next (start); +  objectp (obj) || (intp (obj) && obj) || zero_type (obj); +  obj = _next (obj)) +  if (obj->`() == trampoline) break find_trampoline_object; +  error ("Trampoline object not found.\n"); +  } +  +  if (!obj) error ("Trampoline object false.\n"); +  if (!stringp (sprintf ("%O", obj))) +  // The important part is to try to call the _sprintf lfun in the +  // trampoline object, not to check what sprintf() returns. +  error ("Failed to describe trampoline object.\n"); +  }]]) +    // local function tests   test_eq(120,    [[ lambda()    {    int f(int i) { return i == 0 ? 1 : i*f(i-1); };    return f(5);    }(); ]])      test_eq([[function f;    for(int i = 0; i < 2; i++)