v8/test/mjsunit/es6/classes-accesors.js
Mythri A 2c95484ae7 Reland [cleanup][test] split es6/classes.js into different tests
Reland after splitting large classes further.

es6/classes.js is large and causes timeouts and OOM on some of the
configurations.

Bug: v8:9246
Change-Id: I51952447eb6a6b46d78410d5d3798292f5a8d87d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1706061
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62864}
2019-07-23 09:13:26 +00:00

98 lines
2.7 KiB
JavaScript

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
var b = 'b';
(function TestOverwritingInstanceAccessors() {
var C, desc;
C = class {
[b]() { return 'B'; };
get b() { return 'get B'; };
};
desc = Object.getOwnPropertyDescriptor(C.prototype, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals('get B', desc.get());
assertEquals(undefined, desc.set);
C = class {
[b]() { return 'B'; };
set b(v) { return 'set B'; };
};
desc = Object.getOwnPropertyDescriptor(C.prototype, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals(undefined, desc.get);
assertEquals('set B', desc.set());
C = class {
set b(v) { return 'get B'; };
[b]() { return 'B'; };
get b() { return 'get B'; };
};
desc = Object.getOwnPropertyDescriptor(C.prototype, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals('get B', desc.get());
assertEquals(undefined, desc.set);
C = class {
get b() { return 'get B'; };
[b]() { return 'B'; };
set b(v) { return 'set B'; };
};
desc = Object.getOwnPropertyDescriptor(C.prototype, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals(undefined, desc.get);
assertEquals('set B', desc.set());
})();
(function TestOverwritingStaticAccessors() {
var C, desc;
C = class {
static [b]() { return 'B'; };
static get b() { return 'get B'; };
};
desc = Object.getOwnPropertyDescriptor(C, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals('get B', desc.get());
assertEquals(undefined, desc.set);
C = class {
static [b]() { return 'B'; };
static set b(v) { return 'set B'; };
};
desc = Object.getOwnPropertyDescriptor(C, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals(undefined, desc.get);
assertEquals('set B', desc.set());
C = class {
static set b(v) { return 'get B'; };
static [b]() { return 'B'; };
static get b() { return 'get B'; };
};
desc = Object.getOwnPropertyDescriptor(C, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals('get B', desc.get());
assertEquals(undefined, desc.set);
C = class {
static get b() { return 'get B'; };
static [b]() { return 'B'; };
static set b(v) { return 'set B'; };
};
desc = Object.getOwnPropertyDescriptor(C, 'b');
assertFalse(desc.enumerable);
assertTrue(desc.configurable);
assertEquals(undefined, desc.get);
assertEquals('set B', desc.set());
})();