• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Copyright 2014 the V8 project authors. All rights reserved.
16// Use of this source code is governed by a BSD-style license that can be
17// found in the LICENSE file.
18
19var object = {
20  property: 'Batcat'
21};
22
23Reflect.deleteProperty (object, 'property');
24
25assert (object.property === undefined);
26
27assert (2 === Reflect.deleteProperty.length);
28
29try {
30  Reflect.deleteProperty ();
31  assert (false);
32} catch (e) {
33  assert (e instanceof TypeError);
34}
35
36try {
37  Reflect.deleteProperty (42, 'bat');
38  assert (false);
39} catch (e) {
40  assert (e instanceof TypeError);
41}
42
43try {
44  Reflect.deleteProperty (null, 'bat');
45  assert (false);
46} catch (e) {
47  assert (e instanceof TypeError);
48}
49
50var target = {bat: 42};
51var a = { [Symbol.toPrimitive]: function() { return 'bat' } };
52var b = { [Symbol.toPrimitive]: function() { throw 'cat' } };
53
54assert (Reflect.deleteProperty (target, a));
55
56try {
57  Reflect.deleteProperty (target, b);
58  assert (false);
59} catch (e) {
60  assert (e === 'cat');
61}
62