Implement "SameValueZero" from ECMA 7.2.9
188508
public static boolean sameZero(Object x, Object y) {
        if (!typeof(x).equals(typeof(y))) {
            return false;
        }
        if (x instanceof Number) {
            if (isNaN(x) && isNaN(y)) {
                return true;
            }
            final double dx = ((Number)x).doubleValue();
            if (y instanceof Number) {
                final double dy = ((Number)y).doubleValue();
                if (((dx == negativeZero) && (dy == 0.0)) ||
                    ((dx == 0.0) && dy == negativeZero)) {
                        return true;
                }
            }
            return eqNumber(dx, y);
        }
        return eq(x, y);
    }
176169
public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
    {
        if (PropelTypes::CLOB_EMU === $cMap->getType()) {
            return $stmt->bindParam(':p'.$position, $value, $cMap->getPdoType(), strlen($value));
        }

        if ($cMap->isTemporal()) {
            $value = $this->formatTemporalValue($value, $cMap);
        } elseif (is_resource($value) && $cMap->isLob()) {
            // we always need to make sure that the stream is rewound, otherwise nothing will
            // get written to database.
            rewind($value);
        }

        return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
    }
496090
public static function equals($value, $comparedValue, $identical = false)
    {
        if (false === $identical) {
            return $value == $comparedValue;
        }

        return $value === $comparedValue;
    }
1029580
public function sameValueAs(ValueObjectInterface $stringLiteral)
    {
        if (false === Util::classEquals($this, $stringLiteral)) {
            return false;
        }

        return $this->toNative() === $stringLiteral->toNative();
    }
305849
def code=(code)
      validator = EnumAttributeValidator.new('String', ["Continue", "SwitchingProtocols", "OK", "Created", "Accepted", "NonAuthoritativeInformation", "NoContent", "ResetContent", "PartialContent", "MultipleChoices", "Ambiguous", "MovedPermanently", "Moved", "Found", "Redirect", "SeeOther", "RedirectMethod", "NotModified", "UseProxy", "Unused", "TemporaryRedirect", "RedirectKeepVerb", "BadRequest", "Unauthorized", "PaymentRequired", "Forbidden", "NotFound", "MethodNotAllowed", "NotAcceptable", "ProxyAuthenticationRequired", "RequestTimeout", "Conflict", "Gone", "LengthRequired", "PreconditionFailed", "RequestEntityTooLarge", "RequestUriTooLong", "UnsupportedMediaType", "RequestedRangeNotSatisfiable", "ExpectationFailed", "UpgradeRequired", "InternalServerError", "NotImplemented", "BadGateway", "ServiceUnavailable", "GatewayTimeout", "HttpVersionNotSupported"])
      if code.to_i == 0
        unless validator.valid?(code)
          raise ArgumentError, "invalid value for 'code', must be one of #{validator.allowable_values}."
        end
        @code = code
      else
        @code = validator.allowable_values[code.to_i]
      end
    end
1062902
private function deduplicateValueObjectInsertions()
    {
        $unitOfWork = $this->entityManager->getUnitOfWork();
        $entityInsertions = $unitOfWork->getScheduledEntityInsertions();

        $knownValueObjects = [];
        foreach ($entityInsertions as $entity) {
            $className = TypeHandling::getTypeForValue($entity);
            if ($this->reflectionService->getClassSchema($className)->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT) {
                $identifier = $this->persistenceManager->getIdentifierByObject($entity);

                if (isset($knownValueObjects[$className][$identifier]) || $unitOfWork->getEntityPersister($className)->exists($entity)) {
                    unset($entityInsertions[spl_object_hash($entity)]);
                    continue;
                }

                $knownValueObjects[$className][$identifier] = true;
            }
        }

        ObjectAccess::setProperty($unitOfWork, 'entityInsertions', $entityInsertions, true);
    }
361049
function(newval, oldval) {
		if ([newval, oldval].every(function(val) {
			return val.contains('edbml.$');
		})) {
			var newkeys = gui.KeyMaster.extractKey(newval);
			var oldkeys = gui.KeyMaster.extractKey(oldval);
			if (newkeys && oldkeys) {
				oldkeys.forEach(function(oldkey, i) {
					var newkey = newkeys[i];
					newval = newval.replace(newkey, '');
					oldval = oldval.replace(oldkey, '');
					this._functions[oldkey] = newkey;
				}, this);
				return newval === oldval;
			}
		}
		return false;
	}
25645
public function isEqual($a=null, $b=null) {
    list($a, $b) = self::_wrapArgs(func_get_args(), 2);
    
    if(isset($this) && isset($this->_chained) && $this->_chained) $a =& $this;
    
    if($a === $b) return self::_wrap(true);
    if(gettype($a) !== gettype($b)) return self::_wrap(false);
    if(is_callable($a) !== is_callable($b)) return self::_wrap(false);
    
    if($a == $b) return self::_wrap(true);
    
    // Objects and arrays compared by values
    if(is_object($a) || is_array($a)) {
      
      // Do either implement isEqual()?
      if(is_object($a) && isset($a->isEqual)) return self::_wrap($a->isEqual($b));
      if(is_object($b) && isset($b->isEqual)) return self::_wrap($b->isEqual($a));
      if(is_array($a) && array_key_exists('isEqual', $a)) return self::_wrap($a['isEqual']($b));
      if(is_array($b) && array_key_exists('isEqual', $b)) return self::_wrap($b['isEqual']($a));
      
      if(count($a) !== count($b)) return self::_wrap(false);
      
      $__ = new self;
      $keys_equal = $__->isEqual($__->keys($a), $__->keys($b));
      $values_equal = $__->isEqual($__->values($a), $__->values($b));
      return self::_wrap($keys_equal && $values_equal);
    }
    
    return self::_wrap(false);
  }
515448
private void recordCompatibilityInfo(JMFType access, JSchema accSchema, JMFType encoding,
      JSchema encSchema) throws JMFSchemaViolationException
  {
    if (access instanceof JSPrimitive)
      if (encoding instanceof JSPrimitive)
        recordCompatibilityInfo((JSPrimitive)access, accSchema, (JSPrimitive)encoding,
          encSchema);
      else if (encoding instanceof JSVariant)
        checkForDeletingVariant(access, (JSVariant)encoding, false, accSchema, encSchema);
      else {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JmfTr.debug(this, tc, "Compatibility violation (type mismatch) for JSPrimitive");
        violation(access, encoding);
       }
    else if (access instanceof JSEnum)
      if (encoding instanceof JSEnum)
        recordCompatibilityInfo((JSEnum)access, accSchema, (JSEnum)encoding, encSchema);
      else if (encoding instanceof JSVariant)
        checkForDeletingVariant(access, (JSVariant)encoding, false, accSchema, encSchema);
      else {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JmfTr.debug(this, tc, "Compatibility violation (type mismatch) for JSEnum");
        violation(access, encoding);
      }
    else if (access instanceof JSDynamic)
      if (encoding instanceof JSDynamic)
        recordOnePair((JSField)access, accSchema, (JSField)encoding, encSchema);
      else if (encoding instanceof JSVariant)
        checkForDeletingVariant(access, (JSVariant)encoding, false, accSchema, encSchema);
      else {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JmfTr.debug(this, tc, "Compatibility violation (type mismatch) for JSDynamic");
        violation(access, encoding);
      }
    else if (access instanceof JSRepeated)
      if (encoding instanceof JSRepeated)
        recordCompatibilityInfo(((JSRepeated)access).getItemType(), accSchema,
          ((JSRepeated)encoding).getItemType(), encSchema);
      else if (encoding instanceof JSVariant)
        checkForDeletingVariant(access, (JSVariant)encoding, false, accSchema, encSchema);
      else {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JmfTr.debug(this, tc, "Compatibility violation (type mismatch) for JSRepeated");
        violation(access, encoding);
      }
    else if (access instanceof JSTuple)
      if (encoding instanceof JSTuple)
        recordCompatibilityInfo((JSTuple)access, accSchema, (JSTuple)encoding, encSchema);
      else if (encoding instanceof JSVariant)
        checkForDeletingVariant(access, (JSVariant)encoding, false, accSchema, encSchema);
      else {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) JmfTr.debug(this, tc, "Compatibility violation (type mismatch) for JSTuple");
        violation(access, encoding);
      }
    else if (access instanceof JSVariant) {
      JSVariant accVar = (JSVariant)access;
      if (encoding instanceof JSVariant) {
        JSVariant encVar = (JSVariant)encoding;
        recordCompatibilityInfo(accVar, accSchema, encVar, encSchema);
      } else
        checkForDeletingVariant(encoding, accVar, true, accSchema, encSchema);
    }
  }
591245
protected function isUnique($value, $name, $locale, $parameters)
    {
        list ($connection, $table) = $this->getConnectionAndTable($parameters);

        $column = $this->getParameter($parameters, 1) ?? $name;
        $ignoreValue = $this->getParameter($parameters, 2);
        $ignoreColumn = $this->getParameter($parameters, 3);

        $query = $this->findTranslation($connection, $table, $column, $locale, $value);
        $query = $this->ignore($query, $ignoreColumn, $ignoreValue);
        $query = $this->addConditions($query, $this->getUniqueExtra($parameters));

        $isUnique = $query->count() === 0;

        return $isUnique;
    }
603317
public function sameValueAs(ValueObjectInterface $uuid)
    {
        if (false === Util::classEquals($this, $uuid)) {
            return false;
        }

        return $this->toNative() === $uuid->toNative();
    }
588679
function (values, schema, options, callback) {
    var newValues = {}
        , errors = []
        , modelList = find(schema)
        , val;

    for (var model in modelList) {
        if (_.isArray(modelList[model])) {

            if (values === undefined) {
                val = undefined;
            }
            else {
                val = values[model];
            }

            // Empty array defined in schema
            if (_.isEmpty(modelList[model])) {
                if (val) {
                    newValues[model] = val;
                }
            }
            else {
                // Set value to empty array if empty given
                if (val == undefined) {
                    if (options && options.partial == true) {
                        // Do nothing
                    }
                    else {
                        newValues[model] = [];
                    }
                }
                else {
                    // Sub model defined in schema
                    for (var thisSubSchema in modelList[model]) {
                        if (_.isArray(val)) {
                            for (var thisValue in val) {

                                // Check if type array or plain array
                                if (typeof val[thisValue] == "object") {
                                    modelCompare(val[thisValue], modelList[model][thisSubSchema], options, function (err, data) {
                                        if (err) {
                                            errors = _.union(errors, err);
                                        }
                                        if (data !== null) {
                                            if (!newValues[model]) {
                                                newValues[model] = [];
                                            }
                                            newValues[model][thisValue] = data;
                                        }
                                    });
                                }
                                else {
                                    rulesMatch(thisValue, val[thisValue], modelList[model][thisSubSchema], options, function (err, data) {
                                        if (err) {
                                            errors.push(err);
                                        }
                                        if (data !== undefined) {
                                            if (!newValues[model]) {
                                                newValues[model] = [];
                                            }
                                            newValues[model][thisValue] = data;
                                        }
                                    });
                                }
                            }
                        }
                        else {
                            modelCompare(val, modelList[model][thisSubSchema], options, function (err, data) {
                                if (err) {
                                    errors = _.union(errors, err);
                                }
                                if (data !== null) {
                                    newValues[model] = data;
                                }
                            });
                        }
                    }
                }
            }
        } else {
            // Check for definition of {} in model to allow any data for this node without validation
            if (_.isEmpty(modelList[model])) {
                for (var index in values) {
                    var filter = new RegExp("^" + model);
                    if (index.match(filter)) {
                        newValues[index] = values[index];
                    }
                }
            }
            else {
                if (values === undefined) {
                    val = undefined;
                }
                else {
                    val = values[model];
                }

                rulesMatch(model, val, modelList[model], options, function (err, data) {
                    if (err) {
                        errors.push(err);
                    }
                    if (data !== undefined) {
                        newValues[model] = data;
                    }
                });
            }
        }
    }

    if (_.isEmpty(errors)) {
        errors = null;
    }
    else {
        errors = {name: 'ValidationError', err: errors};
    }
    if (_.isEmpty(newValues)) {
        newValues = null;
    }
    callback(errors, newValues);
}
326903
private static boolean mappingCompatible(EntitySchema oldSchema,
      EntitySchema newSchema) {
    for (FieldMapping oldFieldMapping : oldSchema.getColumnMappingDescriptor()
        .getFieldMappings()) {
      FieldMapping newFieldMapping = newSchema.getColumnMappingDescriptor()
          .getFieldMapping(oldFieldMapping.getFieldName());
      if (newFieldMapping != null) {
        if (!oldFieldMapping.equals(newFieldMapping)) {
          return false;
        }
      }
    }
    return true;
  }
89629
function it_throws_an_exception_when_attempting_to_register_the_same_type_twice($converter)
    {
        $this->setType('decimal', $converter);
        $this->shouldThrow(new ResourceHandlerAlreadyDefinedException( 'An handler for resource "decimal" has already been registered.'))->duringSetType('decimal', $converter);
    }
183330
public function sameValueAs(ValueObjectInterface $street)
    {
        if (false === Util::classEquals($this, $street)) {
            return false;
        }

        return $this->getName()->sameValueAs($street->getName()) &&
               $this->getNumber()->sameValueAs($street->getNumber()) &&
               $this->getElements()->sameValueAs($street->getElements());
        ;
    }
1264475
function (value, modelsToIgnore) {
    modelsToIgnore = modelsToIgnore || {};

    modelsToIgnore[value.name] = value;

    // Response support
    if (value.examples && _.isPlainObject(value.examples)) {
      value = _.cloneDeep(value);
      var keys = Object.keys(value.examples);

      _.forEach(keys, function(key) {
        if(key.indexOf('application/json') === 0) {
          var example = value.examples[key];
          if (_.isString(example)) {
            example = jsyaml.safeLoad(example);
          }
          value.definition.example = example;
          return schemaToJSON(value.definition, example, modelsToIgnore, value.modelPropertyMacro);
        }
      });
    }

    if (value.examples) {
      value = _.cloneDeep(value);
      var example = value.examples;
      if (_.isString(example)) {
        example = jsyaml.safeLoad(example);
      }
      value.definition.example = example;
      return schemaToJSON(value.definition, example, modelsToIgnore, value.modelPropertyMacro);
    }

    return schemaToJSON(value.definition, value.models, modelsToIgnore, value.modelPropertyMacro);
  }
200931
function assertTlsOptionsAreEqual(optionName, queryString, queryStringKeys) {
  const queryStringHasTLSOption = queryStringKeys.indexOf(optionName) !== -1;

  let optionValue;
  if (Array.isArray(queryString[optionName])) {
    optionValue = queryString[optionName][0];
  } else {
    optionValue = queryString[optionName];
  }

  if (queryStringHasTLSOption) {
    if (Array.isArray(queryString[optionName])) {
      const firstValue = queryString[optionName][0];
      queryString[optionName].forEach(tlsValue => {
        if (tlsValue !== firstValue) {
          throw new MongoParseError('All values of ${optionName} must be the same.');
        }
      });
    }
  }

  return optionValue;
}