1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --harmony-sloppy
6// Flags: --allow-natives-syntax
7
8
9function ID(x) {
10  return x;
11}
12
13
14(function TestComputedMethodSuper() {
15  class Base {
16    m() {
17      return ' base m';
18    }
19  }
20  class Derived extends Base {
21    ['a']() { return 'a' + super.m(); }
22    [ID('b')]() { return 'b' + super.m(); }
23    [0]() { return '0' + super.m(); }
24    [ID(1)]() { return '1' + super.m(); }
25  }
26
27  assertSame(Derived.prototype, Derived.prototype.a[%HomeObjectSymbol()]);
28
29  assertEquals('a base m', new Derived().a());
30  assertEquals('b base m', new Derived().b());
31  assertEquals('0 base m', new Derived()[0]());
32  assertEquals('1 base m', new Derived()[1]());
33})();
34
35
36(function TestComputedGetterSuper() {
37  class Base {
38    m() {
39      return ' base m';
40    }
41  }
42  class Derived extends Base {
43    get ['a']() { return 'a' + super.m(); }
44    get [ID('b')]() { return 'b' + super.m(); }
45    get [0]() { return '0' + super.m(); }
46    get [ID(1)]() { return '1' + super.m(); }
47  }
48  assertEquals('a base m', new Derived().a);
49  assertEquals('b base m', new Derived().b);
50  assertEquals('0 base m', new Derived()[0]);
51  assertEquals('1 base m', new Derived()[1]);
52})();
53
54
55(function TestComputedSetterSuper() {
56  var value;
57  class Base {
58    m(name, v) {
59      value = name + ' ' + v;
60    }
61  }
62  class Derived extends Base {
63    set ['a'](v) { super.m('a', v); }
64    set [ID('b')](v) { super.m('b', v); }
65    set [0](v) { super.m('0', v); }
66    set [ID(1)](v) { super.m('1', v); }
67  }
68  new Derived().a = 2;
69  assertEquals('a 2', value);
70  new Derived().b = 3;
71  assertEquals('b 3', value);
72  new Derived()[0] = 4;
73  assertEquals('0 4', value);
74  new Derived()[1] = 5;
75  assertEquals('1 5', value);
76})();
77