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 15assert(Object.is(2, "foo") === false); 16assert(Object.is(null, 2) === false); 17 18var x; 19assert(Object.is(x, 2) === false); 20 21assert(Object.is(null, null) === true); 22 23assert(Object.is(2, 8) === false); 24assert(Object.is(8, 8) === true); 25 26assert(Object.is(3.14, 6.28) === false); 27assert(Object.is(3.14, 3.14) === true); 28 29assert(Object.is('foo', 'foo') === true); 30assert(Object.is('foo', 'bar') === false); 31assert(Object.is(new String('foo'), 'foo') === false); 32 33assert(Object.is([], []) === false); 34 35assert(Object.is(true, true) === true); 36assert(Object.is(false, false) === true); 37assert(Object.is(true, false) === false); 38assert(Object.is(false, true) === false); 39assert(Object.is("", false) === false); 40assert(Object.is(0, false) === false); 41 42sym1 = Symbol.for('foo'); 43sym2 = Symbol.for('foo'); 44assert(Object.is(sym1, sym2) === true); 45assert(Object.is(Symbol('foo'), Symbol('foo')) === false); 46 47var foo = { a: 1 }; 48var bar = { a: 1 }; 49var zoo = foo; 50assert(Object.is(foo, foo) === true); 51assert(Object.is(foo, bar) === false); 52assert(Object.is(foo, zoo) === true); 53 54// Special Cases 55assert(Object.is(+0, -0) === false); 56assert(Object.is(+0, 0) === true); 57assert(Object.is(-0, -0) === true); 58assert(Object.is(-0, 0) === false); 59assert(Object.is(NaN, 0/0) === true); 60