| 233 | } |
| 234 | |
| 235 | bool Value::operator==(const Value& other) const noexcept { |
| 236 | if (this == &other) { |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | if (_type != other._type) { |
| 241 | if (isNumber() && other.isNumber()) { |
| 242 | // Automatically converts for number representable objects |
| 243 | return toDouble() == other.toDouble(); |
| 244 | } |
| 245 | if (isString() && other.isString()) { |
| 246 | // Strings can be stored as InternedString or StaticString; normalize |
| 247 | // to StringBox for cross-subtype equality (e.g. comparing a JS-sourced |
| 248 | // value to a schema's compile-time string literal). |
| 249 | return toStringBox() == other.toStringBox(); |
| 250 | } |
| 251 | |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | switch (getType()) { |
| 256 | case ValueType::Null: |
| 257 | return true; |
| 258 | case ValueType::Undefined: |
| 259 | return true; |
| 260 | case ValueType::InternedString: |
| 261 | return toStringBox() == other.toStringBox(); |
| 262 | case ValueType::StaticString: |
| 263 | return *getStaticString() == *other.getStaticString(); |
| 264 | case ValueType::Int: |
| 265 | return _data.i == other._data.i; |
| 266 | case ValueType::Long: |
| 267 | return _data.l == other._data.l; |
| 268 | case ValueType::Double: |
| 269 | return _data.d == other._data.d; |
| 270 | case ValueType::Bool: |
| 271 | return _data.b == other._data.b; |
| 272 | case ValueType::Map: |
| 273 | return *getMap() == *other.getMap(); |
| 274 | case ValueType::Array: |
| 275 | return *getArray() == *other.getArray(); |
| 276 | case ValueType::TypedArray: |
| 277 | return *getTypedArray() == *other.getTypedArray(); |
| 278 | case ValueType::Function: |
| 279 | return getFunction() == other.getFunction(); |
| 280 | case ValueType::Error: |
| 281 | return getError() == other.getError(); |
| 282 | case ValueType::TypedObject: |
| 283 | return *getTypedObject() == *other.getTypedObject(); |
| 284 | case ValueType::ProxyTypedObject: |
| 285 | return getProxyObject() == other.getProxyObject(); |
| 286 | case ValueType::ValdiObject: |
| 287 | return getValdiObject().get() == other.getValdiObject().get(); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | bool Value::operator!=(const Value& other) const noexcept { |
| 292 | return !(*this == other); |
nothing calls this directly
no test coverage detected