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 19assert (Reflect.has ({x: 0}, 'x') === true); 20assert (Reflect.has ({x: 0}, 'y') === false); 21 22assert (Reflect.has ({x: 0}, 'toString') === true); 23 24var object = { 25 prop: 'Apple' 26}; 27 28assert (Reflect.has (object, 'prop') === true); 29 30assert (2 === Reflect.has.length); 31 32try { 33 Reflect.has (); 34 assert (false); 35} catch (e) { 36 assert (e instanceof TypeError); 37} 38 39try { 40 Reflect.has (42, 'batcat'); 41 assert (false); 42} catch (e) { 43 assert (e instanceof TypeError); 44} 45 46try { 47 Reflect.has (null, 'bat'); 48 assert (false); 49} catch (e) { 50 assert (e instanceof TypeError); 51} 52 53var target = {bat: 42}; 54var a = { [Symbol.toPrimitive]: function () { return 'bat' } }; 55var b = { [Symbol.toPrimitive]: function () { throw 'cat' } }; 56 57assert (Reflect.has (target, a) === true); 58 59try { 60 Reflect.has (target, b); 61 assert (false); 62} catch (e) { 63 assert (e === 'cat'); 64} 65