Branch: Tag:

2008-09-14

2008-09-14 16:18:25 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added tests of hiding of inherited symbols.

Rev: src/testsuite.in:1.854

1:   START_MARKER - test_true([["$Id: testsuite.in,v 1.853 2008/09/12 18:46:59 grubba Exp $"]]); + test_true([["$Id: testsuite.in,v 1.854 2008/09/14 16:18:25 grubba Exp $"]]);      // This triggered a bug only if run sufficiently early.   test_compile_any([[#pike 7.2]])
728:   }   }()->C()->D()->bonk_me()]],"oiff")    + test_any_equal([[ +  // Test hiding of inherited symbols with protected. +  class A { +  local mixed a() {} +  mixed b(); +  mixed c; +  local mixed d; +  extern mixed e; +  local mixed f; +  this_program get_a() { return this_program::this; } +  }; +  class B { +  inherit A; +  protected mixed a() {} +  protected mixed b() {} +  protected mixed c = a(); +  protected mixed d = b(); +  protected mixed e = a(); +  protected local mixed f = b(); +  this_program get_b() { return this_program::this; } +  }; +  class C { +  inherit B; +  this_program get_c() { return this_program::this; } +  }; +  class D { +  inherit C; +  this_program get_d() { return this_program::this; } +  }; +  object(D) d = D(); +  return ({ "A", sort(indices(d->get_a())), +  "B", sort(indices(d->get_b())), +  "C", sort(indices(d->get_c())), +  "D", sort(indices(d->get_d())) }); + ]], ({ "A", ({ "a", "b", "c", "d", "e", "f", "get_a" }), +  "B", ({ "get_a", "get_b" }), +  "C", ({ "get_a", "get_b", "get_c" }), +  "D", ({ "get_a", "get_b", "get_c", "get_d" }) })) +  + test_any_equal([[ +  // Test hiding of inherited symbols with private. +  class A { +  local mixed a() {} +  mixed b(); +  mixed c; +  local mixed d; +  extern mixed e; +  local mixed f; +  this_program get_a() { return this_program::this; } +  }; +  class B { +  inherit A; +  private mixed a() {} +  private mixed b() {} +  private mixed c = a(); +  private mixed d = b(); +  private mixed e = a(); +  private local mixed f = b(); +  this_program get_b() { return this_program::this; } +  }; +  class C { +  inherit B; +  this_program get_c() { return this_program::this; } +  }; +  class D { +  inherit C; +  this_program get_d() { return this_program::this; } +  }; +  object(D) d = D(); +  return ({ "A", sort(indices(d->get_a())), +  "B", sort(indices(d->get_b())), +  "C", sort(indices(d->get_c())), +  "D", sort(indices(d->get_d())) }); + ]], ({ "A", ({ "a", "b", "c", "d", "e", "f", "get_a" }), +  "B", ({ "get_a", "get_b" }), +  "C", ({ "get_a", "get_b", "get_c" }), +  "D", ({ "get_a", "get_b", "get_c", "get_d" }) })) +    test_compile_error([[    class A { constant q = "x"; }    class B { inherit A; string z="z"; constant q="x"+z; }