Commit cb02a939 authored by Charles McCarthy's avatar Charles McCarthy Committed by Facebook GitHub Bot

Fix folly::dynamic ordering comparison operator bug for Type::NULLT vs Type::NULLT

Summary:
Fixes the bug referenced in the base commit of this stack.

Given that `folly::dynamic(nullptr) == folly::dynamic(nullptr)` returns true, `folly::dynamic(nullptr) < folly::dynamic(nullptr)` should return false to maintain ordering properties.

Reviewed By: Gownta

Differential Revision: D33456202

fbshipit-source-id: 3fc994cd76d6e119884e017f68b445ed438f7cea
parent 2e364fbb
...@@ -567,7 +567,7 @@ struct dynamic::CompareOp<dynamic::ObjectImpl> { ...@@ -567,7 +567,7 @@ struct dynamic::CompareOp<dynamic::ObjectImpl> {
template <> template <>
struct dynamic::CompareOp<std::nullptr_t> { struct dynamic::CompareOp<std::nullptr_t> {
static bool comp(std::nullptr_t const&, std::nullptr_t const&) { static bool comp(std::nullptr_t const&, std::nullptr_t const&) {
return true; return false;
} }
}; };
......
...@@ -540,14 +540,7 @@ void testComparisonOperatorsForEqualDynamicValues( ...@@ -540,14 +540,7 @@ void testComparisonOperatorsForEqualDynamicValues(
const dynamic& valueA, const dynamic& valueB) { const dynamic& valueA, const dynamic& valueB) {
testEqualityOperatorsForEqualValues(valueA, valueB); testEqualityOperatorsForEqualValues(valueA, valueB);
if (valueA.isNull() && valueB.isNull()) { if (valueA.isObject() || valueB.isObject()) {
// There's a bug in null vs null ordering comparison. This test is mainly
// for highlighting the behavior which will be fixed in a subsequent commit.
EXPECT_TRUE(valueA < valueB);
EXPECT_TRUE(valueA > valueB);
EXPECT_FALSE(valueB <= valueA);
EXPECT_FALSE(valueB >= valueA);
} else if (valueA.isObject() || valueB.isObject()) {
// Objects don't support ordering // Objects don't support ordering
testOrderingOperatorsThrowForObjectTypes(valueA, valueB); testOrderingOperatorsThrowForObjectTypes(valueA, valueB);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment