mirror of
https://github.com/tc39/test262.git
synced 2025-05-12 02:40:29 +02:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
// Copyright 2018 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: --harmony-weak-refs
|
|
|
|
(function TestConstructWeakFactory() {
|
|
let wf = new WeakFactory();
|
|
assertEquals(wf.toString(), "[object WeakFactory]");
|
|
assertNotSame(wf.__proto__, Object.prototype);
|
|
assertSame(wf.__proto__.__proto__, Object.prototype);
|
|
})();
|
|
|
|
(function TestWeakFactoryConstructorCallAsFunction() {
|
|
let caught = false;
|
|
let message = "";
|
|
try {
|
|
let f = WeakFactory();
|
|
} catch (e) {
|
|
message = e.message;
|
|
caught = true;
|
|
} finally {
|
|
assertTrue(caught);
|
|
assertEquals(message, "Constructor WeakFactory requires 'new'");
|
|
}
|
|
})();
|
|
|
|
(function TestMakeCell() {
|
|
let wf = new WeakFactory();
|
|
let wc = wf.makeCell({});
|
|
assertEquals(wc.toString(), "[object WeakCell]");
|
|
assertNotSame(wc.__proto__, Object.prototype);
|
|
assertSame(wc.__proto__.__proto__, Object.prototype);
|
|
})();
|
|
|
|
(function TestMakeCellWithoutWeakFactory() {
|
|
assertThrows(() => WeakFactory.prototype.makeCell.call({}, {}), TypeError);
|
|
})();
|